kuaifan f479047fc9 feat(mobile): 主程序前端 nativeApp 桥接契约改造 + /share 接收页 + 子模块切到 Expo 工程
新移动端从 EEUI(weex) 切到 Expo(react-native),UA 标识从 'eeui' 改为 'DooTaskApp',
桥接底层从全局 requireModuleJs 切到 window.__nativeBridge.call(method,args) Promise RPC。
约 52 个文件批量改名(256 处引用):

- 平台识别:$A.isEEUIApp/Vue.prototype.$isEEUIApp → isMobileApp / $isMobileApp
  app.js 顶部 UA 正则 /eeui/i → /DooTaskApp/i
  app.js requireModuleJs 等待逻辑替换为 window.__nativeBridge 就绪判定
- 桥接 API:$A.eeuiAppXXX → $A.nativeAppXXX
- functions/eeui.js 删除,重写为 functions/native-app.js
  底层走 window.__nativeBridge.call;nativeAppSendMessage 把旧 sendMessage 的
  各 action 拆解为独立 method 调用(updateTheme/windowSize/setBadge/vibrate/
  callTel/picturePreview/videoPreview/startMeeting/updateMeetingInfo 等)
- types/dootask-globals.d.ts:方法签名同步改名
- store/actions.js:清理 saveUserInfoBase 内旧的
  userChatList/userUploadUrl sendMessage(二期由 /share 接收页直接调接口替代)

二期 /share 接收页(跨 App 分享):
- pages/share.vue(新增):原生 Share Extension / Android Intent 通过
  dootask://share?token=... 拉起 App 后跳本页;
  调 nativeAppGetSharedPayload 取分享元数据;
  复用 api/users/share/list 渲染会话列表;
  用户选会话 → POST api/dialog/msg/sendfiles 上传 + sendtext 发文本/URL;
  完成后 nativeAppClearSharedPayload 清理 + 跳目标会话
- routes.js 注册 /share 路由
- language/original-web.txt 加 share.vue 用到的文案

构建链路(electron/build.js):
- appbuild app 子命令:前端产物从复制到 resources/mobile/src/public + EEUI docker 构建
  改为同步到 resources/mobile/assets/web(由 plugins/withWebAssets 注入原生 bundle)
- android-upload apk 路径:从 platforms/android/eeuiApp/... 改为
  android/app/build/outputs/apk/release(Expo prebuild 标准布局)

子模块 resources/mobile 指针更新到新 Expo 工程提交(feat/mobile-expo-rewrite 分支)。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-17 06:55:52 +00:00

93 lines
2.8 KiB
JavaScript
Vendored

export const imageExtensions = ['jpg', 'jpeg', 'webp', 'png', 'gif', 'bmp'];
function extractExt(target) {
if (!target) {
return '';
}
if (typeof target === 'string') {
return target.toLowerCase();
}
const ext = target.ext || '';
if (ext) {
return `${ext}`.toLowerCase();
}
if (target.name && target.name.includes('.')) {
return target.name.split('.').pop().toLowerCase();
}
return '';
}
export function isImageFile(target) {
return imageExtensions.includes(extractExt(target));
}
export function previewImageFromList(vm, items, currentItem) {
if (!vm || !currentItem || !Array.isArray(items)) {
return false;
}
if (!currentItem.image_url || !isImageFile(currentItem)) {
return false;
}
const imageItems = items.filter(item => item && item.type === 'file' && isImageFile(item) && item.image_url);
const index = imageItems.findIndex(item => item.id === currentItem.id);
if (index === -1) {
return false;
}
const previewList = imageItems.map(item => {
if (item.image_width && item.image_height) {
return {
src: item.image_url,
width: item.image_width,
height: item.image_height,
};
}
return item.image_url;
});
vm.$store.dispatch('previewImage', {index, list: previewList});
return true;
}
export function openFileInClient(vm, item, options = {}) {
if (!vm || !item) {
return;
}
const path = options.path || `/single/file/${item.id}`;
const baseTitle = options.title || item.name || vm.$L('查看');
const sizeValue = options.size !== undefined ? options.size : item.size;
const finalTitle = sizeValue ? `${baseTitle} (${$A.bytesToSize(sizeValue)})` : baseTitle;
const windowName = options.windowName || `file-${item.id}`;
const windowConfig = Object.assign({
title: finalTitle,
titleFixed: true,
parent: null,
}, options.windowConfig || {});
if (vm.$Electron) {
vm.$store.dispatch('openWindow', {
name: windowName,
path,
title: windowConfig.title,
titleFixed: windowConfig.titleFixed,
width: windowConfig.width,
height: windowConfig.height,
force: options.force === undefined ? false : options.force,
});
return;
}
if (vm.$isMobileApp) {
vm.$store.dispatch('openAppChildPage', {
pageType: 'app',
pageTitle: finalTitle,
url: 'web.js',
params: Object.assign({
titleFixed: true,
url: $A.urlReplaceHash(path),
}, options.appParams || {}),
});
return;
}
window.open($A.mainUrl(path.substring(1)));
}