const Light = require("../lib/core");
import {resolvePath} from "../lib/utils"
import ajax from "../lib/ajax"
module.exports = {
    init(){

    },
    start(router,options){
        const app = new Light.Vue({
            el : options.el|| "#main",
            router
        });
    },
    navigateBack(number){
        number = number > window.history.length - 1 ? window.history.length - 1 : number;
        window.history.go(-number);
    },
    navigateTo(path,params,options){
        if(!/^https?:\/\//i.test(path.url)){
            return alert("跳转路径在当前环境下不被支持，请下载Lightview！");
        }
        //166093【框架】优化light.navigate路由跳转时无入参的路由
        if(options.history!==false){
            location.href= resolvePath(path.url, params);
        }else{
            location.replace(resolvePath(path.url, params));
        }
        if(options.title){
            document.title = "";
            document.title = options.title;
        }
    },
    getCurrentFile(){
        return location.href.split(/([#])/)[0];
    },
    ajax
};
