功能:完善门店能力与用户安全配置

This commit is contained in:
xiaowang
2026-05-18 10:04:57 +08:00
parent 4563dd2538
commit 3797938616
356 changed files with 24983 additions and 1858 deletions
@@ -75,6 +75,10 @@
</template>
<script setup lang="ts">
/**
* ProfileView page script.
* Call guide: the template binds the reactive state below, and the methods are triggered by button clicks, lifecycle hooks, or router events.
*/
import { computed, onMounted, ref } from 'vue'
import { useRouter } from 'vue-router'
import { message, Modal } from 'ant-design-vue'
@@ -91,15 +95,24 @@ import {
const router = useRouter()
const { userPermissions, loadUserPermissions, clearPermissions } = usePermission()
/** userInfo is a reactive state variable used by the template and event handlers. */
const userInfo = ref(loadCachedAdminUserInfo())
/** selectedShopId is a reactive state variable used by the template and event handlers. */
const selectedShopId = ref(userInfo.value?.shopId ? String(userInfo.value.shopId) : undefined)
/** shopSwitchLoading is a reactive state variable used by the template and event handlers. */
const shopSwitchLoading = ref(false)
/** currentShopName is a reactive state variable used by the template and event handlers. */
const currentShopName = computed(() => getAdminCurrentShopName(userInfo.value))
/** roleLabel is a reactive state variable used by the template and event handlers. */
const roleLabel = computed(() => getAdminRoleLabel(userInfo.value?.type))
/** shopOptions is a reactive state variable used by the template and event handlers. */
const shopOptions = computed(() => getAdminShopOptions(userInfo.value))
/** shopSelectOptions is a reactive state variable used by the template and event handlers. */
const shopSelectOptions = computed(() => shopOptions.value.map(shop => ({ label: shop.name, value: shop.id })))
/** permissionCount is a reactive state variable used by the template and event handlers. */
const permissionCount = computed(() => userPermissions.value.length)
/** shopScopeText is a reactive state variable used by the template and event handlers. */
const shopScopeText = computed(() => {
if (!shopOptions.value.length) {
return '游客模式'
@@ -107,6 +120,7 @@ const shopScopeText = computed(() => {
return shopOptions.value.map(item => item.name).join(' / ')
})
/** persistAdminSession is a local helper used by this page script. */
const persistAdminSession = (payload: any) => {
localStorage.setItem('adminAccessToken', payload.accessToken)
localStorage.setItem('adminRefreshToken', payload.refreshToken)
@@ -114,11 +128,13 @@ const persistAdminSession = (payload: any) => {
sessionStorage.setItem('adminAccessToken', payload.accessToken)
}
/** refreshLocalUserInfo is a local helper used by this page script. */
const refreshLocalUserInfo = () => {
userInfo.value = loadCachedAdminUserInfo()
selectedShopId.value = userInfo.value?.shopId ? String(userInfo.value.shopId) : undefined
}
/** handleShopChange is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const handleShopChange = async (shopId: unknown) => {
if (typeof shopId !== 'string' && typeof shopId !== 'number') {
return
@@ -145,6 +161,7 @@ const handleShopChange = async (shopId: unknown) => {
}
}
/** handleLogout is a local helper used by this page script. */
const handleLogout = () => {
Modal.confirm({
title: '确认退出登录',