修复:统一后台登录店铺展示和中文提示
This commit is contained in:
+14
-10
@@ -1,23 +1,27 @@
|
||||
<template>
|
||||
<el-config-provider>
|
||||
<div class="app-container">
|
||||
<BottomNav v-if="!isHiddenNav" />
|
||||
<div class="page-content" :class="{ 'no-nav-padding': isHiddenNav }">
|
||||
<router-view v-slot="{ Component }">
|
||||
<transition name="page-fade" mode="out-in">
|
||||
<component :is="Component" :key="route.path" />
|
||||
</transition>
|
||||
</router-view>
|
||||
<ConfigProvider :locale="antdLocale">
|
||||
<div class="app-container">
|
||||
<BottomNav v-if="!isHiddenNav" />
|
||||
<div class="page-content" :class="{ 'no-nav-padding': isHiddenNav }">
|
||||
<router-view v-slot="{ Component }">
|
||||
<transition name="page-fade" mode="out-in">
|
||||
<component :is="Component" :key="route.path" />
|
||||
</transition>
|
||||
</router-view>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ConfigProvider>
|
||||
</el-config-provider>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, provide, watch } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { ConfigProvider } from 'ant-design-vue'
|
||||
import BottomNav from './components/BottomNav.vue'
|
||||
import { cartApi } from './api/cart'
|
||||
import antdLocale from './config/antdv-locale'
|
||||
|
||||
const route = useRoute()
|
||||
|
||||
@@ -124,4 +128,4 @@ loadCartCount()
|
||||
.page-fade-leave-to {
|
||||
opacity: 0;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
@@ -93,7 +93,7 @@ adminApi.interceptors.response.use(
|
||||
export interface AdminLoginRequest {
|
||||
account: string
|
||||
password: string
|
||||
shopId?: number
|
||||
shopId?: string | number
|
||||
}
|
||||
|
||||
export interface AdminLoginResponse {
|
||||
|
||||
@@ -13,8 +13,9 @@ export interface ShopVO {
|
||||
}
|
||||
|
||||
export interface ShopSimpleVO {
|
||||
id: number
|
||||
name: string
|
||||
id: string | number
|
||||
shopName?: string
|
||||
name?: string
|
||||
}
|
||||
|
||||
export interface ListShopsParams {
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
import zhCN from 'ant-design-vue/es/locale/zh_CN'
|
||||
|
||||
const baseCalendar = (zhCN.Calendar || { lang: {} }) as any
|
||||
const baseDatePicker = (zhCN.DatePicker || { lang: {}, timePickerLocale: {} }) as any
|
||||
const baseTimePicker = (zhCN.TimePicker || {}) as any
|
||||
|
||||
const antdLocale: any = {
|
||||
...zhCN,
|
||||
Modal: {
|
||||
...zhCN.Modal,
|
||||
okText: '确认',
|
||||
cancelText: zhCN.Modal?.cancelText || '取消',
|
||||
justOkText: zhCN.Modal?.justOkText || '知道了'
|
||||
},
|
||||
Popconfirm: {
|
||||
...zhCN.Popconfirm,
|
||||
okText: '确认',
|
||||
cancelText: zhCN.Popconfirm?.cancelText || '取消'
|
||||
},
|
||||
Calendar: {
|
||||
...baseCalendar,
|
||||
lang: {
|
||||
...baseCalendar.lang,
|
||||
ok: '确认',
|
||||
now: '现在时间'
|
||||
}
|
||||
},
|
||||
DatePicker: {
|
||||
...baseDatePicker,
|
||||
lang: {
|
||||
...baseDatePicker.lang,
|
||||
ok: '确认',
|
||||
now: '现在时间'
|
||||
},
|
||||
timePickerLocale: {
|
||||
...baseDatePicker.timePickerLocale,
|
||||
now: '现在时间'
|
||||
}
|
||||
},
|
||||
TimePicker: {
|
||||
...baseTimePicker,
|
||||
now: '现在时间'
|
||||
}
|
||||
}
|
||||
|
||||
export default antdLocale
|
||||
@@ -46,7 +46,7 @@
|
||||
<span>{{ item.quantity }}</span>
|
||||
<a-button size="small" :disabled="item.quantity >= 99" @click="changeQuantity(item, 1)">+</a-button>
|
||||
</div>
|
||||
<a-popconfirm title="确定删除吗?" ok-text="确定" cancel-text="取消" @confirm="removeItem(item)">
|
||||
<a-popconfirm title="确定删除吗?" ok-text="确认" cancel-text="取消" @confirm="removeItem(item)">
|
||||
<a-button type="text" danger size="small">
|
||||
<DeleteOutlined />
|
||||
</a-button>
|
||||
|
||||
@@ -442,7 +442,7 @@ const handleLogout = () => {
|
||||
Modal.confirm({
|
||||
title: '确认退出登录',
|
||||
content: '确定要退出登录吗?',
|
||||
okText: '确定',
|
||||
okText: '确认',
|
||||
cancelText: '取消',
|
||||
onOk: async () => {
|
||||
try {
|
||||
@@ -1027,4 +1027,4 @@ const loadWishlistCount = async () => {
|
||||
background: #f5f5f5;
|
||||
color: #8b8b9a;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
@@ -96,13 +96,16 @@ const { loadUserPermissions } = usePermission()
|
||||
const formState = reactive({
|
||||
account: '',
|
||||
password: '',
|
||||
shopId: undefined as number | undefined
|
||||
shopId: undefined as string | undefined
|
||||
})
|
||||
|
||||
const getShopIdValue = (shop: ShopSimpleVO) => String(shop.id ?? '')
|
||||
const getShopLabel = (shop: ShopSimpleVO) => String(shop.shopName || shop.name || `店铺 ${shop.id}`)
|
||||
|
||||
const shopOptions = computed(() =>
|
||||
shops.value.map(shop => ({
|
||||
label: shop.name,
|
||||
value: shop.id
|
||||
label: getShopLabel(shop),
|
||||
value: getShopIdValue(shop)
|
||||
}))
|
||||
)
|
||||
const hasAvailableShops = computed(() => shopOptions.value.length > 0)
|
||||
@@ -135,7 +138,7 @@ const restoreLoginShop = () => {
|
||||
try {
|
||||
const parsed = JSON.parse(cached)
|
||||
if (parsed?.shopId) {
|
||||
formState.shopId = parsed.shopId
|
||||
formState.shopId = String(parsed.shopId)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('恢复后台登录店铺失败:', error)
|
||||
@@ -150,12 +153,21 @@ const loadShops = async () => {
|
||||
formState.shopId = undefined
|
||||
return
|
||||
}
|
||||
if (!formState.shopId && shops.value.length === 1) {
|
||||
|
||||
const hasMatchedShop = shopOptions.value.some(option => option.value === formState.shopId)
|
||||
if (hasMatchedShop) {
|
||||
return
|
||||
}
|
||||
|
||||
if (shops.value.length === 1) {
|
||||
const [onlyShop] = shops.value
|
||||
if (onlyShop) {
|
||||
formState.shopId = onlyShop.id
|
||||
formState.shopId = getShopIdValue(onlyShop)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
formState.shopId = undefined
|
||||
} catch (error) {
|
||||
console.error('获取登录店铺列表失败:', error)
|
||||
message.error('店铺列表加载失败,请刷新后重试')
|
||||
|
||||
Reference in New Issue
Block a user