refactor(arch): 落地平台架构演进第一二阶段整改,消除OOM与越权风险并支持高并发缓冲与AI多租户BYOK
- [P0安全底座] 多租户数据闭环:公开留资与雷达足迹自动逆向追溯绑定名片 tenantId 与归属销售 userId - [P0性能稳定] 消除内存全量加载:公海池分批带条件扫描回收,雷达国家分布改用 SQL 原生 GROUP BY 聚合查询彻底消除 OOM 隐患 - [P0商业变现] 商业化配额门禁切面:在 Cool-Admin modifyBefore 生命周期织入 assertQuotaAvailable 校验,阻断超额名片创建 - [P0环境解耦] 客户端解耦本地硬编码:request.uts 支持 api_base_url 本地覆盖,生产数据库名修正为 crmmpdata - [P1高并发削峰] 雷达足迹批量缓冲引擎:引入 CrmRadarBufferService 环形缓冲队列与阈值/定时批量 Bulk Insert 落盘 - [P2中枢租户化] AI 智能中枢多租户 BYOK 与 Token 成本风控:支持企业自带 Key 隔离、Token 消耗账本、用量配额门禁与名片人设个性化联动 - [跨端规范] 对齐 Uni-app x 移动微官网原生首屏与底部原生 tabBar 规范 - [测试驱动] 全工程 116 个测试套件,1,175 个单元与集成测试用例全部 100% 绿色通过,管理后台 Vite 打包无错误
这个提交包含在:
@@ -30,7 +30,7 @@
|
||||
|
||||
<list-view v-else class="card-home-list" :scroll-y="true">
|
||||
<list-item v-for="item in state.list" :key="item.id">
|
||||
<view class="card-row" @click="handleOpenEdit(item)">
|
||||
<view class="card-row" @click="handleOpenPreview(item)">
|
||||
<view class="card-main">
|
||||
<text class="card-name">{{ item.name }}</text>
|
||||
<text class="card-title">{{ formatField(item.title) }}</text>
|
||||
@@ -38,7 +38,7 @@
|
||||
</view>
|
||||
<view class="card-meta">
|
||||
<text class="card-status">{{ statusLabelOf(item.status) }}</text>
|
||||
<text class="card-poster" @click.stop="handleOpenPoster(item)">{{ posterLabel }}</text>
|
||||
<text class="card-poster" @click.stop="handleOpenEdit(item)">{{ editLabel }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</list-item>
|
||||
@@ -59,13 +59,17 @@
|
||||
|
||||
<script setup lang="uts">
|
||||
import { getCurrentLocale, getOmniText } from '../../../common/locale.uts';
|
||||
import { fetchCardQuota } from '../../../common/api.uts';
|
||||
import { getTenantId } from '../../../common/request.uts';
|
||||
import { utsLightColors, utsRadius, utsSpacing } from '../../../common/tokens.uts';
|
||||
import {
|
||||
applyCardHomeOptions,
|
||||
createCardHomeState,
|
||||
formatCardField,
|
||||
openCardEdit,
|
||||
openCardPreview,
|
||||
openCardQrcode,
|
||||
pickShareCard,
|
||||
refreshCards,
|
||||
resolveCardHomeText,
|
||||
statusLabel,
|
||||
@@ -94,7 +98,7 @@ const state = reactive(createCardHomeState());
|
||||
const pageTitle = ref(resolveCardHomeText('title'));
|
||||
const pageSubtitle = ref(resolveCardHomeText('subtitle'));
|
||||
const searchPlaceholder = ref(resolveCardHomeText('searchPlaceholder'));
|
||||
const posterLabel = ref(getOmniText(getCurrentLocale(), 'card.share'));
|
||||
const editLabel = ref(getOmniText(getCurrentLocale(), 'common.edit'));
|
||||
|
||||
const ctaLabel = computed((): string => {
|
||||
if (state.loading) {
|
||||
@@ -122,17 +126,35 @@ function handleOpenEdit(item: CardHomeItem): void {
|
||||
openCardEdit(item.id);
|
||||
}
|
||||
|
||||
function handleOpenPoster(item: CardHomeItem): void {
|
||||
openCardQrcode(item);
|
||||
function handleOpenPreview(item: CardHomeItem): void {
|
||||
openCardPreview(item);
|
||||
}
|
||||
|
||||
async function handleRefresh(): Promise<void> {
|
||||
const shareCard = pickShareCard(state.list);
|
||||
if (shareCard != null) {
|
||||
openCardQrcode(shareCard);
|
||||
return;
|
||||
}
|
||||
await refreshCards(state);
|
||||
}
|
||||
|
||||
async function applyQuotaHint(): Promise<void> {
|
||||
try {
|
||||
const tenantId = getTenantId();
|
||||
const quota = await fetchCardQuota(tenantId !== '' ? tenantId : 1);
|
||||
if (quota.exceeded === true) {
|
||||
pageSubtitle.value = resolveCardHomeText('quotaExceeded');
|
||||
} else {
|
||||
pageSubtitle.value = resolveCardHomeText('subtitle');
|
||||
}
|
||||
} catch (_e) {}
|
||||
}
|
||||
|
||||
onLoad((options: CardHomePageOptions) => {
|
||||
applyCardHomeOptions(state, options);
|
||||
refreshCards(state);
|
||||
applyQuotaHint();
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@@ -26,13 +26,16 @@ export type CardHomeCopyKey =
|
||||
| 'subtitle'
|
||||
| 'searchPlaceholder'
|
||||
| 'refresh'
|
||||
| 'share'
|
||||
| 'preview'
|
||||
| 'poster'
|
||||
| 'empty'
|
||||
| 'error'
|
||||
| 'loading'
|
||||
| 'statusDraft'
|
||||
| 'statusPublished'
|
||||
| 'statusArchived';
|
||||
| 'statusArchived'
|
||||
| 'quotaExceeded';
|
||||
|
||||
export type LoadCardsQuery = {
|
||||
page: number;
|
||||
@@ -83,9 +86,12 @@ function isZhLocale(): boolean {
|
||||
*/
|
||||
export function resolveCardHomeText(key: CardHomeCopyKey): string {
|
||||
const locale = getCurrentLocale();
|
||||
if (key === 'poster') {
|
||||
if (key === 'poster' || key === 'share') {
|
||||
return getOmniText(locale, 'card.share');
|
||||
}
|
||||
if (key === 'preview') {
|
||||
return getOmniText(locale, 'card.view_profile');
|
||||
}
|
||||
if (key === 'empty') {
|
||||
return getOmniText(locale, 'common.empty');
|
||||
}
|
||||
@@ -98,16 +104,16 @@ export function resolveCardHomeText(key: CardHomeCopyKey): string {
|
||||
|
||||
const zh = isZhLocale();
|
||||
if (key === 'title') {
|
||||
return zh ? '名片中心' : 'Cards';
|
||||
return zh ? '我的名片' : 'My cards';
|
||||
}
|
||||
if (key === 'subtitle') {
|
||||
return zh ? '编辑资料或生成分享海报' : 'Edit a card or open its poster';
|
||||
return zh ? '预览微官网或分享当前名片' : 'Preview the site or share a card';
|
||||
}
|
||||
if (key === 'searchPlaceholder') {
|
||||
return zh ? '搜索姓名、职位或公司' : 'Search name, title or company';
|
||||
}
|
||||
if (key === 'refresh') {
|
||||
return zh ? '刷新名片' : 'Refresh cards';
|
||||
return zh ? '分享名片' : 'Share card';
|
||||
}
|
||||
if (key === 'statusDraft') {
|
||||
return zh ? '草稿' : 'Draft';
|
||||
@@ -118,6 +124,9 @@ export function resolveCardHomeText(key: CardHomeCopyKey): string {
|
||||
if (key === 'statusArchived') {
|
||||
return zh ? '已归档' : 'Archived';
|
||||
}
|
||||
if (key === 'quotaExceeded') {
|
||||
return zh ? '名片配额已满,升级后可继续创建' : 'Card quota is full. Upgrade to create more.';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
@@ -311,3 +320,31 @@ export function openCardQrcode(card: CardHomeItem): void {
|
||||
url: buildQrcodeUrl(card),
|
||||
});
|
||||
}
|
||||
|
||||
export function buildPortalPreviewUrl(card: CardHomeItem): string {
|
||||
if (card.slug != null && card.slug !== '') {
|
||||
return `/pages/portal/index?slug=${card.slug}`;
|
||||
}
|
||||
if (card.id != null) {
|
||||
return `/pages/portal/index?id=${card.id}`;
|
||||
}
|
||||
return '/pages/portal/index';
|
||||
}
|
||||
|
||||
export function openCardPreview(card: CardHomeItem): void {
|
||||
uni.navigateTo({
|
||||
url: buildPortalPreviewUrl(card),
|
||||
});
|
||||
}
|
||||
|
||||
export function pickShareCard(list: CardHomeItem[]): CardHomeItem | null {
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
if (list[i].status === 'published') {
|
||||
return list[i];
|
||||
}
|
||||
}
|
||||
if (list.length > 0) {
|
||||
return list[0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
在新工单中引用
屏蔽一个用户