feat(portal): 优化微官网首页名片主客态自适应与主CTA动态切换

这个提交包含在:
wikiboss
2026-09-21 15:05:10 +08:00
父节点 43d4ec42bf
当前提交 3243979169
共有 4 个文件被更改,包括 837 次插入 和 232 次删除

查看文件

@@ -11,6 +11,7 @@ import {
} from '../../../common/types.uts';
import { fetchOwnerCardPage } from '../../../common/api.uts';
import { getCurrentLocale, getOmniText } from '../../../common/locale.uts';
import { setOwnerCardIds } from '../../portal/usePortal.uts';
export type CardHomeItem = {
id?: string | number;
@@ -86,7 +87,7 @@ function isZhLocale(): boolean {
*/
export function resolveCardHomeText(key: CardHomeCopyKey): string {
const locale = getCurrentLocale();
if (key === 'poster' || key === 'share') {
if (key === 'share') {
return getOmniText(locale, 'card.share');
}
if (key === 'preview') {
@@ -103,6 +104,9 @@ export function resolveCardHomeText(key: CardHomeCopyKey): string {
}
const zh = isZhLocale();
if (key === 'poster') {
return zh ? '分享海报' : 'Share poster';
}
if (key === 'title') {
return zh ? '我的名片' : 'My cards';
}
@@ -113,7 +117,7 @@ export function resolveCardHomeText(key: CardHomeCopyKey): string {
return zh ? '搜索姓名、职位或公司' : 'Search name, title or company';
}
if (key === 'refresh') {
return zh ? '分享名片' : 'Share card';
return zh ? '刷新' : 'Refresh';
}
if (key === 'statusDraft') {
return zh ? '草稿' : 'Draft';
@@ -204,8 +208,19 @@ export async function loadCards(
const data = await fetchPage(sanitizeCardQuery(query));
const rawList = data.list != null ? data.list : [];
const list: CardHomeItem[] = [];
const ownerIds: string[] = [];
for (let i = 0; i < rawList.length; i++) {
list.push(toCardHomeItem(rawList[i]));
const item = toCardHomeItem(rawList[i]);
list.push(item);
if (item.id != null) {
ownerIds.push(String(item.id));
}
if (item.slug != null && item.slug !== '') {
ownerIds.push(item.slug);
}
}
if (ownerIds.length > 0) {
setOwnerCardIds(ownerIds);
}
const pagination =
data.pagination != null
@@ -323,12 +338,12 @@ export function openCardQrcode(card: CardHomeItem): void {
export function buildPortalPreviewUrl(card: CardHomeItem): string {
if (card.slug != null && card.slug !== '') {
return `/pages/portal/index?slug=${card.slug}`;
return `/pages/portal/index?slug=${card.slug}&mode=owner`;
}
if (card.id != null) {
return `/pages/portal/index?id=${card.id}`;
return `/pages/portal/index?id=${card.id}&mode=owner`;
}
return '/pages/portal/index';
return '/pages/portal/index?mode=owner';
}
export function openCardPreview(card: CardHomeItem): void {