2e6578247e
- lib/platform:网页 Electron 统一 bridge/web/electron,子目录 API 基路径、返回首页跳站点根、路径末尾斜杠兼容 - index/design*.web.html:网页入口,web.js 加缓存参数避免旧脚本缓存 - api:PHP 读写 soon;文档说明目录权限与 Nginx - lib/design*、lib/index:与 platformBridge 对接及网页侧逻辑 - 公共资源 JsBarcode/jr-qrcode;文档与 package/README/.gitignore 等同步更新 Co-authored-by: Cursor <cursoragent@cursor.com>
45 lines
1.6 KiB
JavaScript
45 lines
1.6 KiB
JavaScript
/**
|
|
* 平台抽象层 - 统一接口定义
|
|
* 桌面端由 lib/platform/electron.js 实现,网页端由 lib/platform/web.js 实现。
|
|
* 业务代码通过 window.platformBridge 或兼容的 window.sysAPI / window.dialog 调用。
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
|
|
// 若已存在(由 electron 或 web 注入),则不覆盖
|
|
if (typeof window.platformBridge !== 'undefined') {
|
|
return;
|
|
}
|
|
|
|
// 默认空实现,避免未注入时报错(仅作占位,实际运行前必须注入 electron 或 web 实现)
|
|
function notImplemented() {
|
|
console.warn('[platform] bridge not injected');
|
|
return Promise.reject(new Error('Platform bridge not available'));
|
|
}
|
|
|
|
window.platformBridge = {
|
|
readHistory: notImplemented,
|
|
writeHistory: notImplemented,
|
|
readJsonFile: notImplemented,
|
|
showOpenDialog: notImplemented,
|
|
showSaveDialog: notImplemented,
|
|
writeFile: notImplemented,
|
|
readFile: notImplemented,
|
|
getAppVersion: function () { return Promise.resolve('0.0.0'); },
|
|
getLocale: function () { return 'zh'; },
|
|
getUserDataPath: function () { return ''; },
|
|
getSystemFonts: function () { return Promise.resolve([]); },
|
|
openDesignPage: function () {},
|
|
openFirstPage: function () {},
|
|
onClose: function () {},
|
|
runClose: function () {},
|
|
openHelp: function () {},
|
|
printPdf: notImplemented,
|
|
getScaleRate: function () { return typeof window !== 'undefined' ? (window.devicePixelRatio || 1) : 1; },
|
|
clipboard: {
|
|
readText: function () { return Promise.resolve(''); },
|
|
writeText: function () { return Promise.resolve(); }
|
|
}
|
|
};
|
|
})();
|