diff --git a/package-lock.json b/package-lock.json index 2946032..2208166 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "erp-vue3", + "name": "vue3-element-admin", "version": "1.0.0", "lockfileVersion": 1, "requires": true, @@ -2796,6 +2796,12 @@ "resolved": "https://registry.npmjs.org/vue-router/-/vue-router-4.0.5.tgz", "integrity": "sha512-AQq+pllb6FCc7rS6vh4PPcce3XA1jgK3hKNkQ4hXHwoVN7jOeAOMKCnX7XAX3etV9rmN7iNW8iIwgPk95ckBjw==" }, + "vue3-pro-table": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/vue3-pro-table/-/vue3-pro-table-1.0.0.tgz", + "integrity": "sha512-tJXFLhkzUJUvGle04poYEt5HEUtAcNXyeQCFlcxwZUooPgZc49sqDGk37xXmEEqKWXtFgMqA4p1F9x3BfgW3jg==", + "dev": true + }, "vuex": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/vuex/-/vuex-4.0.0.tgz", diff --git a/package.json b/package.json index 717d397..ff088f4 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "erp-vue3", + "name": "vue3-element-admin", "version": "1.0.0", "author": { "name": "huzhushan", @@ -32,15 +32,16 @@ "sass": "^1.32.8", "vite": "^2.1.0", "vite-plugin-mock": "^2.3.0", - "vite-plugin-svg-icons": "^0.4.0" + "vite-plugin-svg-icons": "^0.4.0", + "vue3-pro-table": "^1.0.0" }, "repository": { "type": "git", - "url": "git+https://github.com/huzhushan/erp-vue3.git" + "url": "git+https://github.com/huzhushan/vue3-element-admin.git" }, "license": "MIT", "bugs": { - "url": "https://github.com/huzhushan/erp-vue3/issues" + "url": "https://github.com/huzhushan/vue3-element-admin/issues" }, - "homepage": "https://github.com/huzhushan/erp-vue3" + "homepage": "https://github.com/huzhushan/vue3-element-admin" } diff --git a/readme.md b/readme.md index 233f114..2bc329b 100644 --- a/readme.md +++ b/readme.md @@ -1,3 +1,3 @@ # 简介 -vue3-element-admin 是一个后台管理系统前端解决方案,它基于 vue3 和 element-plus 实现 +vue3-element-admin 是一个后台管理系统前端解决方案,它基于 vue3 + element-plus + vite 实现 diff --git a/src/layout/components/Tagsbar/hooks/useContextMenu.js b/src/layout/components/Tagsbar/hooks/useContextMenu.js index 6ee3d72..70045b3 100644 --- a/src/layout/components/Tagsbar/hooks/useContextMenu.js +++ b/src/layout/components/Tagsbar/hooks/useContextMenu.js @@ -46,6 +46,27 @@ export const useContextMenu = (tagList) => { store.dispatch("tags/delOtherTags", state.selectedTag) router.push(state.selectedTag); }, + closeLeftTags () { + state.closeSomeTags('left') + + }, + closeRightTags () { + state.closeSomeTags('right') + + }, + closeSomeTags (direction) { + const index = tagList.value.findIndex( + (item) => item.fullPath === state.selectedTag.fullPath + ); + + if ((direction === 'left' && index <= 0) || (direction === 'right' && index >= tagList.value.length - 1)) { + return; + } + + const needToClose = direction === 'left' ? tagList.value.slice(0, index) : tagList.value.slice(index + 1) + store.dispatch("tags/delSomeTags", needToClose) + router.push(state.selectedTag); + }, closeAllTags () { store.dispatch("tags/delAllTags") router.push("/"); diff --git a/src/layout/components/Tagsbar/hooks/useTags.js b/src/layout/components/Tagsbar/hooks/useTags.js index 455eef7..10bdc96 100644 --- a/src/layout/components/Tagsbar/hooks/useTags.js +++ b/src/layout/components/Tagsbar/hooks/useTags.js @@ -1,5 +1,5 @@ import { useScrollbar } from "./useScrollbar"; -import { onMounted, watch, computed, ref, nextTick } from 'vue'; +import { watch, computed, ref, nextTick, onBeforeMount } from 'vue'; import { useRouter } from 'vue-router'; import { useStore } from 'vuex' @@ -73,7 +73,7 @@ export const useTags = () => { - onMounted(() => { + onBeforeMount(() => { initTags(); addTag(); moveToCurrentTag(); diff --git a/src/layout/components/Tagsbar/index.vue b/src/layout/components/Tagsbar/index.vue index d48ee4c..ca49516 100644 --- a/src/layout/components/Tagsbar/index.vue +++ b/src/layout/components/Tagsbar/index.vue @@ -39,6 +39,8 @@
  • 刷新
  • 关闭
  • 关闭其他
  • +
  • 关闭左侧
  • +
  • 关闭右侧
  • 关闭全部
  • diff --git a/src/main.js b/src/main.js index 5d95861..dfdab07 100644 --- a/src/main.js +++ b/src/main.js @@ -6,6 +6,9 @@ const app = createApp(App) // 引入element-plus import ElementPlus from "element-plus"; import './assets/style/element-variables.scss' +// 引入中文语言包 +import 'dayjs/locale/zh-cn' +import locale from 'element-plus/lib/locale/lang/zh-cn' // 引入路由 import router from './router' @@ -25,4 +28,8 @@ Object.entries(Components).forEach(([key, component]) => { app.component(key, component) }) -app.use(ElementPlus).use(store).use(router).mount('#app') +// 引入vue3-pro-table +import Vue3ProTable from "vue3-pro-table"; +app.use(Vue3ProTable); + +app.use(ElementPlus, { locale }).use(store).use(router).mount('#app') diff --git a/src/store/modules/tags.js b/src/store/modules/tags.js index 3344a40..4d6b4f3 100644 --- a/src/store/modules/tags.js +++ b/src/store/modules/tags.js @@ -38,6 +38,7 @@ const mutations = { }, DEL_CACHE_LIST: (state, tag) => { state.cacheList = state.cacheList.filter(v => v !== tag.name) + }, DEL_OTHER_TAG_LIST: (state, tag) => { @@ -47,6 +48,18 @@ const mutations = { }, DEL_OTHER_CACHE_LIST: (state, tag) => { state.cacheList = state.cacheList.filter(v => v === tag.name) + + }, + + DEL_SOME_TAG_LIST: (state, tags) => { + state.tagList = state.tagList.filter(v => !!v.meta.affix || tags.every(tag => tag.path !== v.path)) + // 保存到localStorage + setItem(TAGLIST, state.tagList); + }, + + DEL_SOME_CACHE_LIST: (state, tags) => { + state.cacheList = state.cacheList.filter(v => tags.every(tag => tag.name !== v)) + }, DEL_ALL_TAG_LIST: state => { @@ -56,6 +69,7 @@ const mutations = { }, DEL_ALL_CACHE_LIST: state => { state.cacheList = [] + }, UPDATE_TAG_LIST: (state, tag) => { @@ -109,6 +123,11 @@ const actions = { commit('DEL_OTHER_CACHE_LIST', tag) }, + delSomeTags ({ commit }, tags) { + commit('DEL_SOME_TAG_LIST', tags) + commit('DEL_SOME_CACHE_LIST', tags) + }, + delAllTags ({ dispatch }) { dispatch('delAllTagList') dispatch('delAllCacheList') diff --git a/src/views/test/Auth.vue b/src/views/test/Auth.vue index c3bda0a..a561153 100644 --- a/src/views/test/Auth.vue +++ b/src/views/test/Auth.vue @@ -4,5 +4,6 @@ $store.state.account.userinfo && $store.state.account.userinfo.role }} +

    刷新页面可切换随机角色

    点击进入只有admin才能访问的页面 \ No newline at end of file diff --git a/src/views/test/Cache.vue b/src/views/test/Cache.vue index 7fbf767..8304483 100644 --- a/src/views/test/Cache.vue +++ b/src/views/test/Cache.vue @@ -6,12 +6,15 @@ diff --git a/src/views/test/index.vue b/src/views/test/index.vue index 7f1316b..3202712 100644 --- a/src/views/test/index.vue +++ b/src/views/test/index.vue @@ -1,6 +1,261 @@ \ No newline at end of file + + + + + + + + diff --git a/vite.config.js b/vite.config.js index 7289888..5c86195 100644 --- a/vite.config.js +++ b/vite.config.js @@ -36,6 +36,8 @@ export default env => { }, }, server: { + port: 8080, + open: true, proxy: { "/api": { target: "http://dev.erp.com",