From 339d760771ec679cf92560b170e560b6f2db6d96 Mon Sep 17 00:00:00 2001 From: Pan <panfree23@gmail.com> Date: Fri, 17 Nov 2017 14:57:39 +0800 Subject: [PATCH] refactor:format code --- src/App.vue | 4 +- src/filters/index.js | 1 + src/icons/svg/documentation.svg | 1 + src/lang/en.js | 1 + src/lang/index.js | 8 ++-- src/lang/zh.js | 1 + src/mock/index.js | 1 + src/router/index.js | 33 ++++++++-------- src/styles/index.scss | 2 +- .../dashboard/admin/components/BarChart.vue | 2 +- .../dashboard/admin/components/BoxCard.vue | 2 +- src/views/dashboard/admin/index.vue | 8 ++-- src/views/documentation/index.vue | 39 +++++++++++++++++++ src/views/introduction/index.vue | 26 ------------- src/views/permission/index.vue | 3 +- src/views/svg-icons/index.vue | 1 + src/views/theme/index.vue | 2 +- 17 files changed, 77 insertions(+), 58 deletions(-) create mode 100644 src/icons/svg/documentation.svg create mode 100644 src/views/documentation/index.vue delete mode 100644 src/views/introduction/index.vue diff --git a/src/App.vue b/src/App.vue index 440937a9..1bfd3d5f 100644 --- a/src/App.vue +++ b/src/App.vue @@ -11,6 +11,6 @@ </script> <style lang="scss"> -@import '~normalize.css/normalize.css';// normalize.css æ ·å¼æ ¼å¼åŒ– -@import './styles/index.scss'; // 全局自定义的cssæ ·å¼ +@import '~normalize.css/normalize.css'; // normalize.css æ ·å¼æ ¼å¼åŒ– +@import './styles/index.scss'; // å…¨å±€è‡ªå®šä¹‰æ ·å¼ </style> diff --git a/src/filters/index.js b/src/filters/index.js index 224b7d2c..285a314b 100644 --- a/src/filters/index.js +++ b/src/filters/index.js @@ -4,6 +4,7 @@ function pluralize(time, label) { } return time + label + 's' } + export function timeAgo(time) { const between = Date.now() / 1000 - Number(time) if (between < 3600) { diff --git a/src/icons/svg/documentation.svg b/src/icons/svg/documentation.svg new file mode 100644 index 00000000..caf68ddb --- /dev/null +++ b/src/icons/svg/documentation.svg @@ -0,0 +1 @@ +<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1510826638494" class="icon" style="" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1669" xmlns:xlink="http://www.w3.org/1999/xlink" width="64" height="64"><defs><style type="text/css"></style></defs><path d="M743.253333 144.184889H374.499556v734.378667H743.253333a92.017778 92.017778 0 0 0 92.16-91.818667V235.975111a91.989333 91.989333 0 0 0-92.16-91.790222z m-0.398222 293.888c0.398222 20.48-1.507556 26.794667-9.756444 26.794667-3.612444 0.597333-9.415111-1.621333-17.863111-8.874667-12.657778-8.931556-21.504-16.753778-29.155556-21.617778-6.798222-5.888-17.550222-5.205333-24.291556 0-8.874667 4.949333-21.532444 15.872-28.814222 21.617778-8.988444 7.907556-15.018667 8.874667-17.180444 8.874667-8.618667 0-10.837333-7.424-10.496-26.794667l-0.312889-223.601778c0-21.162667 8.561778-24.376889 17.265778-24.376889h103.708444c10.552889 0 17.294222 4.835556 17.294222 24.376889l-0.398222 223.601778zM190.122667 235.975111V786.773333a92.046222 92.046222 0 0 0 92.188444 91.818667h46.08V144.184889h-46.08a92.017778 92.017778 0 0 0-92.188444 91.790222z" fill="" p-id="1670"></path></svg> diff --git a/src/lang/en.js b/src/lang/en.js index 7d5386a7..7b1e6094 100644 --- a/src/lang/en.js +++ b/src/lang/en.js @@ -2,6 +2,7 @@ export default { route: { dashboard: 'Dashboard', introduction: 'Introduction', + documentation: 'Documentation', permission: 'Permission', icons: 'Icons', components: 'Components', diff --git a/src/lang/index.js b/src/lang/index.js index 2c55ddc3..12b9cacb 100644 --- a/src/lang/index.js +++ b/src/lang/index.js @@ -1,10 +1,10 @@ import Vue from 'vue' -import elementEnLocale from 'element-ui/lib/locale/lang/en' -import elementZhLocale from 'element-ui/lib/locale/lang/zh-CN' -import enLocale from './en' -import zhLocale from './zh' import VueI18n from 'vue-i18n' import Cookies from 'js-cookie' +import elementEnLocale from 'element-ui/lib/locale/lang/en' // element-ui lang +import elementZhLocale from 'element-ui/lib/locale/lang/zh-CN'// element-ui lang +import enLocale from './en' +import zhLocale from './zh' Vue.use(VueI18n) diff --git a/src/lang/zh.js b/src/lang/zh.js index 37e5d65d..070d673f 100644 --- a/src/lang/zh.js +++ b/src/lang/zh.js @@ -2,6 +2,7 @@ export default { route: { dashboard: '首页', introduction: '简述', + documentation: '文档', permission: 'æƒé™æµ‹è¯•é¡µ', icons: 'å›¾æ ‡', components: '组件', diff --git a/src/mock/index.js b/src/mock/index.js index 951c80d5..c2fbb7f0 100644 --- a/src/mock/index.js +++ b/src/mock/index.js @@ -23,4 +23,5 @@ Mock.mock(/\/search\/user/, 'get', remoteSearchAPI.searchUser) // è´¦å•ç›¸å…³ Mock.mock(/\/transaction\/list/, 'get', transactionAPI.getList) + export default Mock diff --git a/src/router/index.js b/src/router/index.js index 52011bd6..926eea46 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -1,30 +1,30 @@ import Vue from 'vue' import Router from 'vue-router' const _import = require('./_import_' + process.env.NODE_ENV) -// in development env not use Lazy Loading,because Lazy Loading too many pages will cause webpack hot update too slow.so only in production use Lazy Loading +// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading; +// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading Vue.use(Router) -/* layout */ +/* Layout */ import Layout from '../views/layout/Layout' /** -* hidden: true if `hidden:true` will not show in the sidebar(default is false) -* redirect: noredirect if `redirect:noredirect` will no redirct in the levelbar +* hidden: true if `hidden:true` will not show in the sidebar(default is false) +* redirect: noredirect if `redirect:noredirect` will no redirct in the breadcrumb +* name:'router-name' the name is used by <keep-alive> (must set!!!) * meta : { - role: ['admin'] will control the page role - title: 'title' the name show in submenu and levelbar - icon: 'svg-name' the icon show in the sidebar, - noCache: true if fasle ,the page will no be cached(default is false) + role: ['admin','editor'] will control the page role (you can set multiple roles) + title: 'title' the name show in submenu and breadcrumb (recommend set) + icon: 'svg-name' the icon show in the sidebar, + noCache: true if fasle ,the page will no be cached(default is false) } **/ - export const constantRouterMap = [ { path: '/login', component: _import('login/index'), hidden: true }, { path: '/authredirect', component: _import('login/authredirect'), hidden: true }, { path: '/404', component: _import('errorPage/404'), hidden: true }, { path: '/401', component: _import('errorPage/401'), hidden: true }, - { path: '', component: Layout, @@ -36,16 +36,15 @@ export const constantRouterMap = [ meta: { title: 'dashboard', icon: 'dashboard' } }] }, - { - path: '/introduction', + path: '/documentation', component: Layout, - redirect: '/introduction/index', + redirect: '/documentation/index', children: [{ path: 'index', - component: _import('introduction/index'), - name: 'introduction', - meta: { title: 'introduction', icon: 'people' } + component: _import('documentation/index'), + name: 'documentation', + meta: { title: 'documentation', icon: 'documentation', noCache: true } }] } ] @@ -81,7 +80,7 @@ export const asyncRouterMap = [ path: 'index', component: _import('svg-icons/index'), name: 'icons', - meta: { title: 'icons', icon: 'icon' } + meta: { title: 'icons', icon: 'icon', noCache: true } }] }, diff --git a/src/styles/index.scss b/src/styles/index.scss index 4c9fa845..01b167b6 100644 --- a/src/styles/index.scss +++ b/src/styles/index.scss @@ -1,8 +1,8 @@ @import './mixin.scss'; @import './transition.scss'; -@import './btn.scss'; @import './element-ui.scss'; @import './sidebar.scss'; +@import './btn.scss'; body { height: 100%; diff --git a/src/views/dashboard/admin/components/BarChart.vue b/src/views/dashboard/admin/components/BarChart.vue index 34f32c88..5719aebf 100644 --- a/src/views/dashboard/admin/components/BarChart.vue +++ b/src/views/dashboard/admin/components/BarChart.vue @@ -7,7 +7,7 @@ import echarts from 'echarts' require('echarts/theme/macarons') // echarts 主题 import { debounce } from '@/utils' -const animationDuration = 3000 +const animationDuration = 6000 export default { props: { className: { diff --git a/src/views/dashboard/admin/components/BoxCard.vue b/src/views/dashboard/admin/components/BoxCard.vue index 3e92e9e8..6b8f37c7 100644 --- a/src/views/dashboard/admin/components/BoxCard.vue +++ b/src/views/dashboard/admin/components/BoxCard.vue @@ -93,7 +93,7 @@ export default { z-index: 100; height: 70px!important; width: 70px!important; - position: absolute; + position: absolute!important; top: -45px; left: 0px; border: 5px solid #ffffff; diff --git a/src/views/dashboard/admin/index.vue b/src/views/dashboard/admin/index.vue index ac146d7a..65285418 100644 --- a/src/views/dashboard/admin/index.vue +++ b/src/views/dashboard/admin/index.vue @@ -21,7 +21,7 @@ </div> <div class='card-panel-description'> <div class='card-panel-text'>Messages</div> - <count-to class="card-panel-num" :startVal='0' :endVal='81212' :duration='3600'></count-to> + <count-to class="card-panel-num" :startVal='0' :endVal='81212' :duration='4000'></count-to> </div> </div> </el-col> @@ -32,7 +32,7 @@ </div> <div class='card-panel-description'> <div class='card-panel-text'>Purchases</div> - <count-to class="card-panel-num" :startVal='0' :endVal='9280' :duration='3600'></count-to> + <count-to class="card-panel-num" :startVal='0' :endVal='9280' :duration='4000'></count-to> </div> </div> </el-col> @@ -43,7 +43,7 @@ </div> <div class='card-panel-description'> <div class='card-panel-text'>Shoppings</div> - <count-to class="card-panel-num" :startVal='0' :endVal='1299' :duration='3600'></count-to> + <count-to class="card-panel-num" :startVal='0' :endVal='13600' :duration='4600'></count-to> </div> </div> </el-col> @@ -104,7 +104,7 @@ const lineChartData = { }, messages: { expectedData: [200, 192, 120, 144, 160, 130, 140], - actualData: [180, 160, 101, 106, 145, 150, 130] + actualData: [180, 160, 151, 106, 145, 150, 130] }, purchases: { expectedData: [80, 100, 121, 104, 105, 90, 100], diff --git a/src/views/documentation/index.vue b/src/views/documentation/index.vue new file mode 100644 index 00000000..25aa2e9d --- /dev/null +++ b/src/views/documentation/index.vue @@ -0,0 +1,39 @@ +<template> + <div class="app-container"> + <div class="wrapper"> + <code> + <ul> + <li> + <a target='_blank' href="https://github.com/PanJiaChen/vue-element-admin/">项目地å€</a> + </li> + <li> + <a target='_blank' href="https://panjiachen.github.io/vue-element-admin-site/#/">详细文档</a> + </li> + <li> + <a target='_blank' href="https://juejin.im/post/59097cd7a22b9d0065fb61d2">æ‰‹æ‘¸æ‰‹ï¼Œå¸¦ä½ ç”¨ vue æ’¸åŽå° 系列一(基础篇)</a> + </li> + <li> + <a target='_blank' href="https://juejin.im/post/591aa14f570c35006961acac">æ‰‹æ‘¸æ‰‹ï¼Œå¸¦ä½ ç”¨ vue æ’¸åŽå° 系列二(登录æƒé™ç¯‡)</a> + </li> + <li> + <a target='_blank' href="https://juejin.im/post/593121aa0ce4630057f70d35">æ‰‹æ‘¸æ‰‹ï¼Œå¸¦ä½ ç”¨ vue æ’¸åŽå° 系列三 (实战篇)</a> + </li> + <li> + <a target='_blank' href="https://juejin.im/post/595b4d776fb9a06bbe7dba56">æ‰‹æ‘¸æ‰‹ï¼Œå¸¦ä½ ç”¨vueæ’¸åŽå° 系列四(vueAdmin 一个æžç®€çš„åŽå°åŸºç¡€æ¨¡æ¿)</a> + </li> + <li> + <a target='_blank' href="https://segmentfault.com/a/1190000009090836">æ‰‹æ‘¸æ‰‹ï¼Œå¸¦ä½ å°è£…一个vue component</a> + </li> + </ul> + </code> + </div> + </div> +</template> + + +<style scoped> + .wrapper{ + width: 800px; + margin: 30px auto; + } +</style> diff --git a/src/views/introduction/index.vue b/src/views/introduction/index.vue deleted file mode 100644 index 798bba3f..00000000 --- a/src/views/introduction/index.vue +++ /dev/null @@ -1,26 +0,0 @@ -<template> - <div class="app-container"> - <div class="wrapper"> - <code> - è¿™åŠå¹´æ¥ä¸€ç›´åœ¨ç”¨vue写管ç†åŽå°ï¼Œç›®å‰åŽå°å·²ç»æœ‰ç™¾æ¥ä¸ªä¸ªé¡µé¢ï¼Œåå‡ ç§æƒé™ï¼Œä½†ç»´æŠ¤æˆæœ¬ä¾ç„¶å¾ˆä½Žï¼Œæ‰€ä»¥å‡†å¤‡å¼€æºåˆ†äº«ä¸€ä¸‹åŽå°å¼€å‘çš„ç»éªŒå’Œæˆæžœã€‚ç›®å‰çš„æŠ€æœ¯æ ˆä¸»è¦çš„采用vue+element+axiosç”±webpack2打包.由于是个人项目,所以数æ®è¯·æ±‚都是用了mockjs模拟。注æ„ï¼šåœ¨æ¬¡é¡¹ç›®åŸºç¡€ä¸Šæ”¹é€ å¼€å‘时请移除mock文件。 - 写了一个系列的教程é…å¥—æ–‡ç« ï¼Œå¦‚ä½•ä»Žé›¶æž„å»ºåŽä¸€ä¸ªå®Œæ•´çš„åŽå°é¡¹ç›®: - <ul> - <li><a target='_blank' class='lin' href="https://github.com/PanJiaChen/vue-element-admin/">项目地å€</a></li> - <li><a target='_blank' class='lin' href="https://github.com/PanJiaChen/vue-element-admin/wiki">wiki</a></li> - <li><a target='_blank' href="https://juejin.im/post/59097cd7a22b9d0065fb61d2">æ‰‹æ‘¸æ‰‹ï¼Œå¸¦ä½ ç”¨ vue æ’¸åŽå° 系列一(基础篇)</a></li> - <li><a target='_blank' href="https://juejin.im/post/591aa14f570c35006961acac">æ‰‹æ‘¸æ‰‹ï¼Œå¸¦ä½ ç”¨ vue æ’¸åŽå° 系列二(登录æƒé™ç¯‡)</a></li> - <li><a target='_blank' href="https://juejin.im/post/593121aa0ce4630057f70d35">æ‰‹æ‘¸æ‰‹ï¼Œå¸¦ä½ ç”¨ vue æ’¸åŽå° 系列三 (实战篇)</a></li> - <li><a target='_blank' href="https://juejin.im/post/595b4d776fb9a06bbe7dba56">æ‰‹æ‘¸æ‰‹ï¼Œå¸¦ä½ ç”¨vueæ’¸åŽå° 系列四(vueAdmin 一个æžç®€çš„åŽå°åŸºç¡€æ¨¡æ¿)</a></li> - <li><a target='_blank' href="https://segmentfault.com/a/1190000009090836">æ‰‹æ‘¸æ‰‹ï¼Œå¸¦ä½ å°è£…一个vue component</a></li> - </ul> - </code> - </div> - </div> -</template> - -<style scoped> - .wrapper{ - width: 800px; - margin: 30px auto; - } -</style> diff --git a/src/views/permission/index.vue b/src/views/permission/index.vue index 5fdc28c9..df040deb 100644 --- a/src/views/permission/index.vue +++ b/src/views/permission/index.vue @@ -1,6 +1,6 @@ <template> <div class="app-container"> - <div style='margin-bottom:15px;'>ä½ çš„æƒé™ï¼š {{roles}}</div> + <div style="margin-bottom:15px;">ä½ çš„æƒé™ï¼š {{roles}}</div> 切æ¢æƒé™ï¼š <el-radio-group v-model="role"> <el-radio-button label="editor"></el-radio-button> @@ -12,6 +12,7 @@ import { mapGetters } from 'vuex' export default{ + name: 'permission', data() { return { role: '' diff --git a/src/views/svg-icons/index.vue b/src/views/svg-icons/index.vue index 634a55be..a3cdf892 100644 --- a/src/views/svg-icons/index.vue +++ b/src/views/svg-icons/index.vue @@ -22,6 +22,7 @@ import icons from './generateIconsView' import clipboard from '@/utils/clipboard' // use clipboard directly export default { + name: 'icons', data() { return { iconsMap: [] diff --git a/src/views/theme/index.vue b/src/views/theme/index.vue index afc6fa05..496c7783 100644 --- a/src/views/theme/index.vue +++ b/src/views/theme/index.vue @@ -3,7 +3,7 @@ <el-card class="box-card"> <div slot="header"> <span style="line-height: 36px;">å好设置</span> - <a class='link-type link-title' target="_blank" href='https://segmentfault.com/a/1190000009762198#articleHeader2'>动æ€æ¢è‚¤çš„教程</a> + <a class='link-type link-title' target="_blank" href='https://panjiachen.github.io/vue-element-admin-site/#/theme'>æ¢è‚¤æ–‡æ¡£</a> </div> <div class="box-item"> <span class="field-label">æ¢è‚¤:</span> -- GitLab