瀏覽代碼

feat: 退出登录后清理缓存

王家程 10 月之前
父節點
當前提交
10c8cae4e1

+ 2 - 7
src/components/MTabBar/index.vue

@@ -2,12 +2,12 @@
  * @Author: wjc
  * @Date: 2024-07-08 16:31:21
  * @LastEditors: wjc
- * @LastEditTime: 2024-07-12 11:41:28
+ * @LastEditTime: 2024-07-12 17:03:13
  * @Description: 
 -->
 <template>
   <up-tabbar
-    :value="selected"
+    :value="appStore.selectedTabbar"
     class="m-tabbar"
     :fixed="true"
     :z-index="99"
@@ -33,13 +33,8 @@
   defineOptions({ name: 'MTabBar' })
 
   const appStore = useAppStore()
-  const selected = ref(appStore.selectedTabbar)
   const tabbarList = ref(tabBar.list)
 
-  watchEffect(() => {
-    selected.value = appStore.selectedTabbar
-  })
-
   const handleChange = (val: number) => {
     appStore.setTabbar(val)
     uni.switchTab({

+ 8 - 1
src/pages/auth/index.vue

@@ -1,3 +1,10 @@
+<!--
+ * @Author: wjc
+ * @Date: 2024-07-02 15:22:51
+ * @LastEditors: wjc
+ * @LastEditTime: 2024-07-12 17:05:10
+ * @Description: 
+-->
 <template>
   <view>
     <up-modal :show="true">
@@ -15,6 +22,6 @@
   defineOptions({ name: 'Auth' })
 
   const handleConfirm = () => {
-    uni.navigateTo({ url: '/pages/login/index' })
+    uni.reLaunch({ url: '/pages/login/index' })
   }
 </script>

+ 2 - 2
src/pages/mine/index.vue

@@ -2,7 +2,7 @@
  * @Author: wjc
  * @Date: 2024-06-17 16:02:59
  * @LastEditors: wjc
- * @LastEditTime: 2024-07-12 15:50:38
+ * @LastEditTime: 2024-07-12 17:05:15
  * @Description: 
 -->
 <template>
@@ -78,7 +78,7 @@
   const onLogout = () => {
     userStore.logoutAction().then((res) => {
       if (res) {
-        uni.navigateTo({
+        uni.reLaunch({
           url: '/pages/login/index',
         })
       }

+ 1 - 1
src/stores/modules/appStore.ts

@@ -2,7 +2,7 @@
  * @Author: wjc
  * @Date: 2024-06-05 11:22:45
  * @LastEditors: wjc
- * @LastEditTime: 2024-07-12 09:44:20
+ * @LastEditTime: 2024-07-12 16:58:18
  * @Description:
  */
 import { defineStore } from 'pinia'

+ 4 - 1
src/stores/modules/userStore.ts

@@ -2,11 +2,12 @@
  * @Author: wjc
  * @Date: 2024-06-05 17:13:30
  * @LastEditors: wjc
- * @LastEditTime: 2024-07-02 16:42:44
+ * @LastEditTime: 2024-07-12 17:07:58
  * @Description:
  */
 import { defineStore } from 'pinia'
 
+import { useAppStore } from './appStore'
 import { UserState, ILogin, LoginRes, Employees } from '@/models/userTypes'
 import { login, logout, getUserInfo } from '@/api/userApi'
 
@@ -45,10 +46,12 @@ export const useUserStore = defineStore('user', {
       })
     },
     logoutAction(): Promise<string> {
+      const appStore = useAppStore()
       return new Promise((resolve, reject) => {
         logout()
           .then((res) => {
             if (res && res.data) {
+              appStore.$reset()
               this.$reset()
               resolve(res.data)
             }