Skip to content

Commit 2274437

Browse files
committed
fix: context lost
1 parent d3d574b commit 2274437

File tree

2 files changed

+24
-12
lines changed

2 files changed

+24
-12
lines changed

app/pages/index.vue

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
<script setup lang="ts">
22
definePageMeta({ middleware: 'require-login' })
33
4-
const dateLimit = ref<string | undefined>(undefined)
5-
const timeLimit = ref<string | undefined>(undefined)
6-
const maimaiMaid = ref<string | undefined>(undefined)
4+
const contextStore = useContextStore()
75
86
onMounted(() => {
97
const route = useRoute()
10-
dateLimit.value = route.query.date as string | undefined
11-
timeLimit.value = route.query.time as string | undefined
12-
maimaiMaid.value = route.query.maid as string | undefined
8+
if (route.query.date)
9+
contextStore.dateLimit = route.query.date as string
10+
if (route.query.time)
11+
contextStore.timeLimit = route.query.time as string
12+
if (route.query.maid)
13+
contextStore.maimaiMaid = route.query.maid as string
1314
})
1415
1516
const { data: profile } = await useLeporid<UserProfile>('/api/nuxt/profile')
@@ -50,8 +51,8 @@ const simplifiedCode = computed(() => {
5051
// 覆盖优先级:用户偏好设置 > 页面参数
5152
if (profile.value?.preference.simplifiedCode)
5253
return profile.value?.preference.simplifiedCode
53-
if (maimaiMaid.value)
54-
return maimaiMaid.value?.slice(8, 28).match(/.{1,4}/g)?.join(' ')
54+
if (contextStore.maimaiMaid)
55+
return contextStore.maimaiMaid?.slice(8, 28).match(/.{1,4}/g)?.join(' ')
5556
return undefined
5657
})
5758
@@ -82,18 +83,18 @@ const maimaiVersion = computed(() => {
8283
</div>
8384

8485
<WidgetCharaInfo
85-
:chara-name="profile.preference.characterName || undefined" :time-limit="timeLimit"
86-
:date-limit="dateLimit" :show-date="profile.preference.showDate"
86+
:chara-name="profile.preference.characterName || undefined" :time-limit="contextStore.timeLimit"
87+
:date-limit="contextStore.dateLimit" :show-date="profile.preference.showDate"
8788
:chara-info-color="profile.preference.charaInfoColor" class="bottom-[18%] absolute"
8889
/>
8990

90-
<WidgetQrCode v-if="maimaiMaid" class="absolute right-0 bottom-[6%]" :content="maimaiMaid" :size="profile.preference.qrSize" />
91+
<WidgetQrCode v-if="contextStore.maimaiMaid" class="absolute right-0 bottom-[6%]" :content="contextStore.maimaiMaid" :size="profile.preference.qrSize" />
9192

9293
<div
9394
id="c-footer" class="flex absolute bottom-0 items-center justify-center w-full pb-[0.8%]"
9495
:style="{ '--b-bottom': `url(${img(profile.preference.frameId)})` }"
9596
>
96-
<button class="cursor-pointer" @click="triggerCrawl({ date: dateLimit || '', time: timeLimit || '', maid: maimaiMaid || '' })">
97+
<button class="cursor-pointer" @click="triggerCrawl({ date: contextStore.dateLimit || '', time: contextStore.timeLimit || '', maid: contextStore.maimaiMaid || '' })">
9798
<div class="p-1 rounded-full bg-white dark:bg-gray-800" aria-label="rocket" role="img">
9899
<svg
99100
xmlns="http://www.w3.org/2000/svg" class="footer-icon" viewBox="-4 -4 32 32"

app/stores/context.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export const useContextStore = defineStore('context', () => {
2+
const dateLimit = ref<string | undefined>(undefined)
3+
const timeLimit = ref<string | undefined>(undefined)
4+
const maimaiMaid = ref<string | undefined>(undefined)
5+
6+
return {
7+
dateLimit,
8+
timeLimit,
9+
maimaiMaid,
10+
}
11+
})

0 commit comments

Comments
 (0)