feat: 同步管理端、用户端与后端业务,并接通线上 Web 接口

补齐平台订阅、外部登录、CRM 同步与用户端页面;Nginx 转发用户端接口,登录页使用 Google 与 Apple 标志。

Co-authored-by: Cursor <cursoragent@cursor.com>
这个提交包含在:
wikiboss
2026-09-23 18:01:47 +08:00
父节点 8ea9c25386
当前提交 62e0ae4435
共有 227 个文件被更改,包括 21855 次插入 和 5264 次删除

文件差异内容过多而无法显示 加载差异

查看文件

@@ -10,6 +10,12 @@ import {
setAppLocale,
getOmniText,
} from '../../../common/locale.uts';
import {
CardProfile,
OwnerPageData,
OwnerPageQuery,
} from '../../../common/types.uts';
import { fetchOwnerCardPage } from '../../../common/api.uts';
export { PORTAL_LOCALE_STORAGE_KEY };
@@ -18,6 +24,8 @@ export type UserProfileAccount = {
company: string;
department: string;
avatar: string;
cardId: string;
cardSlug: string;
};
export type NotificationSettings = {
@@ -74,13 +82,104 @@ function defaultStorage(): StorageApi {
export function getDefaultAccount(): UserProfileAccount {
return {
name: 'Alex Vance',
company: 'Nexus Tech Global',
department: 'Overseas Business Dept',
avatar: 'https://images.unsplash.com/photo-1534528741775-53994a69daeb?auto=format&fit=crop&w=256&q=80',
name: '',
company: '',
department: '',
avatar: '',
cardId: '',
cardSlug: '',
};
}
export type LoadProfileAccountApi = {
fetchOwnerCardPage: (
query: OwnerPageQuery
) => Promise<OwnerPageData<CardProfile>>;
};
/**
* 读取接口可选组织字段:仅 trim,缺失或空白一律空串
*/
export function readOptionalOrgText(value: string | null | undefined): string {
if (value == null) {
return '';
}
return String(value).trim();
}
/**
* 公司/部门展示:有值原样返回,缺失或空串走 i18n 空态
*/
export function displayOrgField(value: string | null | undefined): string {
const text = readOptionalOrgText(value);
if (text === '') {
return resolveProfileText('empty');
}
return text;
}
/**
* 接口失败或无数据时清空公司与部门,禁止保留上次/示例值
*/
export function clearOrgFields(state: ProfileState): void {
state.account.company = '';
state.account.department = '';
}
function readDepartmentFromCard(card: CardProfile): string {
const extra = card as CardProfile & { department?: string | null };
return readOptionalOrgText(extra.department);
}
/**
* 从名片分页接口拉取当前用户公司/部门(仅使用接口返回字段)
*/
export async function loadOwnerProfileAccount(
state: ProfileState,
api?: LoadProfileAccountApi
): Promise<boolean> {
const fetchPage =
api != null ? api.fetchOwnerCardPage : fetchOwnerCardPage;
state.loading = true;
try {
const data = await fetchPage({ page: 1, size: 1 } as OwnerPageQuery);
const list = data.list != null ? data.list : [];
if (list.length === 0) {
clearOrgFields(state);
state.account.cardId = '';
state.account.cardSlug = '';
state.errorMessage = '';
state.loading = false;
return true;
}
const card = list[0];
state.account.company = readOptionalOrgText(card.company);
state.account.department = readDepartmentFromCard(card);
state.account.cardId = card.id != null ? String(card.id) : '';
const slugText = card.slug != null ? String(card.slug).trim() : '';
state.account.cardSlug = slugText;
if (card.name != null && String(card.name).trim() !== '') {
state.account.name = String(card.name).trim();
}
if (card.avatarUrl != null && String(card.avatarUrl).trim() !== '') {
state.account.avatar = String(card.avatarUrl).trim();
}
state.errorMessage = '';
state.loading = false;
return true;
} catch (err: unknown) {
clearOrgFields(state);
state.account.cardId = '';
state.account.cardSlug = '';
const msg = err instanceof Error && err.message !== ''
? err.message
: resolveProfileText('error');
state.errorMessage = msg;
state.loading = false;
return false;
}
}
export function getDefaultNotifications(): NotificationSettings {
return {
radarPush: true,
@@ -90,9 +189,9 @@ export function getDefaultNotifications(): NotificationSettings {
export function getDefaultMetrics(): ProfileMetrics {
return {
cardsCount: 6,
visitorsCount: 128,
leadsCount: 24,
cardsCount: 0,
visitorsCount: 0,
leadsCount: 0,
};
}
@@ -127,7 +226,7 @@ export function saveProfileMetrics(metrics: ProfileMetrics, storage?: StorageApi
}
export function createProfileState(locale?: OmniLocale): ProfileState {
const currentLocale = locale != null && locale !== '' ? locale : getCurrentLocale();
const currentLocale = locale != null ? locale : getCurrentLocale();
return {
account: getDefaultAccount(),
notifications: getDefaultNotifications(),
@@ -166,25 +265,32 @@ export function loadProfileSettings(storage?: StorageApi): ProfileState {
const parsedAccount = safeParseJson<Record<string, unknown>>(rawAccount);
if (parsedAccount != null && typeof parsedAccount === 'object') {
const defaultAcc = getDefaultAccount();
const safeName = typeof parsedAccount.name === 'string' && parsedAccount.name.trim() !== ''
const safeName = typeof parsedAccount.name === 'string'
? parsedAccount.name.trim()
: defaultAcc.name;
const safeCompany = typeof parsedAccount.company === 'string' && parsedAccount.company.trim() !== ''
: '';
const safeCompany = typeof parsedAccount.company === 'string'
? parsedAccount.company.trim()
: defaultAcc.company;
const safeDept = typeof parsedAccount.department === 'string' && parsedAccount.department.trim() !== ''
: '';
const safeDept = typeof parsedAccount.department === 'string'
? parsedAccount.department.trim()
: defaultAcc.department;
const safeAvatar = typeof parsedAccount.avatar === 'string' && parsedAccount.avatar.trim() !== ''
: '';
const safeAvatar = typeof parsedAccount.avatar === 'string'
? parsedAccount.avatar.trim()
: defaultAcc.avatar;
: '';
const safeCardId = typeof parsedAccount.cardId === 'string'
? parsedAccount.cardId.trim()
: '';
const safeCardSlug = typeof parsedAccount.cardSlug === 'string'
? parsedAccount.cardSlug.trim()
: '';
state.account = {
name: safeName,
company: safeCompany,
department: safeDept,
avatar: safeAvatar,
cardId: safeCardId,
cardSlug: safeCardSlug,
};
}
} catch (_e) {
@@ -418,6 +524,9 @@ export function resolveProfileText(key: string): string {
if (key === 'error') {
return getOmniText(locale, 'common.error');
}
if (key === 'empty') {
return getOmniText(locale, 'common.empty');
}
const isZh = locale === 'zh-CN';
@@ -507,25 +616,25 @@ export function resolveProfileText(key: string): string {
case 'confirmLogoutContent':
return isZh ? '确定要退出当前账号吗?' : 'Are you sure you want to sign out?';
case 'myCardsSub':
return isZh ? '查看与出示专属数字名片' : 'View and present digital cards';
return isZh ? '查看和切换名片' : 'View and switch cards';
case 'cardEditSub':
return isZh ? '修改履历、职业信息与社交矩阵' : 'Update profile and social links';
return isZh ? '改姓名、职位和联系方式' : 'Name, role, and contact details';
case 'productCasesSub':
return isZh ? '展示产品与案例' : 'Portfolio and cases';
return isZh ? '名片上展示的案例' : 'Cases shown on your card';
case 'articleDynamicsSub':
return isZh ? '发布业务动态与文章' : 'Publish dynamic posts';
return isZh ? '名片上展示的文章' : 'Articles shown on your card';
case 'sharePosterSub':
return isZh ? '展会专属扫码展台与立牌' : 'Expo QR poster and stand';
return isZh ? '全屏出示二维码' : 'Full-screen QR';
case 'exchangeHallSub':
return isZh ? '面对面扫码或碰卡互换' : 'Face-to-face card exchange';
return isZh ? '当面交换名片' : 'Exchange in person';
case 'nfcScanSub':
return isZh ? '新实体卡贴碰写入绑定' : 'Tap and bind new NFC card';
return isZh ? '把实体卡绑到名片' : 'Bind a physical card';
case 'nfcModeSub':
return isZh ? '展会与拜访场景切换' : 'Switch expo and meeting modes';
return isZh ? '更换这张卡打开的页面' : 'Choose what the card opens';
case 'nfcSecuritySub':
return isZh ? '防盗刷保护与远程紧急冻结' : 'Remote freeze and theft protection';
return isZh ? '卡片丢失时远程停用' : 'Freeze a lost card';
case 'teamBriefingSub':
return isZh ? '全员名片分发与获客大盘战报' : 'Team leads and distribution briefing';
return isZh ? '团队今天的获客' : "Today's team results";
case 'avatarActionSheetTitle':
return isZh ? '头像管理' : 'Avatar Options';
case 'avatarActionPreview':
@@ -536,8 +645,12 @@ export function resolveProfileText(key: string): string {
return isZh ? '移除当前头像' : 'Remove Avatar';
case 'aboutApp':
return isZh ? '关于 OmniCard' : 'About OmniCard';
case 'aboutBody':
return isZh ? '数字名片、微官网和访客雷达' : 'Digital cards, microsites, and visitor radar';
case 'confirm':
return isZh ? '知道了' : 'OK';
case 'appVersion':
return isZh ? '企业旗舰版 v1.2.0' : 'Enterprise v1.2.0';
return 'OmniCard';
case 'securitySafe':
return isZh ? '保护中' : 'Protected';
case 'livePulse':