From 89c448571e013fc06c0c27a4d94055f9a984eae5 Mon Sep 17 00:00:00 2001 From: Pan Date: Fri, 29 Dec 2017 15:57:36 +0800 Subject: [PATCH] perf[i18n]: refine code comments --- src/errorLog.js | 4 ++++ src/icons/svg/trendChart1.svg | 1 - src/icons/svg/trendChart2.svg | 1 - src/icons/svg/trendChart3.svg | 1 - src/lang/en.js | 11 ++++++----- src/lang/zh.js | 3 ++- src/main.js | 6 +++--- src/permission.js | 18 +++++++++--------- src/utils/request.js | 10 +++++----- src/views/clipboard/index.vue | 4 ++-- src/views/components-demo/dropzone.vue | 2 +- src/views/components-demo/splitpane.vue | 2 +- src/views/components-demo/tinymce.vue | 2 +- src/views/errorLog/index.vue | 2 +- src/views/excel/exportExcel.vue | 2 +- src/views/excel/selectExcel.vue | 2 +- src/views/layout/components/AppMain.vue | 1 - src/views/layout/components/Navbar.vue | 2 +- src/views/login/index.vue | 19 ++++++++----------- src/views/theme/index.vue | 1 + src/views/zip/index.vue | 2 +- 21 files changed, 48 insertions(+), 48 deletions(-) delete mode 100644 src/icons/svg/trendChart1.svg delete mode 100644 src/icons/svg/trendChart2.svg delete mode 100644 src/icons/svg/trendChart3.svg diff --git a/src/errorLog.js b/src/errorLog.js index f5aa6644..7f7e492e 100644 --- a/src/errorLog.js +++ b/src/errorLog.js @@ -3,7 +3,10 @@ import store from './store' // you can set only in production env show the error-log // if (process.env.NODE_ENV === 'production') { + Vue.config.errorHandler = function(err, vm, info, a) { + // Don't ask me why I use Vue.nextTick, it just a hack. + // detail see https://forum.vuejs.org/t/dispatch-in-vue-config-errorhandler-has-some-problem/23500 Vue.nextTick(() => { store.dispatch('addErrorLog', { err, @@ -14,4 +17,5 @@ Vue.config.errorHandler = function(err, vm, info, a) { console.error(err, info) }) } + // } diff --git a/src/icons/svg/trendChart1.svg b/src/icons/svg/trendChart1.svg deleted file mode 100644 index 6297fe8a..00000000 --- a/src/icons/svg/trendChart1.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/icons/svg/trendChart2.svg b/src/icons/svg/trendChart2.svg deleted file mode 100644 index 0c08ff08..00000000 --- a/src/icons/svg/trendChart2.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/icons/svg/trendChart3.svg b/src/icons/svg/trendChart3.svg deleted file mode 100644 index 17124d90..00000000 --- a/src/icons/svg/trendChart3.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/lang/en.js b/src/lang/en.js index d2c767e6..b243b0a5 100644 --- a/src/lang/en.js +++ b/src/lang/en.js @@ -71,18 +71,18 @@ export default { }, components: { documentation: 'Documentation', - tinymceTips: 'Rich text editor is a core part of management system, but at the same time is a place with lots of problems. In the process of selecting rich texts, I also walked a lot of detours. The common rich text editors in the market are basically used, and the final trade-off is the selection of Tinymce.See documentation for more detailed rich text editor comparisons and introductions', - dropzoneTips: 'Because my business has special needs, and has to upload to qiniu, So instead of a third party, I chose encapsulate it by myself. It is very simple, you can see the specific code in @/components/Dropzone.', + tinymceTips: 'Rich text editor is a core part of management system, but at the same time is a place with lots of problems. In the process of selecting rich texts, I also walked a lot of detours. The common rich text editors in the market are basically used, and the finally chose Tinymce. See documentation for more detailed rich text editor comparisons and introductions.', + dropzoneTips: 'Because my business has special needs, and has to upload images to qiniu, so instead of a third party, I chose encapsulate it by myself. It is very simple, you can see the detail code in @/components/Dropzone.', stickyTips: 'when the page is scrolled to the preset position will be sticky on the top.', backToTopTips1: 'When the page is scrolled to the specified position, the Back to Top button appears in the lower right corner', backToTopTips2: 'You can customize the style of the button, show / hide, height of appearance, height of the return. If you need a text prompt, you can use element-ui el-tooltip elements externally', - imageUploadTips: 'Since I was using only the vue@1 version, and it is not compatible with mockjs at the moment, I modified it myself,and if you are going to use it, it is better to use official version.' + imageUploadTips: 'Since I was using only the vue@1 version, and it is not compatible with mockjs at the moment, I modified it myself, and if you are going to use it, it is better to use official version.' }, table: { dynamicTips1: 'Fixed header, sorted by header order', dynamicTips2: 'Not fixed header, sorted by click order', dragTips1: 'The default order', - dragTips2: 'The Drag after order', + dragTips2: 'The after dragging order', title: 'Title', importance: 'Imp', type: 'Type', @@ -120,6 +120,7 @@ export default { }, theme: { change: 'Theme change', - documentation: 'Theme documentation' + documentation: 'Theme documentation', + tips: 'Tips: It is different from the theme-pick on the navbar is two different skinning methods, each with different application scenarios. Refer to the documentation for details.' } } diff --git a/src/lang/zh.js b/src/lang/zh.js index 25f86773..4dd83533 100644 --- a/src/lang/zh.js +++ b/src/lang/zh.js @@ -120,6 +120,7 @@ export default { }, theme: { change: '换肤', - documentation: '换肤文档' + documentation: '换肤文档', + tips: 'Tips: 它区别于 navbar 上的 theme-pick, 是两种不同的换肤方法,各自有不同的应用场景,具体请参考文档。' } } diff --git a/src/main.js b/src/main.js index 30140400..07cbbe6e 100644 --- a/src/main.js +++ b/src/main.js @@ -15,12 +15,12 @@ import i18n from './lang' // Internationalization import './icons' // icon import './errorLog'// error log import './permission' // permission control -import './mock' // simulation data generator +import './mock' // simulation data -import * as filters from './filters' // global filter +import * as filters from './filters' // global filters Vue.use(Element, { - size: 'medium', + size: 'medium', // set element-ui default size i18n: (key, value) => i18n.t(key, value) }) diff --git a/src/permission.js b/src/permission.js index e470ffb7..e3400588 100644 --- a/src/permission.js +++ b/src/permission.js @@ -1,21 +1,21 @@ import router from './router' import store from './store' -import NProgress from 'nprogress' // Progress 进度条 -import 'nprogress/nprogress.css'// Progress 进度条样式 -import { getToken } from '@/utils/auth' // 验权 +import NProgress from 'nprogress' // progress bar +import 'nprogress/nprogress.css'// progress bar style +import { getToken } from '@/utils/auth' // getToken from cookie import { Message } from 'element-ui' // permissiom judge function hasPermission(roles, permissionRoles) { - if (roles.indexOf('admin') >= 0) return true // admin权限 直接通过 + if (roles.indexOf('admin') >= 0) return true // admin permission passed directly if (!permissionRoles) return true return roles.some(role => permissionRoles.indexOf(role) >= 0) } -const whiteList = ['/login', '/authredirect']// 不重定向白名单 +const whiteList = ['/login', '/authredirect']// no redirect whitelist router.beforeEach((to, from, next) => { - NProgress.start() // 开启Progress + NProgress.start() // start progress bar if (getToken()) { // 判断是否有token if (to.path === '/login') { next({ path: '/' }) @@ -26,11 +26,11 @@ router.beforeEach((to, from, next) => { const roles = res.data.role store.dispatch('GenerateRoutes', { roles }).then(() => { // 生成可访问的路由表 router.addRoutes(store.getters.addRouters) // 动态添加可访问路由表 - next({ ...to, replace: true }) // hack方法 确保addRoutes已完成 ,replace: true so the navigation will not leave a history record + next({ ...to, replace: true }) // hack方法 确保addRoutes已完成 ,set the replace: true so the navigation will not leave a history record }) }).catch(() => { store.dispatch('FedLogOut').then(() => { - Message.error('验证失败,请重新登录') + Message.error('Verification failed, please login again') next({ path: '/login' }) }) }) @@ -56,5 +56,5 @@ router.beforeEach((to, from, next) => { }) router.afterEach(() => { - NProgress.done() // 结束Progress + NProgress.done() // finish progress bar }) diff --git a/src/utils/request.js b/src/utils/request.js index ee007f1f..eb70b363 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -3,17 +3,17 @@ import { Message } from 'element-ui' import store from '@/store' import { getToken } from '@/utils/auth' -// 创建axios实例 +// create an axios instance const service = axios.create({ baseURL: process.env.BASE_API, // api的base_url - timeout: 5000 // 请求超时时间 + timeout: 5000 // request timeout }) -// request拦截器 +// request interceptor service.interceptors.request.use(config => { // Do something before request is sent if (store.getters.token) { - config.headers['X-Token'] = getToken() // 让每个请求携带token--['X-Token']为自定义key 请根据实际情况自行修改 + config.headers['X-Token'] = getToken() // 让每个请求携带token-- ['X-Token']为自定义key 请根据实际情况自行修改 } return config }, error => { @@ -22,7 +22,7 @@ service.interceptors.request.use(config => { Promise.reject(error) }) -// respone拦截器 +// respone interceptor service.interceptors.response.use( response => response, /** diff --git a/src/views/clipboard/index.vue b/src/views/clipboard/index.vue index dfc4a98c..83945235 100644 --- a/src/views/clipboard/index.vue +++ b/src/views/clipboard/index.vue @@ -2,11 +2,11 @@
- + copy - + copy diff --git a/src/views/components-demo/dropzone.vue b/src/views/components-demo/dropzone.vue index 135cd4fb..a31a702b 100644 --- a/src/views/components-demo/dropzone.vue +++ b/src/views/components-demo/dropzone.vue @@ -1,7 +1,7 @@