refactor: 移除用户存储及相关演示用户逻辑
This commit is contained in:
+1
-14
@@ -2,25 +2,16 @@
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useHead, useSeoMeta } from '#imports'
|
||||
import { useUserStore } from '~/stores/user'
|
||||
import { useAppStore } from '~/stores/app'
|
||||
import { usePageScrollLock } from '~/composables/usePageScrollLock'
|
||||
import HomeIntro from '~/components/home/HomeIntro.vue'
|
||||
import HomeHero from '~/components/home/HomeHero.vue'
|
||||
|
||||
const { t } = useI18n()
|
||||
const userStore = useUserStore()
|
||||
const appStore = useAppStore()
|
||||
|
||||
const isIntroActive = ref(true)
|
||||
|
||||
const demoUserName = computed(() => userStore.displayName)
|
||||
const demoUserRole = computed(() => userStore.role)
|
||||
|
||||
if (!userStore.isLoggedIn) {
|
||||
userStore.loadDemoUser()
|
||||
}
|
||||
|
||||
// 保证即使 Lenis 还没加载完成,也能通过原生 CSS 锁定页面
|
||||
useHead({
|
||||
htmlAttrs: {
|
||||
@@ -57,11 +48,7 @@ watch(() => appStore.isAppLoading, async (isLoading) => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<main
|
||||
id="top"
|
||||
:data-demo-user="demoUserName"
|
||||
:data-demo-user-role="demoUserRole"
|
||||
>
|
||||
<main id="top">
|
||||
<HomeIntro ref="homeIntroRef" />
|
||||
<HomeHero ref="homeHeroRef" />
|
||||
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
import { computed, ref } from 'vue'
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
export const useUserStore = defineStore('user', () => {
|
||||
const id = ref('')
|
||||
const displayName = ref('')
|
||||
const role = ref('')
|
||||
const locale = ref('zh-CN')
|
||||
|
||||
const isLoggedIn = computed(() => Boolean(id.value))
|
||||
|
||||
function loadDemoUser() {
|
||||
id.value = 'demo-user'
|
||||
displayName.value = 'Arctic Demo User'
|
||||
role.value = 'Viewer'
|
||||
}
|
||||
|
||||
return {
|
||||
id,
|
||||
displayName,
|
||||
role,
|
||||
locale,
|
||||
isLoggedIn,
|
||||
loadDemoUser,
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user