feat: 同步管理端、用户端与后端业务,并接通线上 Web 接口
补齐平台订阅、外部登录、CRM 同步与用户端页面;Nginx 转发用户端接口,登录页使用 Google 与 Apple 标志。 Co-authored-by: Cursor <cursoragent@cursor.com>
这个提交包含在:
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* OmniCard AI (CRMmp) - 名片主参展分享码海报业务驱动层
|
||||
* 解析 slug / id,拉取公开短链二维码,复制链接
|
||||
* 解析 slug / id,拉取公开短链二维码,复制链接,保存海报到相册
|
||||
*/
|
||||
|
||||
import { fetchCardQrcodeSvg } from '../../../common/api.uts';
|
||||
@@ -47,7 +47,10 @@ export type QrcodeCopyKey =
|
||||
| 'empty'
|
||||
| 'error'
|
||||
| 'loading'
|
||||
| 'title';
|
||||
| 'title'
|
||||
| 'saveSuccess'
|
||||
| 'saveFailed'
|
||||
| 'saveUnavailable';
|
||||
|
||||
const QRCODE_COPY: Record<OmniLocale, Record<QrcodeCopyKey, string>> = {
|
||||
'zh-CN': {
|
||||
@@ -58,6 +61,9 @@ const QRCODE_COPY: Record<OmniLocale, Record<QrcodeCopyKey, string>> = {
|
||||
empty: '暂无数据',
|
||||
error: '出错了',
|
||||
loading: '加载中...',
|
||||
saveSuccess: '已保存到相册',
|
||||
saveFailed: '保存失败',
|
||||
saveUnavailable: '暂无可保存的图片',
|
||||
},
|
||||
'en-US': {
|
||||
title: 'Share Card',
|
||||
@@ -67,6 +73,9 @@ const QRCODE_COPY: Record<OmniLocale, Record<QrcodeCopyKey, string>> = {
|
||||
empty: 'Nothing here yet',
|
||||
error: 'Something went wrong',
|
||||
loading: 'Loading...',
|
||||
saveSuccess: 'Saved to Photos',
|
||||
saveFailed: 'Could not save',
|
||||
saveUnavailable: 'No image to save',
|
||||
},
|
||||
'ar-SA': {
|
||||
title: 'مشاركة البطاقة',
|
||||
@@ -76,6 +85,9 @@ const QRCODE_COPY: Record<OmniLocale, Record<QrcodeCopyKey, string>> = {
|
||||
empty: 'لا توجد بيانات بعد',
|
||||
error: 'حدث خطأ',
|
||||
loading: 'جار التحميل...',
|
||||
saveSuccess: 'تم الحفظ في الصور',
|
||||
saveFailed: 'تعذر الحفظ',
|
||||
saveUnavailable: 'لا توجد صورة للحفظ',
|
||||
},
|
||||
'es-ES': {
|
||||
title: 'Compartir tarjeta',
|
||||
@@ -85,6 +97,9 @@ const QRCODE_COPY: Record<OmniLocale, Record<QrcodeCopyKey, string>> = {
|
||||
empty: 'Aun no hay datos',
|
||||
error: 'Algo salio mal',
|
||||
loading: 'Cargando...',
|
||||
saveSuccess: 'Guardado en Fotos',
|
||||
saveFailed: 'No se pudo guardar',
|
||||
saveUnavailable: 'No hay imagen para guardar',
|
||||
},
|
||||
'de-DE': {
|
||||
title: 'Karte teilen',
|
||||
@@ -94,6 +109,9 @@ const QRCODE_COPY: Record<OmniLocale, Record<QrcodeCopyKey, string>> = {
|
||||
empty: 'Noch keine Daten',
|
||||
error: 'Etwas ist schiefgelaufen',
|
||||
loading: 'Wird geladen...',
|
||||
saveSuccess: 'In Fotos gespeichert',
|
||||
saveFailed: 'Speichern fehlgeschlagen',
|
||||
saveUnavailable: 'Kein Bild zum Speichern',
|
||||
},
|
||||
'fr-FR': {
|
||||
title: 'Partager la carte',
|
||||
@@ -103,6 +121,9 @@ const QRCODE_COPY: Record<OmniLocale, Record<QrcodeCopyKey, string>> = {
|
||||
empty: 'Aucune donnee',
|
||||
error: 'Une erreur est survenue',
|
||||
loading: 'Chargement...',
|
||||
saveSuccess: 'Enregistre dans Photos',
|
||||
saveFailed: 'Echec de l enregistrement',
|
||||
saveUnavailable: 'Aucune image a enregistrer',
|
||||
},
|
||||
'ja-JP': {
|
||||
title: '名刺をシェア',
|
||||
@@ -112,6 +133,9 @@ const QRCODE_COPY: Record<OmniLocale, Record<QrcodeCopyKey, string>> = {
|
||||
empty: 'データがありません',
|
||||
error: 'エラーが発生しました',
|
||||
loading: '読み込み中...',
|
||||
saveSuccess: '写真に保存しました',
|
||||
saveFailed: '保存に失敗しました',
|
||||
saveUnavailable: '保存できる画像がありません',
|
||||
},
|
||||
};
|
||||
|
||||
@@ -264,3 +288,106 @@ export function copyPosterUrl(url: string | null | undefined): boolean {
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 仅本地路径 / 网络图 / data:image 可入库;纯 SVG 标记不可直接进相册
|
||||
*/
|
||||
export function isSaveablePosterImage(source: string | null | undefined): boolean {
|
||||
const text = trimText(source);
|
||||
if (text === '') {
|
||||
return false;
|
||||
}
|
||||
const lower = text.toLowerCase();
|
||||
if (lower.indexOf('<svg') >= 0 || lower.indexOf('<?xml') === 0) {
|
||||
return false;
|
||||
}
|
||||
if (
|
||||
lower.indexOf('http://') === 0 ||
|
||||
lower.indexOf('https://') === 0 ||
|
||||
lower.indexOf('data:image') === 0
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function toastSaveFailed(unavailable: boolean): void {
|
||||
if (unavailable) {
|
||||
uni.showToast({
|
||||
title: resolveQrcodeText('saveUnavailable'),
|
||||
icon: 'none',
|
||||
});
|
||||
return;
|
||||
}
|
||||
uni.showToast({
|
||||
title: resolveQrcodeText('saveFailed'),
|
||||
icon: 'none',
|
||||
});
|
||||
}
|
||||
|
||||
function invokeSaveImageToPhotosAlbum(filePath: string): Promise<boolean> {
|
||||
return new Promise<boolean>(resolve => {
|
||||
uni.saveImageToPhotosAlbum({
|
||||
filePath: filePath,
|
||||
success: () => {
|
||||
uni.showToast({
|
||||
title: resolveQrcodeText('saveSuccess'),
|
||||
icon: 'none',
|
||||
});
|
||||
resolve(true);
|
||||
},
|
||||
fail: (_err: unknown) => {
|
||||
toastSaveFailed(false);
|
||||
resolve(false);
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function downloadRemoteImage(url: string): Promise<string> {
|
||||
return new Promise<string>(resolve => {
|
||||
uni.downloadFile({
|
||||
url: url,
|
||||
success: (res: { statusCode?: number; tempFilePath?: string }) => {
|
||||
const path =
|
||||
res != null && res.tempFilePath != null
|
||||
? String(res.tempFilePath).trim()
|
||||
: '';
|
||||
const code = res != null && res.statusCode != null ? res.statusCode : 0;
|
||||
if (code === 200 && path !== '') {
|
||||
resolve(path);
|
||||
return;
|
||||
}
|
||||
resolve('');
|
||||
},
|
||||
fail: (_err: unknown) => {
|
||||
resolve('');
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存海报到相册:必须等 uni.saveImageToPhotosAlbum 成功才 toast 已保存
|
||||
*/
|
||||
export async function savePosterToAlbum(
|
||||
imageSource: string | null | undefined
|
||||
): Promise<boolean> {
|
||||
const source = trimText(imageSource);
|
||||
if (source === '' || !isSaveablePosterImage(source)) {
|
||||
toastSaveFailed(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
let filePath = source;
|
||||
const lower = source.toLowerCase();
|
||||
if (lower.indexOf('http://') === 0 || lower.indexOf('https://') === 0) {
|
||||
filePath = await downloadRemoteImage(source);
|
||||
if (filePath === '') {
|
||||
toastSaveFailed(false);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return invokeSaveImageToPhotosAlbum(filePath);
|
||||
}
|
||||
|
||||
在新工单中引用
屏蔽一个用户