From cdd26073afd1f34f8cdfcb2c54ecc27673ea4971 Mon Sep 17 00:00:00 2001
From: dayou <853094838@qq.com>
Date: Fri, 28 Jun 2024 18:46:24 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20user=E6=A8=A1=E5=9D=97=E7=9A=84pinia?=
=?UTF-8?q?=E8=BF=81=E7=A7=BB=20(#315)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
web/package.json | 1 +
web/src/management/api/base.js | 7 +--
web/src/management/main.js | 3 ++
.../pages/list/components/MemberSelect.vue | 6 +--
web/src/management/pages/list/index.vue | 7 +--
web/src/management/pages/login/LoginPage.vue | 6 +--
web/src/management/router/index.ts | 11 ++--
web/src/management/store/index.js | 4 +-
web/src/management/stores/user.js | 51 +++++++++++++++++++
web/src/render/main.js | 7 ++-
web/src/render/pages/IndexPage.vue | 1 -
web/src/render/pages/RenderPage.vue | 2 +-
web/src/render/store/actions.js | 1 -
13 files changed, 85 insertions(+), 22 deletions(-)
create mode 100644 web/src/management/stores/user.js
diff --git a/web/package.json b/web/package.json
index 114191e1..ad7c09f6 100644
--- a/web/package.json
+++ b/web/package.json
@@ -27,6 +27,7 @@
"moment": "^2.29.4",
"nanoid": "^5.0.7",
"node-forge": "^1.3.1",
+ "pinia": "^2.1.7",
"qrcode": "^1.5.3",
"vue": "^3.4.15",
"vue-router": "^4.2.5",
diff --git a/web/src/management/api/base.js b/web/src/management/api/base.js
index 45687330..1268f8bc 100644
--- a/web/src/management/api/base.js
+++ b/web/src/management/api/base.js
@@ -1,7 +1,7 @@
import axios from 'axios'
-import store from '@/management/store/index'
import router from '@/management/router/index'
import { get as _get } from 'lodash-es'
+import { useUserStore } from '../stores/user'
export const CODE_MAP = {
SUCCESS: 200,
@@ -36,8 +36,9 @@ instance.interceptors.response.use(
)
instance.interceptors.request.use((config) => {
- const hasLogined = _get(store, 'state.user.hasLogined')
- const token = _get(store, 'state.user.userInfo.token')
+ const userStore = useUserStore()
+ const hasLogined = _get(userStore, 'hasLogined')
+ const token = _get(userStore, 'userInfo.token')
if (hasLogined && token) {
if (!config.headers) {
config.headers = {}
diff --git a/web/src/management/main.js b/web/src/management/main.js
index 56af3ac3..081784ef 100644
--- a/web/src/management/main.js
+++ b/web/src/management/main.js
@@ -1,14 +1,17 @@
import { createApp } from 'vue'
import store from './store'
+import { createPinia } from 'pinia'
import plainText from './directive/plainText'
import safeHtml from './directive/safeHtml'
import App from './App.vue'
import router from './router'
+const pinia = createPinia()
const app = createApp(App)
app.use(store)
+app.use(pinia)
app.use(router)
app.use(plainText)
diff --git a/web/src/management/pages/list/components/MemberSelect.vue b/web/src/management/pages/list/components/MemberSelect.vue
index e36437cd..9bb83ad2 100644
--- a/web/src/management/pages/list/components/MemberSelect.vue
+++ b/web/src/management/pages/list/components/MemberSelect.vue
@@ -23,7 +23,6 @@
diff --git a/web/src/management/pages/login/LoginPage.vue b/web/src/management/pages/login/LoginPage.vue
index d502cf84..6564c9bf 100644
--- a/web/src/management/pages/login/LoginPage.vue
+++ b/web/src/management/pages/login/LoginPage.vue
@@ -57,7 +57,6 @@