diff --git a/package.json b/package.json index 6e71de6f..fb440def 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vue-element-admin", - "version": "3.8.1", + "version": "3.9.0", "description": "A magical vue admin. Typical templates for enterprise applications. Newest development stack of vue. Lots of awesome features", "author": "Pan ", "license": "MIT", @@ -11,6 +11,7 @@ "lint": "eslint --ext .js,.vue src", "test": "npm run lint", "precommit": "lint-staged", + "svgo": "svgo -f src/icons/svg --config=src/icons/svgo.yml", "deploy": "bash deploy.sh" }, "lint-staged": { @@ -106,6 +107,7 @@ "serve-static": "1.13.2", "shelljs": "0.8.2", "svg-sprite-loader": "3.8.0", + "svgo": "1.0.5", "uglifyjs-webpack-plugin": "1.2.7", "url-loader": "1.0.1", "vue-loader": "15.3.0", diff --git a/src/components/SizeSelect/index.vue b/src/components/SizeSelect/index.vue index 3f73673e..0e428a23 100644 --- a/src/components/SizeSelect/index.vue +++ b/src/components/SizeSelect/index.vue @@ -32,10 +32,12 @@ export default { // In order to make the cached page re-rendered this.$store.dispatch('delAllCachedViews', this.$route) - const { path } = this.$route + const { fullPath } = this.$route - this.$router.replace({ - path: '/redirect' + path + this.$nextTick(() => { + this.$router.replace({ + path: '/redirect' + fullPath + }) }) } } diff --git a/src/components/Tinymce/index.vue b/src/components/Tinymce/index.vue index 37fd8dd2..7f4a0ae0 100644 --- a/src/components/Tinymce/index.vue +++ b/src/components/Tinymce/index.vue @@ -18,7 +18,9 @@ export default { props: { id: { type: String, - default: 'vue-tinymce-' + +new Date() + default: function() { + return 'vue-tinymce-' + +new Date() + ((Math.random() * 1000).toFixed(0) + '') + } }, value: { type: String, diff --git a/src/icons/svg/404.svg b/src/icons/svg/404.svg index bc5bc9fa..6df50190 100644 --- a/src/icons/svg/404.svg +++ b/src/icons/svg/404.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/icons/svg/bug.svg b/src/icons/svg/bug.svg index a12a9394..05a150dc 100644 --- a/src/icons/svg/bug.svg +++ b/src/icons/svg/bug.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/icons/svg/chart.svg b/src/icons/svg/chart.svg index b1b31336..27728fb0 100644 --- a/src/icons/svg/chart.svg +++ b/src/icons/svg/chart.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/icons/svg/clipboard.svg b/src/icons/svg/clipboard.svg index cf1c9b0c..90923ff6 100644 --- a/src/icons/svg/clipboard.svg +++ b/src/icons/svg/clipboard.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/icons/svg/component.svg b/src/icons/svg/component.svg index a8008c84..207ada34 100644 --- a/src/icons/svg/component.svg +++ b/src/icons/svg/component.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/icons/svg/dashboard.svg b/src/icons/svg/dashboard.svg index bee42507..5317d370 100644 --- a/src/icons/svg/dashboard.svg +++ b/src/icons/svg/dashboard.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/icons/svg/documentation.svg b/src/icons/svg/documentation.svg index 405c2ad7..70431228 100644 --- a/src/icons/svg/documentation.svg +++ b/src/icons/svg/documentation.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/icons/svg/drag.svg b/src/icons/svg/drag.svg index 819c8d50..4185d3ce 100644 --- a/src/icons/svg/drag.svg +++ b/src/icons/svg/drag.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/icons/svg/edit.svg b/src/icons/svg/edit.svg index 5c77d97a..0306a867 100644 --- a/src/icons/svg/edit.svg +++ b/src/icons/svg/edit.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/icons/svg/email.svg b/src/icons/svg/email.svg index 8a87e147..055e5013 100644 --- a/src/icons/svg/email.svg +++ b/src/icons/svg/email.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/icons/svg/example.svg b/src/icons/svg/example.svg index 681422ea..46f42b53 100644 --- a/src/icons/svg/example.svg +++ b/src/icons/svg/example.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/icons/svg/excel.svg b/src/icons/svg/excel.svg index e5dd5cec..59d54b2c 100644 --- a/src/icons/svg/excel.svg +++ b/src/icons/svg/excel.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/icons/svg/eye.svg b/src/icons/svg/eye.svg index 194aa45c..16ed2d87 100644 --- a/src/icons/svg/eye.svg +++ b/src/icons/svg/eye.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/icons/svg/form.svg b/src/icons/svg/form.svg index 79716f06..dcbaa185 100644 --- a/src/icons/svg/form.svg +++ b/src/icons/svg/form.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/icons/svg/guide 2.svg b/src/icons/svg/guide 2.svg new file mode 100644 index 00000000..d053bd73 --- /dev/null +++ b/src/icons/svg/guide 2.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/guide.svg b/src/icons/svg/guide.svg index 9bae3394..b2710017 100644 --- a/src/icons/svg/guide.svg +++ b/src/icons/svg/guide.svg @@ -1 +1 @@ - + \ No newline at end of file diff --git a/src/icons/svg/icon.svg b/src/icons/svg/icon.svg index 906af96a..82be8eee 100644 --- a/src/icons/svg/icon.svg +++ b/src/icons/svg/icon.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/icons/svg/international.svg b/src/icons/svg/international.svg index 6912767d..e9b56eee 100644 --- a/src/icons/svg/international.svg +++ b/src/icons/svg/international.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/icons/svg/language.svg b/src/icons/svg/language.svg index 2baf7431..96d00288 100644 --- a/src/icons/svg/language.svg +++ b/src/icons/svg/language.svg @@ -1 +1 @@ - + \ No newline at end of file diff --git a/src/icons/svg/link.svg b/src/icons/svg/link.svg index 11037e6f..07090147 100644 --- a/src/icons/svg/link.svg +++ b/src/icons/svg/link.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/icons/svg/list.svg b/src/icons/svg/list.svg index c45f4591..20259edd 100644 --- a/src/icons/svg/list.svg +++ b/src/icons/svg/list.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/icons/svg/lock.svg b/src/icons/svg/lock.svg index 37c60701..74fee543 100644 --- a/src/icons/svg/lock.svg +++ b/src/icons/svg/lock.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/icons/svg/message.svg b/src/icons/svg/message.svg index d807b002..14ca8172 100644 --- a/src/icons/svg/message.svg +++ b/src/icons/svg/message.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/icons/svg/money.svg b/src/icons/svg/money.svg index d4fcb9ca..c1580de1 100644 --- a/src/icons/svg/money.svg +++ b/src/icons/svg/money.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/icons/svg/nested.svg b/src/icons/svg/nested.svg index f5641979..06713a86 100644 --- a/src/icons/svg/nested.svg +++ b/src/icons/svg/nested.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/icons/svg/password.svg b/src/icons/svg/password.svg index 920b500b..e291d85d 100644 --- a/src/icons/svg/password.svg +++ b/src/icons/svg/password.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/icons/svg/people.svg b/src/icons/svg/people.svg index 3985ab51..2bd54aeb 100644 --- a/src/icons/svg/people.svg +++ b/src/icons/svg/people.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/icons/svg/peoples.svg b/src/icons/svg/peoples.svg index 2dccfcc0..2c911615 100644 --- a/src/icons/svg/peoples.svg +++ b/src/icons/svg/peoples.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/icons/svg/qq.svg b/src/icons/svg/qq.svg index 97aee717..ee13d4ec 100644 --- a/src/icons/svg/qq.svg +++ b/src/icons/svg/qq.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/icons/svg/shopping.svg b/src/icons/svg/shopping.svg new file mode 100644 index 00000000..87513e7c --- /dev/null +++ b/src/icons/svg/shopping.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/shoppingCard.svg b/src/icons/svg/shoppingCard.svg deleted file mode 100644 index cdebbdb4..00000000 --- a/src/icons/svg/shoppingCard.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/icons/svg/size.svg b/src/icons/svg/size.svg index def290f7..ddb25b8d 100644 --- a/src/icons/svg/size.svg +++ b/src/icons/svg/size.svg @@ -1,2 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/icons/svg/star.svg b/src/icons/svg/star.svg index 685a301d..6cf86e66 100644 --- a/src/icons/svg/star.svg +++ b/src/icons/svg/star.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/icons/svg/tab.svg b/src/icons/svg/tab.svg index 17aa088b..b4b48e48 100644 --- a/src/icons/svg/tab.svg +++ b/src/icons/svg/tab.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/icons/svg/table.svg b/src/icons/svg/table.svg index 083bc8cc..dbfe5d64 100644 --- a/src/icons/svg/table.svg +++ b/src/icons/svg/table.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/icons/svg/theme.svg b/src/icons/svg/theme.svg index d5c2e5ad..5982a2f7 100644 --- a/src/icons/svg/theme.svg +++ b/src/icons/svg/theme.svg @@ -1 +1 @@ - + \ No newline at end of file diff --git a/src/icons/svg/tree.svg b/src/icons/svg/tree.svg new file mode 100644 index 00000000..dd4b7dd2 --- /dev/null +++ b/src/icons/svg/tree.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/icons/svg/user.svg b/src/icons/svg/user.svg index 5971deeb..0ba0716a 100644 --- a/src/icons/svg/user.svg +++ b/src/icons/svg/user.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/icons/svg/wechat.svg b/src/icons/svg/wechat.svg index d88a64bc..9e18b717 100644 --- a/src/icons/svg/wechat.svg +++ b/src/icons/svg/wechat.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/src/icons/svg/zip.svg b/src/icons/svg/zip.svg index e9a9d012..f806fc48 100644 --- a/src/icons/svg/zip.svg +++ b/src/icons/svg/zip.svg @@ -1 +1 @@ - + \ No newline at end of file diff --git a/src/icons/svgo.yml b/src/icons/svgo.yml new file mode 100644 index 00000000..d11906ae --- /dev/null +++ b/src/icons/svgo.yml @@ -0,0 +1,22 @@ +# replace default config + +# multipass: true +# full: true + +plugins: + + # - name + # + # or: + # - name: false + # - name: true + # + # or: + # - name: + # param1: 1 + # param2: 2 + +- removeAttrs: + attrs: + - 'fill' + - 'fill-rule' diff --git a/src/store/modules/permission.js b/src/store/modules/permission.js index ce1aafa6..97de701e 100644 --- a/src/store/modules/permission.js +++ b/src/store/modules/permission.js @@ -7,7 +7,7 @@ import { asyncRouterMap, constantRouterMap } from '@/router' */ function hasPermission(roles, route) { if (route.meta && route.meta.roles) { - return roles.some(role => route.meta.roles.indexOf(role) >= 0) + return roles.some(role => route.meta.roles.includes(role)) } else { return true } @@ -15,20 +15,23 @@ function hasPermission(roles, route) { /** * 递归过滤异步路由表,返回符合用户角色权限的路由表 - * @param asyncRouterMap + * @param routes asyncRouterMap * @param roles */ -function filterAsyncRouter(asyncRouterMap, roles) { - const accessedRouters = asyncRouterMap.filter(route => { - if (hasPermission(roles, route)) { - if (route.children && route.children.length) { - route.children = filterAsyncRouter(route.children, roles) +function filterAsyncRouter(routes, roles) { + const res = [] + + routes.forEach(route => { + const tmp = { ...route } + if (hasPermission(roles, tmp)) { + if (tmp.children) { + tmp.children = filterAsyncRouter(tmp.children, roles) } - return true + res.push(tmp) } - return false }) - return accessedRouters + + return res } const permission = { @@ -47,7 +50,7 @@ const permission = { return new Promise(resolve => { const { roles } = data let accessedRouters - if (roles.indexOf('admin') >= 0) { + if (roles.includes('admin')) { accessedRouters = asyncRouterMap } else { accessedRouters = filterAsyncRouter(asyncRouterMap, roles) diff --git a/src/store/modules/tagsView.js b/src/store/modules/tagsView.js index f2faeb12..cbf9eeb7 100644 --- a/src/store/modules/tagsView.js +++ b/src/store/modules/tagsView.js @@ -60,6 +60,15 @@ const tagsView = { }, DEL_ALL_CACHED_VIEWS: state => { state.cachedViews = [] + }, + + UPDATE_VISITED_VIEW: (state, view) => { + for (let v of state.visitedViews) { + if (v.path === view.path) { + v = Object.assign(v, view) + break + } + } } }, @@ -142,6 +151,10 @@ const tagsView = { commit('DEL_ALL_CACHED_VIEWS') resolve([...state.cachedViews]) }) + }, + + updateVisitedView({ commit }, view) { + commit('UPDATE_VISITED_VIEW', view) } } } diff --git a/src/store/modules/user.js b/src/store/modules/user.js index 13e76399..0f7e2296 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -122,7 +122,7 @@ const user = { }, // 动态修改权限 - ChangeRoles({ commit }, role) { + ChangeRoles({ commit, dispatch }, role) { return new Promise(resolve => { commit('SET_TOKEN', role) setToken(role) @@ -132,6 +132,7 @@ const user = { commit('SET_NAME', data.name) commit('SET_AVATAR', data.avatar) commit('SET_INTRODUCTION', data.introduction) + dispatch('GenerateRoutes', data) // 动态修改权限后 重绘侧边菜单 resolve() }) }) diff --git a/src/views/dashboard/admin/components/PanelGroup.vue b/src/views/dashboard/admin/components/PanelGroup.vue index 2d1d58c9..8125b846 100644 --- a/src/views/dashboard/admin/components/PanelGroup.vue +++ b/src/views/dashboard/admin/components/PanelGroup.vue @@ -35,8 +35,8 @@
-
- +
+
Shoppings
@@ -91,7 +91,7 @@ export default { .icon-money { background: #f4516c; } - .icon-shoppingCard { + .icon-shopping { background: #34bfa3 } } @@ -104,7 +104,7 @@ export default { .icon-money { color: #f4516c; } - .icon-shoppingCard { + .icon-shopping { color: #34bfa3 } .card-panel-icon-wrapper { diff --git a/src/views/i18n-demo/index.vue b/src/views/i18n-demo/index.vue index 22f5646c..94d1e470 100644 --- a/src/views/i18n-demo/index.vue +++ b/src/views/i18n-demo/index.vue @@ -20,13 +20,13 @@
- + + +
{{ $t('i18nView.default') }} @@ -57,7 +57,6 @@ export default { data() { return { date: '', - currentPage: 5, tableData: [{ date: '2016-05-03', name: 'Tom', @@ -77,7 +76,9 @@ export default { date: '2016-05-01', name: 'Tom', address: 'No. 189, Grove St, Los Angeles' - }] + }], + options: [], + value: '' } }, computed: { @@ -91,11 +92,35 @@ export default { } } }, + watch: { + lang() { + this.setOptions() + } + }, created() { if (!this.$i18n.getLocaleMessage('en')[viewName]) { this.$i18n.mergeLocaleMessage('en', local.en) this.$i18n.mergeLocaleMessage('zh', local.zh) } + this.setOptions() // set default select options + }, + methods: { + setOptions() { + this.options = [ + { + value: '1', + label: this.$t('i18nView.one') + }, + { + value: '2', + label: this.$t('i18nView.two') + }, + { + value: '3', + label: this.$t('i18nView.three') + } + ] + } } } diff --git a/src/views/i18n-demo/local.js b/src/views/i18n-demo/local.js index 7977d2f9..1c39608e 100644 --- a/src/views/i18n-demo/local.js +++ b/src/views/i18n-demo/local.js @@ -5,6 +5,7 @@ export default { title: '切换语言', note: '本项目国际化基于 vue-i18n', datePlaceholder: '请选择日期', + selectPlaceholder: '请选择', tableDate: '日期', tableName: '姓名', tableAddress: '地址', @@ -13,15 +14,18 @@ export default { success: '成功按钮', info: '信息按钮', warning: '警告按钮', - danger: '危险按钮' + danger: '危险按钮', + one: '一', + two: '二', + three: '三' } - }, en: { i18nView: { title: 'Switch Language', note: 'The internationalization of this project is based on vue-i18n', datePlaceholder: 'Pick a day', + selectPlaceholder: 'Select', tableDate: 'tableDate', tableName: 'tableName', tableAddress: 'tableAddress', @@ -30,7 +34,10 @@ export default { success: 'success', info: 'info', warning: 'warning', - danger: 'danger' + danger: 'danger', + one: 'One', + two: 'Two', + three: 'Three' } } } diff --git a/src/views/layout/components/Sidebar/SidebarItem.vue b/src/views/layout/components/Sidebar/SidebarItem.vue index 6e461d4a..d87453b9 100644 --- a/src/views/layout/components/Sidebar/SidebarItem.vue +++ b/src/views/layout/components/Sidebar/SidebarItem.vue @@ -1,10 +1,10 @@