mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-23 23:19:19 +08:00
feat: 概览标签统一为种类「名称」格式
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
/**
|
||||
* 概览页标签标题:有实体名则优先覆盖菜单默认标题(如「商品概览」)。
|
||||
* 概览页标签标题:形如 店铺「名称」;有实体名时覆盖菜单默认标题。
|
||||
*/
|
||||
export function formatOverviewTabTitle(
|
||||
kind: string,
|
||||
name: null | string | undefined,
|
||||
fallback: string,
|
||||
maxLen = 18,
|
||||
fallbackName: string,
|
||||
maxNameLen = 16,
|
||||
): string {
|
||||
const raw = (name ?? '').trim() || fallback;
|
||||
if (raw.length <= maxLen) return raw;
|
||||
return `${raw.slice(0, Math.max(1, maxLen - 1))}…`;
|
||||
let raw = (name ?? '').trim() || fallbackName;
|
||||
if (raw.length > maxNameLen) {
|
||||
raw = `${raw.slice(0, Math.max(1, maxNameLen - 1))}…`;
|
||||
}
|
||||
return `${kind}「${raw}」`;
|
||||
}
|
||||
|
||||
@@ -70,8 +70,9 @@ async function syncCategoryTabTitle(name?: null | string) {
|
||||
if (!isCategoryOverviewRoute()) return;
|
||||
await setTabTitle(
|
||||
formatOverviewTabTitle(
|
||||
'品类',
|
||||
name,
|
||||
categoryId.value ? `品类 #${categoryId.value}` : '品类概览',
|
||||
categoryId.value ? `#${categoryId.value}` : '概览',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -70,8 +70,9 @@ async function syncPlatformTabTitle(name?: null | string) {
|
||||
if (!isPlatformOverviewRoute()) return;
|
||||
await setTabTitle(
|
||||
formatOverviewTabTitle(
|
||||
'平台',
|
||||
name,
|
||||
platformCode.value ? platformCode.value : '平台概览',
|
||||
platformCode.value || '概览',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -67,7 +67,11 @@ const productId = computed(() => {
|
||||
async function syncProductTabTitle(name?: null | string) {
|
||||
if (!isProductOverviewRoute()) return;
|
||||
await setTabTitle(
|
||||
formatOverviewTabTitle(name, productId.value ? `商品 #${productId.value}` : '商品概览'),
|
||||
formatOverviewTabTitle(
|
||||
'商品',
|
||||
name,
|
||||
productId.value ? `#${productId.value}` : '概览',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +78,11 @@ const shopId = computed(() => {
|
||||
async function syncShopTabTitle(name?: null | string) {
|
||||
if (!isShopOverviewRoute()) return;
|
||||
await setTabTitle(
|
||||
formatOverviewTabTitle(name, shopId.value ? `店铺 #${shopId.value}` : '店铺概览'),
|
||||
formatOverviewTabTitle(
|
||||
'店铺',
|
||||
name,
|
||||
shopId.value ? `#${shopId.value}` : '概览',
|
||||
),
|
||||
);
|
||||
}
|
||||
const loading = ref(false);
|
||||
|
||||
Reference in New Issue
Block a user