功能:更新 YumiNail 用户端流程

This commit is contained in:
xiaowang
2026-05-31 18:36:52 +08:00
parent 22347ff076
commit 73483e7b0c
49 changed files with 6053 additions and 1306 deletions
+37 -10
View File
@@ -287,12 +287,9 @@ import { notifyShopThemeChanged } from '@/utils/shop-theme'
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const router = useRouter()
const USER_INFO_CACHE_KEY = 'userInfo'
/**
* Purpose: userInfo supports ProfileView.vue by holding or executing the user info page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const userInfo = ref<UserVO>({
const createEmptyUserInfo = (): UserVO => ({
id: 0,
nickname: '',
account: '',
@@ -303,6 +300,34 @@ const userInfo = ref<UserVO>({
updateTime: ''
})
const readCachedUserInfo = (): UserVO => {
if (typeof window === 'undefined') {
return createEmptyUserInfo()
}
try {
const raw = localStorage.getItem(USER_INFO_CACHE_KEY)
const cached = raw ? JSON.parse(raw) as Partial<UserVO> : null
return cached && typeof cached === 'object'
? { ...createEmptyUserInfo(), ...cached }
: createEmptyUserInfo()
} catch {
return createEmptyUserInfo()
}
}
const persistCachedUserInfo = (info: UserVO) => {
if (typeof window === 'undefined') {
return
}
localStorage.setItem(USER_INFO_CACHE_KEY, JSON.stringify(info))
}
/**
* Purpose: userInfo supports ProfileView.vue by holding or executing the user info page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const userInfo = ref<UserVO>(readCachedUserInfo())
/** editModalVisible is a reactive state variable used by the template and event handlers. */
const editModalVisible = ref(false)
/** saving is a reactive state variable used by the template and event handlers. */
@@ -416,7 +441,7 @@ const shopOptions = computed(() => {
})
/** currentShopName is a reactive state variable used by the template and event handlers. */
const currentShopName = computed(() => userInfo.value.shopName || '当前门店')
const currentShopName = computed(() => userInfo.value.shopName || userInfo.value.shopNames?.find(Boolean) || '当前门店')
/** shopSwitchTip is a reactive state variable used by the template and event handlers. */
const shopSwitchTip = computed(() => {
if (shopOptions.value.length > 1) {
@@ -516,7 +541,7 @@ const isServiceUser = computed(() => {
const persistUserSession = (payload: any) => {
localStorage.setItem('accessToken', payload.accessToken)
localStorage.setItem('refreshToken', payload.refreshToken)
localStorage.setItem('userInfo', JSON.stringify(payload.userInfo))
localStorage.setItem(USER_INFO_CACHE_KEY, JSON.stringify(payload.userInfo))
sessionStorage.setItem('accessToken', payload.accessToken)
notifyShopThemeChanged()
if (payload.needSetPassword) {
@@ -532,6 +557,7 @@ const fetchUserInfo = async () => {
artistCalendarAccessible.value = false
const response = await userApi.getUserInfo()
userInfo.value = response
persistCachedUserInfo(response)
needSetPassword.value = localStorage.getItem('needSetPassword') === 'true'
selectedShopId.value = response.shopId ? String(response.shopId) : undefined
artistCalendarAccessible.value = response.type === 3
@@ -666,6 +692,7 @@ const handleDeleteAvatar = () => {
try {
await runWithGlobalLoading(() => userApi.updateUserInfo({ avatar: '' }))
userInfo.value.avatar = ''
persistCachedUserInfo(userInfo.value)
message.success('头像删除成功')
} catch (error) {
console.error('删除头像失败:', error)
@@ -829,7 +856,7 @@ const handleLogout = () => {
} finally {
localStorage.removeItem('accessToken')
localStorage.removeItem('refreshToken')
localStorage.removeItem('userInfo')
localStorage.removeItem(USER_INFO_CACHE_KEY)
localStorage.removeItem('needSetPassword')
sessionStorage.removeItem('accessToken')
notifyShopThemeChanged()
@@ -913,7 +940,7 @@ onMounted(async () => {
.profile-topbar h1 {
margin: 2px 0 0;
color: var(--text-primary);
font-size: 24px;
font-size: 18px;
font-weight: 780;
line-height: 1.18;
}
@@ -998,7 +1025,7 @@ onMounted(async () => {
margin: 4px 0 4px;
overflow: hidden;
color: var(--text-primary);
font-size: 22px;
font-size: 20px;
font-weight: 800;
line-height: 1.18;
text-overflow: ellipsis;