diff --git a/src/GlobalModal.tsx b/src/GlobalModal.tsx
index f39aeb2..303062b 100644
--- a/src/GlobalModal.tsx
+++ b/src/GlobalModal.tsx
@@ -30,7 +30,7 @@ export default defineComponent(() => {
{
- router.path = ''
+ router.back()
}}
>
)}
@@ -53,7 +53,7 @@ export default defineComponent(() => {
(router.path === 'global-adder' ? 'top-6 right-4' : 'top-2 right-2')
}
onClick={() => {
- router.path = ''
+ router.back()
}}
>
{
if (user.isLogin) {
- router.path = 'settings-user'
+ router.go('settings-user')
} else {
- router.path = 'global-login'
+ router.go('global-login')
}
}}
>
diff --git a/src/settings/SettingsButton.tsx b/src/settings/SettingsButton.tsx
index 7756199..3d7dbe4 100644
--- a/src/settings/SettingsButton.tsx
+++ b/src/settings/SettingsButton.tsx
@@ -10,7 +10,7 @@ export default defineComponent(() => {
class="absolute left-10 bottom-8 p-1 z-10 flex justify-center items-center cursor-pointer rounded-lg hover:bg-black/20 transition-all"
style="filter: drop-shadow(0 0 4px rgba(0,0,0,0.2))"
onClick={() => {
- router.path = 'settings-background'
+ router.go('settings-background')
}}
>
diff --git a/src/settings/SettingsOverlay.tsx b/src/settings/SettingsOverlay.tsx
index bb6efca..c601cea 100644
--- a/src/settings/SettingsOverlay.tsx
+++ b/src/settings/SettingsOverlay.tsx
@@ -25,7 +25,7 @@ const SettingsTab = defineComponent({
(router.path === props.path ? 'bg-white/70 font-bold shadow-lg' : '')
}
onClick={() => {
- router.path = props.path as any
+ router.go(props.path as any)
}}
>
{props.label}
@@ -44,7 +44,7 @@ export default defineComponent(() => {
{
- router.path = ''
+ router.back()
}}
>
)}
@@ -52,45 +52,41 @@ export default defineComponent(() => {
{show.value && (
- {
- router.path.startsWith('settings-') ?
- <>
-
-
{
- router.path = 'settings-user'
- }}
- >
-
+ {router.path.startsWith('settings-') ? (
+ <>
+
+
{
+ router.go('settings-user')
+ }}
+ >
+
-
-
-
-
-
-
-
-
-
-
- >
- :
- router.path.startsWith('s2') ?
- <>
-
-
- >
- : ''
-
- }
-
+
+
+
+
+
+
+
+
+
+
+
+ >
+ ) : router.path.startsWith('s2') ? (
+ <>
+
+ >
+ ) : (
+ ''
+ )}
)}
diff --git a/src/useRouterStore.ts b/src/useRouterStore.ts
index eb3124d..c9b5501 100644
--- a/src/useRouterStore.ts
+++ b/src/useRouterStore.ts
@@ -1,5 +1,5 @@
import { defineStore } from 'pinia'
-import { ref } from 'vue'
+import { computed, ref, watch } from 'vue'
export type GlobalStr = 'search' | 'block' | 'adder' | 'login'
export type SettingStr =
@@ -16,8 +16,24 @@ export type SettingStr =
export type RouteStr = '' | `widget-${string}` | `global-${GlobalStr}` | `settings-${SettingStr}`
export default defineStore('router', () => {
- const path = ref
('')
+ const his = ref([])
+ const go = (p: RouteStr) => {
+ his.value.unshift(p)
+ if (his.value.length > 10) {
+ his.value.pop()
+ }
+ }
+ const back = () => {
+ if (his.value.length > 0) {
+ his.value.shift()
+ }
+ }
+ const path = computed(() => {
+ return his.value[0] || ''
+ })
return {
- path
+ path,
+ go,
+ back
}
})
diff --git a/src/user/LoginModal.tsx b/src/user/LoginModal.tsx
index 8abe717..5702e47 100644
--- a/src/user/LoginModal.tsx
+++ b/src/user/LoginModal.tsx
@@ -17,7 +17,7 @@ export default defineComponent(() => {
{
- router.path = ''
+ router.back()
}}
>
)}
@@ -45,7 +45,7 @@ export default defineComponent(() => {
returnType: 'text'
}).then((res) => {
user.token = res
- router.path = ''
+ router.go('')
})
}}
>
diff --git a/src/user/UserPage.tsx b/src/user/UserPage.tsx
index 335d157..6766d4a 100644
--- a/src/user/UserPage.tsx
+++ b/src/user/UserPage.tsx
@@ -43,7 +43,7 @@ export default defineComponent(() => {
<>