diff --git a/package.json b/package.json
index 0f35e5c..2fe5d71 100644
--- a/package.json
+++ b/package.json
@@ -30,6 +30,7 @@
"jsencrypt": "3.2.1",
"md-editor-v3": "^1.11.11",
"nprogress": "0.2.0",
+ "pinia": "^2.0.14",
"sortablejs": "^1.15.0",
"vue": "^3.2.36",
"vue-clipboard3": "^2.0.0",
@@ -37,7 +38,6 @@
"vue-i18n": "^9.1.10",
"vue-router": "^4.0.15",
"vue3-seamless-scroll": "^1.2.0",
- "vuex": "4.0.2",
"wangeditor": "^4.7.15"
},
"devDependencies": {
diff --git a/src/App.vue b/src/App.vue
index 0408db9..9e2725f 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -4,7 +4,8 @@
diff --git a/src/components/Notice/Index.vue b/src/components/Notice/Index.vue
index d6df379..ad4c3e5 100644
--- a/src/components/Notice/Index.vue
+++ b/src/components/Notice/Index.vue
@@ -33,15 +33,18 @@
diff --git a/src/components/TopNav/index.vue b/src/components/TopNav/index.vue
index 0932a45..d0c6e11 100644
--- a/src/components/TopNav/index.vue
+++ b/src/components/TopNav/index.vue
@@ -37,6 +37,9 @@ import { constantRoutes } from '@/router'
import { isHttp } from '@/utils/validate'
import { useRouter } from 'vue-router'
import { getNormalPath } from '@/utils/ruoyi'
+import useAppStore from '@/store/modules/app'
+import useSettingsStore from '@/store/modules/settings'
+import usePermissionStore from '@/store/modules/permission'
// 顶部栏初始数
const visibleNumber = ref(5)
@@ -45,14 +48,16 @@ const isFrist = ref(false)
// 当前激活菜单的 index
const currentIndex = ref(undefined)
-const store = useStore()
+const appStore = useAppStore()
+const settingsStore = useSettingsStore()
+const permissionStore = usePermissionStore()
const route = useRoute()
const router = useRouter()
// 主题颜色
-const theme = computed(() => store.state.settings.theme)
+const theme = computed(() => settingsStore.theme)
// 所有的路由信息
-const routers = computed(() => store.state.permission.topbarRouters)
+const routers = computed(() => permissionStore.topbarRouters)
// 顶部显示菜单
const topMenus = computed(() => {
@@ -153,7 +158,7 @@ function activeRoutes(key) {
})
}
if (routes.length > 0) {
- store.commit('SET_SIDEBAR_ROUTERS', routes)
+ permissionStore.setSidebarRouters(routes)
}
return routes
}
diff --git a/src/directive/permission/hasPermi.js b/src/directive/permission/hasPermi.js
index 91777f1..4c387bf 100644
--- a/src/directive/permission/hasPermi.js
+++ b/src/directive/permission/hasPermi.js
@@ -1,28 +1,28 @@
/**
- * v-hasPermi 操作权限处理
- * Copyright (c) 2019 ruoyi
- */
-
-import store from '@/store'
+ * v-hasPermi 操作权限处理
+ * Copyright (c) 2019 ruoyi
+ */
-export default {
- mounted(el, binding, vnode) {
- const { value } = binding
- const all_permission = "*:*:*";
- const permissions = store.getters && store.getters.permissions
+ import useUserStore from '@/store/modules/user'
- if (value && value instanceof Array && value.length > 0) {
- const permissionFlag = value
+ export default {
+ mounted(el, binding, vnode) {
+ const { value } = binding
+ const all_permission = "*:*:*";
+ const permissions = useUserStore().permissions
- const hasPermissions = permissions.some(permission => {
- return all_permission === permission || permissionFlag.includes(permission)
- })
+ if (value && value instanceof Array && value.length > 0) {
+ const permissionFlag = value
- if (!hasPermissions) {
- el.parentNode && el.parentNode.removeChild(el)
- }
- } else {
- throw new Error(`请设置操作权限标签值`)
- }
- }
-}
+ const hasPermissions = permissions.some(permission => {
+ return all_permission === permission || permissionFlag.includes(permission)
+ })
+
+ if (!hasPermissions) {
+ el.parentNode && el.parentNode.removeChild(el)
+ }
+ } else {
+ throw new Error(`请设置操作权限标签值`)
+ }
+ }
+ }
\ No newline at end of file
diff --git a/src/directive/permission/hasRole.js b/src/directive/permission/hasRole.js
index a8776a6..c4e387b 100644
--- a/src/directive/permission/hasRole.js
+++ b/src/directive/permission/hasRole.js
@@ -3,13 +3,13 @@
* Copyright (c) 2019 ruoyi
*/
-import store from '@/store'
+import useUserStore from '@/store/modules/user'
export default {
mounted(el, binding, vnode) {
const { value } = binding
const super_admin = "admin";
- const roles = store.getters && store.getters.roles
+ const roles = useUserStore().roles
if (value && value instanceof Array && value.length > 0) {
const roleFlag = value
diff --git a/src/i18n/index.js b/src/i18n/index.js
index 6d29672..4358092 100644
--- a/src/i18n/index.js
+++ b/src/i18n/index.js
@@ -1,9 +1,10 @@
import { createI18n } from 'vue-i18n'
-import store from '@/store/index'
+// import useAppStore from '@/store/modules/app'
import { listLangByLocale } from '@/api/system/commonLang'
-
+import jsCookie from 'js-cookie'
const language = computed(() => {
- return store.getters.language
+ // return useAppStore().lang
+ return jsCookie.get('lang') || 'zh-cn'
})
import zhCn from './lang/zh-cn.json'
@@ -23,7 +24,7 @@ const i18n = createI18n({
// 全局注入 $t 函数
globalInjection: true,
fallbackLocale: 'zh-cn',
- locale: store.getters.language, //默认选择的语言
+ locale: language.value, //默认选择的语言
legacy: false, // 使用 Composition API 模式,则需要将其设置为false
messages: {
'zh-cn': {
diff --git a/src/layout/components/AppMain.vue b/src/layout/components/AppMain.vue
index b97222b..8035beb 100644
--- a/src/layout/components/AppMain.vue
+++ b/src/layout/components/AppMain.vue
@@ -10,9 +10,11 @@
diff --git a/src/layout/components/Navbar.vue b/src/layout/components/Navbar.vue
index 8ba0837..0d370c7 100644
--- a/src/layout/components/Navbar.vue
+++ b/src/layout/components/Navbar.vue
@@ -1,13 +1,13 @@
-