first commit

This commit is contained in:
编码猿
2024-09-27 01:32:49 +08:00
commit 28ebe05a64
7399 changed files with 1174529 additions and 0 deletions

View File

@@ -0,0 +1 @@
32b784bd-1a75-43f8-9b0b-565c56d600fc

View File

@@ -0,0 +1,60 @@
import Vue, {VueConstructor} from 'vue';
import App from '@/App.vue';
import VueRouter from 'vue-router';
import '../class-component-hooks';
import {config} from '../config'
/**
* 初始化Vue需要的插件和构造Vue启动参数
*/
export class init {
private initVuePlugsArray: Array<any> = config.VuePlugs;
private initOtherPlugsArray: Array<Object> = config.NotVuePlugs;
protected router: any;
protected Vues: any = Vue;
public static App: VueConstructor = App;
constructor() {
this.Vues.config.productionTip = false;
this.initPlugs();
}
/**
* 初始化Vue和非Vue插件
*/
private initPlugs(): void {
// @ts-ignore
this.initOtherPlugsArray.forEach(v => this.Vues.prototype[v['n']] = new (v['f'])());
this.initVuePlugsArray.forEach(v => this.Vues.use(v));
this.InitVueRouter();
}
/**
* 初始化配置全局路由
* @constructor
*/
private InitVueRouter(): void {
this.router = new VueRouter(config.RouterConfigUrl);
// 重写路由Push
const routerPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location: any): any {
// @ts-ignore
return routerPush.call(this, location).catch((error: any) => error)
}
this.router.beforeEach((to: any, from: any, next: any) => {
if (to.meta.title) {
document.title = to.meta.title;
}
// 如果用户未登录跳转至登录页
if(!localStorage.getItem(`${config.prefix}access_token`) && config.isRouter.indexOf(to.path) !== -1){
next('/login')
}else{
next();
}
// next();
});
}
}

View File

@@ -0,0 +1,20 @@
import {init} from './init';
import {config} from '../config';
import store from '../store/index'
/**
* Vue项目的启动文件
*/
class Run extends init {
public initApp(): void {
const router = this.router;
new this.Vues({
router,
store,
render: (h: (arg0: any) => void): any => h(init.App)
}).$mount(config.mountElement);
}
}
(new Run()).initApp();