修复:统一后台登录店铺展示和中文提示
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-config-provider>
|
<el-config-provider>
|
||||||
|
<ConfigProvider :locale="antdLocale">
|
||||||
<div class="app-container">
|
<div class="app-container">
|
||||||
<BottomNav v-if="!isHiddenNav" />
|
<BottomNav v-if="!isHiddenNav" />
|
||||||
<div class="page-content" :class="{ 'no-nav-padding': isHiddenNav }">
|
<div class="page-content" :class="{ 'no-nav-padding': isHiddenNav }">
|
||||||
@@ -10,14 +11,17 @@
|
|||||||
</router-view>
|
</router-view>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</ConfigProvider>
|
||||||
</el-config-provider>
|
</el-config-provider>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, ref, provide, watch } from 'vue'
|
import { computed, ref, provide, watch } from 'vue'
|
||||||
import { useRoute } from 'vue-router'
|
import { useRoute } from 'vue-router'
|
||||||
|
import { ConfigProvider } from 'ant-design-vue'
|
||||||
import BottomNav from './components/BottomNav.vue'
|
import BottomNav from './components/BottomNav.vue'
|
||||||
import { cartApi } from './api/cart'
|
import { cartApi } from './api/cart'
|
||||||
|
import antdLocale from './config/antdv-locale'
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
|
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ adminApi.interceptors.response.use(
|
|||||||
export interface AdminLoginRequest {
|
export interface AdminLoginRequest {
|
||||||
account: string
|
account: string
|
||||||
password: string
|
password: string
|
||||||
shopId?: number
|
shopId?: string | number
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AdminLoginResponse {
|
export interface AdminLoginResponse {
|
||||||
|
|||||||
@@ -13,8 +13,9 @@ export interface ShopVO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface ShopSimpleVO {
|
export interface ShopSimpleVO {
|
||||||
id: number
|
id: string | number
|
||||||
name: string
|
shopName?: string
|
||||||
|
name?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ListShopsParams {
|
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>
|
<span>{{ item.quantity }}</span>
|
||||||
<a-button size="small" :disabled="item.quantity >= 99" @click="changeQuantity(item, 1)">+</a-button>
|
<a-button size="small" :disabled="item.quantity >= 99" @click="changeQuantity(item, 1)">+</a-button>
|
||||||
</div>
|
</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">
|
<a-button type="text" danger size="small">
|
||||||
<DeleteOutlined />
|
<DeleteOutlined />
|
||||||
</a-button>
|
</a-button>
|
||||||
|
|||||||
@@ -442,7 +442,7 @@ const handleLogout = () => {
|
|||||||
Modal.confirm({
|
Modal.confirm({
|
||||||
title: '确认退出登录',
|
title: '确认退出登录',
|
||||||
content: '确定要退出登录吗?',
|
content: '确定要退出登录吗?',
|
||||||
okText: '确定',
|
okText: '确认',
|
||||||
cancelText: '取消',
|
cancelText: '取消',
|
||||||
onOk: async () => {
|
onOk: async () => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -96,13 +96,16 @@ const { loadUserPermissions } = usePermission()
|
|||||||
const formState = reactive({
|
const formState = reactive({
|
||||||
account: '',
|
account: '',
|
||||||
password: '',
|
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(() =>
|
const shopOptions = computed(() =>
|
||||||
shops.value.map(shop => ({
|
shops.value.map(shop => ({
|
||||||
label: shop.name,
|
label: getShopLabel(shop),
|
||||||
value: shop.id
|
value: getShopIdValue(shop)
|
||||||
}))
|
}))
|
||||||
)
|
)
|
||||||
const hasAvailableShops = computed(() => shopOptions.value.length > 0)
|
const hasAvailableShops = computed(() => shopOptions.value.length > 0)
|
||||||
@@ -135,7 +138,7 @@ const restoreLoginShop = () => {
|
|||||||
try {
|
try {
|
||||||
const parsed = JSON.parse(cached)
|
const parsed = JSON.parse(cached)
|
||||||
if (parsed?.shopId) {
|
if (parsed?.shopId) {
|
||||||
formState.shopId = parsed.shopId
|
formState.shopId = String(parsed.shopId)
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('恢复后台登录店铺失败:', error)
|
console.error('恢复后台登录店铺失败:', error)
|
||||||
@@ -150,12 +153,21 @@ const loadShops = async () => {
|
|||||||
formState.shopId = undefined
|
formState.shopId = undefined
|
||||||
return
|
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
|
const [onlyShop] = shops.value
|
||||||
if (onlyShop) {
|
if (onlyShop) {
|
||||||
formState.shopId = onlyShop.id
|
formState.shopId = getShopIdValue(onlyShop)
|
||||||
}
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
formState.shopId = undefined
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('获取登录店铺列表失败:', error)
|
console.error('获取登录店铺列表失败:', error)
|
||||||
message.error('店铺列表加载失败,请刷新后重试')
|
message.error('店铺列表加载失败,请刷新后重试')
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
# 2026-03-21 后台登录店铺展示与中文提示修复
|
||||||
|
|
||||||
|
## 本轮问题
|
||||||
|
|
||||||
|
- 后台登录页“登录店铺”下拉显示成了店铺 ID,而不是店铺名称。
|
||||||
|
- Ant Design Vue 的部分默认文案仍显示英文或默认中文口径不统一,例如日期面板里的 `Now`、确认按钮文案等。
|
||||||
|
|
||||||
|
## 本轮修改
|
||||||
|
|
||||||
|
### 1. 后台登录店铺下拉改为稳定显示店名
|
||||||
|
|
||||||
|
- 更新 [AdminLoginView.vue](/E:/code/xiaowang/Frontend/src/views/admin/AdminLoginView.vue)
|
||||||
|
- 更新 [shop.ts](/E:/code/xiaowang/Frontend/src/api/shop.ts)
|
||||||
|
- 更新 [admin.ts](/E:/code/xiaowang/Frontend/src/api/admin.ts)
|
||||||
|
- 调整内容:
|
||||||
|
- `ShopSimpleVO` 兼容后端实际返回的 `shopName`
|
||||||
|
- 登录页下拉展示优先读取 `shop.shopName`,兼容旧字段 `name`
|
||||||
|
- 登录页 `shopId` 改为字符串兼容模式,避免超长店铺 ID 在前端下拉里回显异常
|
||||||
|
- 恢复缓存店铺时会按当前选项重新匹配,不再把原始 ID 直接显示到选择框
|
||||||
|
|
||||||
|
### 2. Ant Design Vue 全局提示改为中文口径
|
||||||
|
|
||||||
|
- 新增 [antdv-locale.ts](/E:/code/xiaowang/Frontend/src/config/antdv-locale.ts)
|
||||||
|
- 更新 [App.vue](/E:/code/xiaowang/Frontend/src/App.vue)
|
||||||
|
- 调整内容:
|
||||||
|
- 全局接入 `ConfigProvider`
|
||||||
|
- 默认确认按钮统一改为 `确认`
|
||||||
|
- 默认取消按钮统一保持 `取消`
|
||||||
|
- 日期/时间面板中的 `Now` 统一改为 `现在时间`
|
||||||
|
- 日期面板中的 `OK` 统一改为 `确认`
|
||||||
|
|
||||||
|
### 3. 个别手写按钮文案同步统一
|
||||||
|
|
||||||
|
- 更新 [CartView.vue](/E:/code/xiaowang/Frontend/src/views/CartView.vue)
|
||||||
|
- 更新 [ProfileView.vue](/E:/code/xiaowang/Frontend/src/views/ProfileView.vue)
|
||||||
|
- 调整内容:
|
||||||
|
- 购物车删除确认按钮由 `确定` 改为 `确认`
|
||||||
|
- 个人中心退出登录弹窗确认按钮由 `确定` 改为 `确认`
|
||||||
|
|
||||||
|
## 结果
|
||||||
|
|
||||||
|
- 后台登录页的店铺下拉会优先显示真实店名,不再直接显示店铺 ID。
|
||||||
|
- 日期时间选择器、确认弹窗等默认提示统一切换为中文口径。
|
||||||
|
- `Now` 文案已按本轮要求改成 `现在时间`。
|
||||||
|
|
||||||
|
## 验证
|
||||||
|
|
||||||
|
- `Frontend` 执行 `npm run build` 通过
|
||||||
Reference in New Issue
Block a user