songxy 1 рік тому
батько
коміт
ea0d8a52d8

+ 2 - 2
client_h5/index.html

@@ -5,8 +5,8 @@
     <meta http-equiv="X-UA-Compatible" content="IE=edge">
     <meta name="viewport" content="width=device-width,initial-scale=1.0, maximum-scale=1">
     <!-- <script src="https://g.alicdn.com/dingding/dingtalk-jsapi/2.10.3/dingtalk.open.js"></script> -->
-    <script src="eruda.js"></script>
-    <script>eruda.init()</script>
+    <!-- <script src="eruda.js"></script> -->
+    <!-- <script>eruda.init()</script> -->
     <title></title>
   </head>
   <body>

Різницю між файлами не показано, бо вона завелика
+ 0 - 0
client_h5/public/eruda.js


+ 16 - 9
client_h5/src/App.vue

@@ -1,16 +1,23 @@
 <script setup lang="ts">
+import { useUserStoreWithOut, UserInterface } from "@/stores/modules/user"
 import { getAuthCode } from 'dingtalk-jsapi'; 
 import reqest from "@/utils/request";
 
+const userStore = useUserStoreWithOut();
 const initUserInfoHandler = async () => {
     const code: string = await getDDAuthCode() as string
-    const userIdResult = await getUserIdByDD({
-        code
-    })
-    console.log("userIdResult--------")
-    console.log(userIdResult)
+    const userIdResult = await getUserIdByDD({code})
     if (userIdResult && userIdResult?.data) {
-        getUserInfoById(userIdResult?.data.userId)
+        const userResult = await getUserInfoById(userIdResult?.data.accessToken)
+        if (userResult && userResult?.data) { 
+            const userInfo: UserInterface = {
+                id: userResult?.data.user.id,
+                nickname: userResult?.data.user.nickname,
+                accessToken: userIdResult?.data.accessToken,
+            }
+            userStore.setUser(userInfo)
+            localStorage.setItem("_userInfo", JSON.stringify(userInfo))
+        }
     }
 }
 initUserInfoHandler()
@@ -38,9 +45,9 @@ const getUserIdByDD = async (data: Required<UserIdParam>) => {
   return reqest.post(`/app-api/system/auth/login-ding?code=${data.code}`, null)
 }
 //@ts-ignore
-const getUserInfoById = async (idStr: Required<string>) => {
-  return reqest.get('/admin-api/system/user/get', {
-      params: {id: idStr}
+const getUserInfoById = async (token: Required<string>) => {
+    return reqest.get('/admin-api/system/auth/get-permission-info', {
+        headers: { 'Authorization': 'Bearer ' + token }
   })
 }
 </script>

+ 2 - 0
client_h5/src/main.ts

@@ -1,4 +1,5 @@
 import { createApp } from 'vue'
+import { setupStore } from '@/stores'
 import setupRouter from './router'
 import './style.css'
 import App from './App.vue'
@@ -6,6 +7,7 @@ import App from './App.vue'
 
 const setupAll = () => {
   const app = createApp(App)
+  setupStore(app)
   setupRouter(app)
   return app;
 }

+ 3 - 3
client_h5/src/pages/home/index.vue

@@ -1,8 +1,8 @@
 <script setup lang="ts">
-import { ref } from 'vue'
+import { useUserStoreWithOut } from '@/stores/modules/user';
 import { getAssetsURI } from '@/utils/common';
 
-const userName = ref<String>('测试用户')
+const userStore = useUserStoreWithOut();
 
 interface MenuItem {
   title: string
@@ -81,7 +81,7 @@ const toPageHandle = (path: string) => {
       <div class="nav">
         <div class="login_info">
           <img src="@/assets/images/user_log.jpg">
-          <span>{{ userName }}</span>
+          <span>{{ userStore.userInfo.nickname }}</span>
         </div>
       </div>
       <ul>

+ 10 - 22
client_h5/src/stores/modules/user.ts

@@ -1,33 +1,18 @@
 import { defineStore } from "pinia";
 
-interface UserInterface {
-    username: string
-    nickname: string
-    deptId: string
-    deptIds: string[]
-    email: string
-    mobile: string
-    sex: string
-    avatar: string
+export interface UserInterface {
+    id: string  //用户ID
+    nickname: string    //用户昵称
+    accessToken: string //accessToken
 }
 const UserStore = defineStore("UserStore", {
     state: () => ({
         userInfo: {
-            username: "",
+            id: "",
             nickname: "",
-            deptId: "",
-            deptIds: [],
-            email: "",
-            mobile: "",
-            sex: "",
-            avatar: ""
+            accessToken: ""
         } as UserInterface
     }),
-    getters: {
-        getUser(state) {
-            return state.userInfo;
-        }
-    },
     actions: {
         setUser(user: UserInterface) {
             this.userInfo = user;
@@ -35,4 +20,7 @@ const UserStore = defineStore("UserStore", {
     }
 });
 
-export default UserStore;
+
+export const useUserStoreWithOut = () => {
+    return UserStore();
+}

Деякі файли не було показано, через те що забагато файлів було змінено