ソースを参照

🎨 按要求修改细节问题

快乐的梦鱼 1 ヶ月 前
コミット
eb484597eb
共有4 個のファイルを変更した23 個の追加11 個の削除を含む
  1. 5 0
      src/api/auth/UserApi.ts
  2. 3 3
      src/pages/home.vue
  3. 1 1
      src/pages/inhert/intangible/list.vue
  4. 14 7
      src/store/auth.ts

+ 5 - 0
src/api/auth/UserApi.ts

@@ -111,6 +111,11 @@ export class UserApi extends AppServerRequestModule<DataModel> {
     return (await this.post('/content/main_body_user/refreshUser', {
     }, '刷新用户', undefined, LoginResult)).data as LoginResult;
   }
+  async checkUserAuthed(id: number) {
+    return await this.post('/content/main_body_user/getMainBodyUser', {
+      main_body_user_id: id,
+    }, '检查用户是否登录');
+  }  
 }
 
 export default new UserApi();

+ 3 - 3
src/pages/home.vue

@@ -311,7 +311,7 @@ const statsLoader = useSimpleDataLoader(async () => {
   let sumInheritor = 0;
   let sumProject = 0;
   const topLevelProject = data.ichData.find((p: any) => p.level_text == '人类非遗')?.total || 0;
-  const projects = (data.ichData as any[]).filter((p: any) => [ '国家级', '省级', '市级' ].includes(p.level_text)).map((item: any) => {
+  const projects = (data.ichData as any[]).filter((p: any) => [ '人类非遗', '国家级', '省级', '市级' ].includes(p.level_text)).map((item: any) => {
     sumProject += item.total;
     return {
       title: item.level_text,
@@ -326,12 +326,12 @@ const statsLoader = useSimpleDataLoader(async () => {
       long: true,
     }
   ]);
-  projects.splice(1, 0, {
+  /* projects.splice(1, 0, {
     title: `(其中${topLevelProject}项为人类非遗)`,
     value: ' ',
     longTitle: true,
     onClick: () => navTo('/pages/inhert/intangible/list', { tab: 0, level: 0 }),
-  })
+  }) */
   return [
     {
       title: '非遗项目',

+ 1 - 1
src/pages/inhert/intangible/list.vue

@@ -14,7 +14,7 @@
     :dropDownNames="dropdownNames"
     :tabs="[
       { id: 0, text: '非遗项目' },
-      { id: 1, text: '非遗作品' },
+      //{ id: 1, text: '非遗作品' },
       { id: 2, text: '非遗传承人', jump: () => navTo('/pages/inhert/inheritor/list'), onlyJump: true },
       { id: 3, text: '非遗传习所' },
       { id: 4, text: '保护单位' },

+ 14 - 7
src/store/auth.ts

@@ -21,14 +21,11 @@ export const useAuthStore = defineStore('auth', {
         this.userId = authInfo.userId;
         this.expireAt = authInfo.expireAt;
         this.userInfo = authInfo.userInfo;
+        this.shareLoginInfo();
 
-        // 全局变量存储
-        const app = getApp();
-        if (!app.globalData) 
-          app.globalData = {};
-        app.globalData.token = this.token;
-        app.globalData.userId = this.userId;
-        app.globalData.userInfo = this.userInfo;
+        //检查登录是否过期
+        await UserApi.checkUserAuthed(this.userId);
+        return true;
       } catch (error) {
         this.token = '';
         this.userId = 0;
@@ -63,6 +60,7 @@ export const useAuthStore = defineStore('auth', {
       this.saveLoginState();
     },
     saveLoginState() {
+      this.shareLoginInfo();
       uni.setStorage({ 
         key: STORAGE_KEY, 
         data: JSON.stringify({ 
@@ -73,6 +71,15 @@ export const useAuthStore = defineStore('auth', {
         }) 
       });
     },
+    shareLoginInfo() {
+      // 全局变量存储
+      const app = getApp();
+      if (!app.globalData) 
+        app.globalData = {};
+      app.globalData.token = this.token;
+      app.globalData.userId = this.userId;
+      app.globalData.userInfo = this.userInfo;
+    },
     async logout() {
       this.token = '';
       this.userId = 0;