Skip to content

Commit cb54e27

Browse files
committed
refactor:结构优化
1 parent e3da39c commit cb54e27

File tree

2 files changed

+123
-115
lines changed

2 files changed

+123
-115
lines changed

src/main.js

Lines changed: 38 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
11
/*
22
* @Author: nigel
33
* @Date: 2020-05-12 14:33:04
4-
* @LastEditTime: 2020-05-20 13:50:44
4+
* @LastEditTime: 2020-12-22 10:15:26
55
*/
66
/* eslint-disable */
7-
import babelpolyfill from 'babel-polyfill';
8-
import Vue from 'vue';
9-
import VueI18n from 'vue-i18n';
10-
import App from './App';
11-
import ElementUI from 'element-ui';
12-
import enLocale from 'element-ui/lib/locale/lang/en';
13-
import jaLocale from 'element-ui/lib/locale/lang/ja';
14-
import zhLocale from 'element-ui/lib/locale/lang/zh-CN';
7+
import babelpolyfill from "babel-polyfill";
8+
import Vue from "vue";
9+
import VueI18n from "vue-i18n";
10+
import App from "./App";
11+
import ElementUI from "element-ui";
12+
import enLocale from "element-ui/lib/locale/lang/en";
13+
import jaLocale from "element-ui/lib/locale/lang/ja";
14+
import zhLocale from "element-ui/lib/locale/lang/zh-CN";
1515
import Exif from "exif-js";
1616

1717
// import 'element-ui/lib/theme-default/index.css'
18-
import 'element-ui/lib/theme-chalk/index.css';
18+
import "element-ui/lib/theme-chalk/index.css";
1919
// import './assets/theme/theme-green/index.css'
20-
import VueRouter from 'vue-router';
21-
import store from './vuex/store';
22-
import Vuex from 'vuex';
23-
import NProgress from 'nprogress';
24-
import 'nprogress/nprogress.css';
25-
import routes from './routes';
26-
import './styles/main.scss';
27-
import 'font-awesome/css/font-awesome.min.css';
20+
import VueRouter from "vue-router";
21+
import store from "./vuex/store";
22+
import Vuex from "vuex";
23+
import NProgress from "nprogress";
24+
import "nprogress/nprogress.css";
25+
import routes from "./routes";
26+
import "./styles/main.scss";
27+
import "font-awesome/css/font-awesome.min.css";
2828

2929
// 启动模拟接口
3030
// import Mock from './mock/index.js'
3131
// Mock.bootstrap();
32-
import utils from './common/js/util.js';
32+
import utils from "./common/js/util.js";
3333
window.storeLocal = utils.storeLocal;
3434
window.storeSession = utils.storeSession;
3535
window.Exif = Exif;
@@ -42,36 +42,41 @@ Vue.use(Vuex);
4242
NProgress.configure({ showSpinner: false });
4343
const router = new VueRouter({
4444
// mode: 'history',
45-
routes
45+
routes,
4646
});
4747

4848
const i18n = new VueI18n({
49-
locale: 'zh-CH', // set locale
49+
locale: "zh-CH", // set locale
5050
messages: {},
5151
// silentFallbackWarn: true,
5252
// silentTranslationWarn: true
5353
});
5454

55-
5655
router.beforeEach((to, from, next) => {
5756
NProgress.start();
5857
/*需要判断登录*/
59-
let token = storeSession.get('token');
60-
if (!token && to.name !== 'login') {
58+
let token = storeSession.get("token");
59+
if (!token && to.name !== "login") {
6160
next({
62-
path: '/login',
63-
query: { redirect: to.fullPath }
61+
path: "/login",
62+
query: { redirect: to.fullPath },
6463
});
6564
} else {
6665
let locale = store.state.menuStore.locals;
6766
i18n.locale = locale;
6867
switch (locale) {
69-
case 'zh-CH': Vue.use(ElementUI, zhLocale); break;
70-
case 'en': Vue.use(ElementUI, enLocale); break;
71-
case 'ja': Vue.use(ElementUI, jaLocale); break;
68+
case "zh-CH":
69+
Vue.use(ElementUI, zhLocale);
70+
break;
71+
case "en":
72+
Vue.use(ElementUI, enLocale);
73+
break;
74+
case "ja":
75+
Vue.use(ElementUI, jaLocale);
76+
break;
7277
}
73-
if (to.path == '/login') {
74-
sessionStorage.removeItem('user');
78+
if (to.path == "/login") {
79+
sessionStorage.removeItem("user");
7580
}
7681
next();
7782
}
@@ -96,7 +101,7 @@ const rootVue = new Vue({
96101
router,
97102
store,
98103
i18n,
99-
render: h => h(App)
100-
}).$mount('#app');
104+
render: (h) => h(App),
105+
}).$mount("#app");
101106

102107
export default rootVue;

src/routes.js

Lines changed: 85 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,102 +1,105 @@
11
/*
22
* @Author: nigel
33
* @Date: 2020-03-19 17:42:35
4-
* @LastEditTime: 2020-07-20 16:13:39
4+
* @LastEditTime: 2020-12-22 10:15:16
55
*/
6-
import Login from './views/login/login.vue';
7-
import NotFound from './views/404.vue';
8-
import Home from './views/Home.vue';
9-
import eslUpdate from './views/eslUpdate/eslUpdate.vue';
10-
import ocr from './views/ocr/ocr.vue';
11-
import postCodeOcr from './views/postCodeOcr/postCodeOcr.vue';
12-
import dectectApi from './views/dectectApi/dectectApi.vue';
13-
import drawImg from './views/drawImg/drawImg.vue';
14-
import generalocr from './views/generalocr/generalocr.vue';
15-
import googleOcr from './views/googleOcr/googleOcr.vue';
16-
import customizeOcr from './views/customizeOcr/customizeOcr.vue';
17-
import myOcrTemplate from './views/myOcrTemplate/myOcrTemplate.vue';
6+
import Login from "./views/login/login.vue";
7+
import NotFound from "./views/404.vue";
8+
import Home from "./views/Home.vue";
9+
import eslUpdate from "./views/eslUpdate/eslUpdate.vue";
10+
import ocr from "./views/ocr/ocr.vue";
11+
import postCodeOcr from "./views/postCodeOcr/postCodeOcr.vue";
12+
import dectectApi from "./views/dectectApi/dectectApi.vue";
13+
import drawImg from "./views/drawImg/drawImg.vue";
14+
import generalocr from "./views/generalocr/generalocr.vue";
15+
import googleOcr from "./views/googleOcr/googleOcr.vue";
16+
import customizeOcr from "./views/customizeOcr/customizeOcr.vue";
17+
import myOcrTemplate from "./views/myOcrTemplate/myOcrTemplate.vue";
1818
// import gesture from './views/gesture/gesture.vue';
19-
let routes = [{
20-
path: '/login',
19+
let routes = [
20+
{
21+
path: "/login",
2122
component: Login,
22-
name: 'login',
23-
},
24-
{
25-
path: '/404',
23+
name: "login",
24+
},
25+
{
26+
path: "/404",
2627
component: NotFound,
27-
name: '',
28-
},
29-
{
30-
path: '/',
28+
name: "",
29+
},
30+
{
31+
path: "/",
3132
component: Home,
32-
name: 'Home',
33-
children: [{
34-
path: '/eslUpdate',
33+
name: "Home",
34+
children: [
35+
{
36+
path: "/eslUpdate",
3537
component: eslUpdate,
36-
name: 'eslUpdate',
37-
alias: 'esl更新'
38-
},
39-
{
40-
path: '/ocr',
38+
name: "eslUpdate",
39+
alias: "esl更新",
40+
},
41+
{
42+
path: "/ocr",
4143
component: ocr,
42-
name: 'ocr',
43-
alias: '运单识别'
44-
},
45-
{
46-
path: '/dectectApi',
44+
name: "ocr",
45+
alias: "运单识别",
46+
},
47+
{
48+
path: "/dectectApi",
4749
component: dectectApi,
48-
name: 'dectectApi',
49-
alias: '智能识别API'
50-
},
51-
{
52-
path: '/postCodeOcr',
50+
name: "dectectApi",
51+
alias: "智能识别API",
52+
},
53+
{
54+
path: "/postCodeOcr",
5355
component: postCodeOcr,
54-
name: 'postCodeOcr',
55-
alias: '邮编识别'
56-
},
57-
{
58-
path: '/drawImg',
56+
name: "postCodeOcr",
57+
alias: "邮编识别",
58+
},
59+
{
60+
path: "/drawImg",
5961
component: drawImg,
60-
name: 'drawImg',
61-
alias: '指定区域の画像認識'
62-
},
63-
{
64-
path: '/customizeOcr',
62+
name: "drawImg",
63+
alias: "指定区域の画像認識",
64+
},
65+
{
66+
path: "/customizeOcr",
6567
component: customizeOcr,
66-
name: 'customizeOcr',
67-
alias: '自定区域OCR'
68-
},
69-
{
70-
path: '/generalocr',
68+
name: "customizeOcr",
69+
alias: "自定区域OCR",
70+
},
71+
{
72+
path: "/generalocr",
7173
component: generalocr,
72-
name: 'generalocr',
73-
alias: '通用印刷体文字识别'
74-
},
75-
// {
76-
// path: '/gesture',
77-
// component: gesture,
78-
// name: 'gesture',
79-
// alias: '手势识别'
80-
// },
81-
{
82-
path: '/googleOcr',
74+
name: "generalocr",
75+
alias: "通用印刷体文字识别",
76+
},
77+
// {
78+
// path: '/gesture',
79+
// component: gesture,
80+
// name: 'gesture',
81+
// alias: '手势识别'
82+
// },
83+
{
84+
path: "/googleOcr",
8385
component: googleOcr,
84-
name: 'googleOcr',
85-
alias: '谷歌通用文字识别'
86-
}, {
87-
path: '/myOcrTemplate',
86+
name: "googleOcr",
87+
alias: "谷歌通用文字识别",
88+
},
89+
{
90+
path: "/myOcrTemplate",
8891
component: myOcrTemplate,
89-
name: 'myOcrTemplate',
90-
alias: '我的模板'
91-
}
92-
]
93-
},
94-
{
95-
path: '*',
92+
name: "myOcrTemplate",
93+
alias: "我的模板",
94+
},
95+
],
96+
},
97+
{
98+
path: "*",
9699
redirect: {
97-
path: '/404'
98-
}
99-
}
100+
path: "/404",
101+
},
102+
},
100103
];
101104

102-
export default routes;
105+
export default routes;

0 commit comments

Comments
 (0)