408249787@qq.com 2 settimane fa
parent
commit
87c74ef0b6
2 ha cambiato i file con 9 aggiunte e 5 eliminazioni
  1. 2 0
      .cool/store/user.ts
  2. 7 5
      pages/index/components/exchange.uvue

+ 2 - 0
.cool/store/user.ts

@@ -126,6 +126,8 @@ export class User {
 		// storage.remove("refreshToken");
 		this.token = 'Basic ZW5kOmVuZA==';
 		this.remove();
+		this.info.value = null;
+		this.courseId.value = null;
 	}
 
 	/**

+ 7 - 5
pages/index/components/exchange.uvue

@@ -1,5 +1,5 @@
 <script setup lang='ts'>
-import { ref } from 'vue'
+import { ref, onMounted } from 'vue'
 import { exchangeCode } from '@/services/user'
 import { dict } from '@/.cool/store'
 import { user, router } from '@/.cool'
@@ -8,12 +8,14 @@ import { useUi } from "@/uni_modules/cool-ui";
 
 const ui = useUi();
 const code = ref<string>('')
-
-async function handleExchange() {
-  if (user.token === 'Basic ZW5kOmVuZA==') {
-    router.push({ path: '/pages/user/login' })
+onMounted(() => {
+  if (!user.info.value?.userInfo) {
+    user.logout()
     return
   }
+})
+async function handleExchange() {
+
   if (!code.value) {
     uni.showToast({
       title: '请输入兑换码',