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 打包无错误
这个提交包含在:
wikiboss
2026-09-21 11:14:10 +08:00
父节点 e73c15bd22
当前提交 6c3d5d323a
共有 637 个文件被更改,包括 4731 次插入 和 56919 次删除

查看文件

@@ -25,8 +25,15 @@
<text class="brand-subtitle">{{ t('subtitle') }}</text>
</view>
<!-- 2. 极简分段控制器 (Segmented Control) -->
<!-- 2. 极简分段控制器 (Segmented Control: 账号密码 / 手机号 / 邮箱) -->
<view class="segmented-box">
<view
class="segment-item"
:class="{ 'segment-active': state.tab === 'password' }"
@click="handleSwitchTab('password')"
>
<text class="segment-text">{{ t('tabPassword') }}</text>
</view>
<view
class="segment-item"
:class="{ 'segment-active': state.tab === 'phone' }"
@@ -44,8 +51,35 @@
</view>
<!-- 3. 表单主体 -->
<view v-if="state.tab === 'phone'" class="form-section">
<!-- 手机号与区号一体化输入组 -->
<!-- 3.1 账号密码真实登录面板 (便于测试与前后端对齐) -->
<view v-if="state.tab === 'password'" class="form-section">
<view class="form-field">
<text class="field-label">{{ t('usernamePlaceholder') }}</text>
<input
class="input-control text-input"
type="text"
v-model="state.username"
:placeholder="t('usernamePlaceholder')"
:disabled="state.submitting"
/>
</view>
<view class="form-field">
<text class="field-label">{{ t('passwordPlaceholder') }}</text>
<input
class="input-control text-input"
type="password"
v-model="state.password"
:placeholder="t('passwordPlaceholder')"
:disabled="state.submitting"
/>
</view>
<view class="test-account-badge" @click="handleAutofillTest">
<text class="test-account-text">{{ t('testAccountTip') }}</text>
</view>
</view>
<!-- 3.2 国际手机号验证码面板 -->
<view v-else-if="state.tab === 'phone'" class="form-section">
<view class="form-field">
<text class="field-label">{{ t('tabPhone') }}</text>
<view class="phone-group">
@@ -63,7 +97,6 @@
</view>
</view>
<!-- 行内一体化验证码输入行 -->
<view class="form-field">
<text class="field-label">{{ t('smsCode') }}</text>
<view class="code-group">
@@ -85,8 +118,8 @@
</view>
</view>
<!-- 3.3 邮箱 MagicLink 面板 -->
<view v-else class="form-section">
<!-- 邮箱输入行 -->
<view class="form-field">
<text class="field-label">{{ t('tabEmail') }}</text>
<input
@@ -108,6 +141,8 @@
<button
class="primary-cta-btn"
:class="{ 'primary-cta-disabled': state.submitting }"
role="button"
aria-label="登录"
:disabled="state.submitting"
@click="handlePrimarySubmit"
>
@@ -154,12 +189,14 @@ import { getCurrentLocale, isRtlLocale, OmniLocale, setAppLocale } from '../../c
import {
createLoginState,
switchLoginTab,
submitPasswordLogin,
submitPhoneLogin,
sendMagicLink,
sendSmsCode,
tickCountdown,
tapSocialLogin,
resolveLoginText,
fillTestAccount,
LoginCopyKey,
LoginTab,
SocialProvider,
@@ -201,6 +238,9 @@ const codeButtonText = computed((): string => {
});
const primaryButtonText = computed((): string => {
if (state.tab === 'password') {
return state.submitting ? t('loading') : t('login');
}
return state.tab === 'phone' ? t('login') : t('magicLink');
});
@@ -224,14 +264,14 @@ function handleGoBack(): void {
try {
uni.navigateBack({
fail: () => {
uni.switchTab({
url: '/pages/portal/index',
uni.reLaunch({
url: '/pages/owner/hall/index',
});
},
});
} catch (_e) {
uni.switchTab({
url: '/pages/portal/index',
uni.reLaunch({
url: '/pages/owner/hall/index',
});
}
}
@@ -266,8 +306,14 @@ function handleSendCode(): void {
}
}
function handleAutofillTest(): void {
fillTestAccount(state);
}
function handlePrimarySubmit(): void {
if (state.tab === 'phone') {
if (state.tab === 'password') {
submitPasswordLogin(state);
} else if (state.tab === 'phone') {
submitPhoneLogin(state);
} else {
sendMagicLink(state);
@@ -576,6 +622,32 @@ onUnmounted(() => {
color: #98A2B3;
}
/* 测试账号一键填充辅助胶囊 */
.test-account-badge {
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
padding: 6px 10px;
background-color: #F7F8FA;
border: 1px dashed #D0D5DD;
border-radius: 8px;
margin-bottom: 12px;
cursor: pointer;
transition: background-color 150ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.test-account-badge:active {
background-color: #EAF1FF;
border-color: #0B5CFF;
}
.test-account-text {
font-size: 12px;
color: #0B5CFF;
font-weight: 500;
}
/* 错误提示 */
.error-banner {
padding: 8px 12px;
@@ -593,8 +665,13 @@ onUnmounted(() => {
.primary-cta-btn {
width: 100%;
height: 44px;
line-height: 44px;
min-height: 44px;
background-color: #0B5CFF;
color: #FFFFFF;
font-size: 15px;
font-weight: 600;
text-align: center;
border-radius: 12px;
display: flex;
align-items: center;
@@ -602,15 +679,21 @@ onUnmounted(() => {
border: none;
margin-top: 6px;
margin-bottom: 18px;
cursor: pointer;
transition: opacity 150ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.primary-cta-btn::after {
border: none;
}
.primary-cta-btn:active {
opacity: 0.88;
}
.primary-cta-disabled {
background-color: #E3E7ED;
cursor: not-allowed;
}
.primary-cta-text {

查看文件

@@ -1,12 +1,14 @@
/**
* OmniCard AI (CRMmp) - 统一身份认证登录业务驱动层
* 第一版可用骨架:不接真实 Google / Apple SDK,不伪造成功登录
* 第一版可用骨架:支持账号密码真实登录对齐后端、手机号验证码、邮箱MagicLink与社交登录入口
*/
import { getCurrentLocale, getOmniText, OmniLocale } from '../../common/locale.uts';
import { setAuthToken, setTenantId } from '../../common/request.uts';
import { setAuthToken, setTenantId, httpPost } from '../../common/request.uts';
import { collectHallContact } from '../../common/api.uts';
import { consumePendingCollectCard } from '../owner/hall/useHall.uts';
export type LoginTab = 'phone' | 'email';
export type LoginTab = 'password' | 'phone' | 'email';
export type SocialProvider = 'google' | 'apple';
export type LoginCopyKey =
@@ -14,8 +16,14 @@ export type LoginCopyKey =
| 'brandTag'
| 'subtitle'
| 'desc'
| 'tabPassword'
| 'tabPhone'
| 'tabEmail'
| 'usernamePlaceholder'
| 'passwordPlaceholder'
| 'accountRequired'
| 'passwordRequired'
| 'testAccountTip'
| 'countryCode'
| 'phonePlaceholder'
| 'sendCode'
@@ -39,6 +47,8 @@ export type LoginCopyKey =
export type LoginState = {
tab: LoginTab;
username: string;
password: string;
countryCode: string;
phone: string;
smsCode: string;
@@ -48,6 +58,13 @@ export type LoginState = {
countdown: number;
};
export type LoginAdminResponse = {
token: string;
expire?: number;
refreshToken?: string;
refreshExpire?: number;
};
function isZhLocale(): boolean {
return getCurrentLocale() === 'zh-CN';
}
@@ -71,12 +88,30 @@ export function resolveLoginText(key: LoginCopyKey | string, targetLocale?: stri
if (key === 'subtitle') {
return zh ? '极简出海商务,连接全球商机' : 'Minimalist global commerce & identity';
}
if (key === 'tabPassword') {
return zh ? '账号密码' : 'Password';
}
if (key === 'tabPhone') {
return zh ? '手机号' : 'Phone';
}
if (key === 'tabEmail') {
return zh ? '邮箱' : 'Email';
}
if (key === 'usernamePlaceholder') {
return zh ? '用户名或手机号' : 'Username or phone';
}
if (key === 'passwordPlaceholder') {
return zh ? '登录密码' : 'Password';
}
if (key === 'accountRequired') {
return zh ? '请填写账号' : 'Enter your username';
}
if (key === 'passwordRequired') {
return zh ? '请填写密码' : 'Enter your password';
}
if (key === 'testAccountTip') {
return zh ? '测试账号: admin / 123456 (点击一键填入)' : 'Test account: admin / 123456 (Click to autofill)';
}
if (key === 'desc') {
return zh ? '使用国际手机号或邮箱继续' : 'Continue with your phone or email';
}
@@ -148,20 +183,51 @@ function toastNone(title: string): void {
}
function finishAfterLogin(): void {
if (typeof uni.switchTab === 'function') {
uni.switchTab({
url: '/pages/owner/card/index',
});
} else if (typeof uni.reLaunch === 'function') {
uni.reLaunch({
url: '/pages/owner/card/index',
try {
uni.showToast({
title: resolveLoginText('loginSuccess'),
icon: 'success',
});
} catch (e) {}
const pendingCardId = consumePendingCollectCard();
if (pendingCardId !== '') {
collectHallContact(pendingCardId).catch(() => {});
}
try {
if (typeof uni.switchTab === 'function') {
uni.switchTab({
url: '/pages/owner/card/index',
});
if (typeof window !== 'undefined' && window.location != null) {
try {
setTimeout(() => {
const currentHash = window.location.hash || '';
if (!currentHash.includes('/pages/owner/card/index')) {
window.location.hash = '#/pages/owner/card/index';
}
}, 300);
} catch (e) {}
}
return;
}
} catch (e) {}
try {
if (typeof uni.reLaunch === 'function') {
uni.reLaunch({
url: '/pages/owner/card/index',
});
}
} catch (e) {}
}
export function createLoginState(): LoginState {
return {
tab: 'phone',
tab: 'password',
username: '',
password: '',
countryCode: '+86',
phone: '',
smsCode: '',
@@ -177,6 +243,15 @@ export function switchLoginTab(state: LoginState, tab: LoginTab): void {
state.errorMessage = '';
}
/**
* 一键填充测试账号
*/
export function fillTestAccount(state: LoginState): void {
state.username = 'admin';
state.password = '123456';
state.errorMessage = '';
}
/**
* 倒计时推进函数
*/
@@ -206,6 +281,52 @@ export function completeLogin(token: string, tenantId?: string): boolean {
return true;
}
/**
* 账号密码真实登录:对齐后端 Cool-Admin POST /admin/base/open/login
*/
export async function submitPasswordLogin(state: LoginState): Promise<boolean> {
const username = state.username != null ? state.username.trim() : '';
if (username === '') {
state.errorMessage = resolveLoginText('accountRequired');
toastNone(state.errorMessage);
return false;
}
const password = state.password != null ? state.password.trim() : '';
if (password === '') {
state.errorMessage = resolveLoginText('passwordRequired');
toastNone(state.errorMessage);
return false;
}
if (state.submitting) {
return false;
}
state.submitting = true;
state.errorMessage = '';
try {
const res = await httpPost<LoginAdminResponse>('/admin/base/open/login', {
username,
password,
});
state.submitting = false;
if (res != null && res.token != null && res.token !== '') {
completeLogin(res.token);
return true;
}
state.errorMessage = '登录失败,未获取到有效凭证';
toastNone(state.errorMessage);
return false;
} catch (err: any) {
state.submitting = false;
const msg = err && err.message ? err.message : '账户或密码不正确~';
state.errorMessage = msg;
return false;
}
}
export function sendSmsCode(state: LoginState): boolean {
if (state.countdown > 0) {
return false;