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 次删除

查看文件

@@ -58,7 +58,19 @@ describe('Point 25: 移动端拍照上传纸质名片 OCR 识别入库 (useOcrEx
handleCardOcrUpload: (
form: ExchangeForm,
ocrState: ReturnType<typeof loadUseOcrExchange> extends never ? never : any,
options?: { mockText?: string }
options?: {
mockText?: string;
httpPost?: (
url: string,
data?: Record<string, string>
) => Promise<{
name: string;
company: string;
phone: string;
email: string;
title: string;
}>;
}
) => Promise<boolean>;
};
}
@@ -341,7 +353,7 @@ describe('Point 25: 移动端拍照上传纸质名片 OCR 识别入库 (useOcrEx
expect(toastCalls[0].title).toContain('识别成功');
});
it('6.2 通过 chooseImage 成功拍照或选图后触发名片自动填充', async () => {
it('6.2 通过 chooseImage 成功选图后请求 /open/ai/ocr/recognize 并填表', async () => {
const { createOcrScanState, handleCardOcrUpload } = loadUseOcrExchange();
const form: ExchangeForm = {
name: '',
@@ -359,13 +371,32 @@ describe('Point 25: 移动端拍照上传纸质名片 OCR 识别入库 (useOcrEx
opt.success?.({ tempFilePaths: ['temp://photo.jpg'] });
};
const success = await handleCardOcrUpload(form, ocrState);
const httpPost = jest.fn().mockResolvedValue({
name: '赵敏',
company: '星河智联科技有限公司',
phone: '+8613911112222',
email: 'zhaomin@xinghe.ai',
title: '商务经理',
});
const success = await handleCardOcrUpload(form, ocrState, { httpPost });
expect(success).toBe(true);
expect(form.name).toBe('张伟');
expect(form.phone).toBe('+8613800138000');
expect(form.company).toBe('深圳超维智能科技有限公司');
expect(httpPost).toHaveBeenCalledTimes(1);
expect(httpPost.mock.calls[0][0]).toBe('/open/ai/ocr/recognize');
const body = httpPost.mock.calls[0][1] as Record<string, string>;
expect(
(body.imageBase64 != null && body.imageBase64 !== '') ||
(body.imageUrl != null && body.imageUrl !== '')
).toBe(true);
expect(form.name).toBe('赵敏');
expect(form.phone).toBe('+8613911112222');
expect(form.company).toBe('星河智联科技有限公司');
expect(form.email).toBe('zhaomin@xinghe.ai');
expect(form.notes).toBe('商务经理');
expect(form.name).not.toBe('张伟');
expect(ocrState.scanning).toBe(false);
expect(ocrState.errorMessage).toBe('');
expect(toastCalls.length).toBeGreaterThan(0);
});
@@ -412,5 +443,43 @@ describe('Point 25: 移动端拍照上传纸质名片 OCR 识别入库 (useOcrEx
expect(defaultSample.name).toBe('张伟');
expect(defaultSample.phone).toBe('+8613800138000');
});
it('6.5 OCR 接口失败或未配置时写入 errorMessage 且不用样例填表', async () => {
const { createOcrScanState, handleCardOcrUpload } = loadUseOcrExchange();
const form: ExchangeForm = {
name: '已有姓名',
company: '',
phone: '',
email: '',
notes: '',
};
const ocrState = createOcrScanState();
(global as unknown as { uni: Record<string, unknown> }).uni.chooseImage = (opt: {
success?: (res: unknown) => void;
fail?: (err: unknown) => void;
}) => {
opt.success?.({ tempFilePaths: ['temp://photo.jpg'] });
};
const httpPost = jest
.fn()
.mockRejectedValue(new Error('未配置 OCR 服务(OCR_API_KEY / OCR_BASE_URL)'));
const success = await handleCardOcrUpload(form, ocrState, { httpPost });
expect(success).toBe(false);
expect(httpPost).toHaveBeenCalledWith(
'/open/ai/ocr/recognize',
expect.any(Object)
);
expect(form.name).toBe('已有姓名');
expect(form.name).not.toBe('张伟');
expect(form.company).toBe('');
expect(form.phone).toBe('');
expect(ocrState.scanning).toBe(false);
expect(ocrState.errorMessage).toContain('未配置');
expect(ocrState.lastExtracted).toBeNull();
});
});
});