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