网页端:平台桥与部署修复(宝塔/Nginx)

- 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>
This commit is contained in:
24kycj
2026-05-09 18:57:53 +08:00
parent ee6ef462ca
commit 2e6578247e
27 changed files with 6606 additions and 3542 deletions
+63 -49
View File
@@ -1283,32 +1283,34 @@ function saveAs(op1, callback) {
let o = { f: j, b: b, fo: objs1, bo: objs2 }
let con_o = Object.assign(o, op1)
dialog
.showSaveDialog({
title: language_str('saveFile'), //'保存文件'
filters: [{ name: 'Soon File Type', extensions: ['soon'] }]
})
.then((result) => {
if (result.filePath == '') {
return
con_o.soonType = 2
var content = JSON.stringify(con_o)
var dialogApi = (typeof dialog !== 'undefined' && dialog) ? dialog : (window.platformBridge && window.platformBridge.showSaveDialog ? { showSaveDialog: function(opts) { return window.platformBridge.showSaveDialog(opts); } } : null);
if (!dialogApi) return;
dialogApi.showSaveDialog({ title: language_str('saveFile'), filters: [{ name: 'Soon File Type', extensions: ['soon'] }] })
.then(function(result) {
var fp = result.filePath || (result.fileHandle && result.fileHandle.name);
if (!fp && !result.fileHandle) return;
if (typeof fp === 'string' && fp.substring(fp.length - 5).indexOf('.') === -1) fp += '.soon';
if (window.platformBridge && window.platformBridge.writeFile) {
window.platformBridge.writeFile(result.fileHandle || fp, content).then(function() {
openAs.name = fp;
layer.msg(language_str('saveSucc') + openAs.name);
if (typeof window.saveHistory === 'function') window.saveHistory();
if (callback && typeof callback === 'function') callback();
});
return;
}
if (result.filePath.substring(result.filePath.length - 5).indexOf('.') == -1) {
result.filePath += '.soon'
}
let fs = require('fs')
con_o.soonType = 2
fs.writeFileSync(result.filePath, JSON.stringify(con_o), 'utf8')
openAs.name = result.filePath
layer.msg(language_str('saveSucc') + openAs.name) //'保存成功至'
if (typeof window.saveHistory === 'function') {
window.saveHistory();
}
if (callback && typeof callback === 'function') {
callback()
var fs = typeof require !== 'undefined' ? require('fs') : null;
if (fs) {
fs.writeFileSync(fp, content, 'utf8');
openAs.name = fp;
layer.msg(language_str('saveSucc') + openAs.name);
if (typeof window.saveHistory === 'function') window.saveHistory();
if (callback && typeof callback === 'function') callback();
}
})
.catch((err) => {
})
.catch(function(err) {});
}
// save 函数已在 output.js 中定义
// 复制
@@ -1354,49 +1356,60 @@ $('#open').click(function () {
}
)
function OpenDialog() {
dialog
.showOpenDialog({
title: '请选择文件',
buttonLabel: language_str('comf'),
filters: [{ name: 'Soon File Type', extensions: ['soon'] }]
})
.then((result) => {
var dialogApi = (typeof dialog !== 'undefined' && dialog) ? dialog : (window.platformBridge && window.platformBridge.showOpenDialog ? { showOpenDialog: function(opts) { return window.platformBridge.showOpenDialog(opts); } } : null);
if (!dialogApi) return;
dialogApi.showOpenDialog({ title: '请选择文件', buttonLabel: language_str('comf'), filters: [{ name: 'Soon File Type', extensions: ['soon'] }] })
.then(function(result) {
if (result.canceled) return;
let filePath = result.filePaths[0];
let fs = require('fs');
let fsData = fs.readFileSync(filePath);
let j = JSON.parse(fsData.toString());
let type = j.soonType ? j.soonType : j.backBlackPic ? 2 : 1;
if (type == 1) {
ipcRenderer.send('open-design-page', filePath, type);
var filePath = result.filePaths && result.filePaths[0];
var file = result.files && result.files[0];
if (file && window.platformBridge && window.platformBridge.readJsonFile) {
window.platformBridge.readJsonFile(file).then(function(j) {
if (!j) return;
var type = j.soonType ? j.soonType : (j.backBlackPic ? 2 : 1);
if (type == 1 && window.platformBridge.openDesignPage) {
window.platformBridge.openDesignPage(file.name, 1);
return;
}
if (typeof window.openFile === 'function') window.openFile(file.name, j);
});
return;
}
// 调用 output.js 中的 openFile 函数
if (typeof window.openFile === 'function') {
window.openFile(filePath);
if (!filePath) return;
var fs = typeof require !== 'undefined' ? require('fs') : null;
if (!fs) return;
var fsData = fs.readFileSync(filePath);
var j = JSON.parse(fsData.toString());
var type = j.soonType ? j.soonType : (j.backBlackPic ? 2 : 1);
if (type == 1) {
if (window.platformBridge && window.platformBridge.openDesignPage) window.platformBridge.openDesignPage(filePath, type);
else if (ipcRenderer && ipcRenderer.send) ipcRenderer.send('open-design-page', filePath, type);
return;
}
if (typeof window.openFile === 'function') window.openFile(filePath);
})
.catch((err) => {
})
.catch(function(err) {});
}
})
function goFirstPage() {
if (window.platformBridge && window.platformBridge.openFirstPage) window.platformBridge.openFirstPage();
else if (ipcRenderer && ipcRenderer.send) ipcRenderer.send('open-first-page');
}
$('#new').click(function () {
if (step.val == 0) {
ipcRenderer.send('open-first-page');
goFirstPage();
return;
}
layer.confirm(
'<font style="color:black">' + language_str('whetherSave') + '</font>',
function (index) {
if (typeof window.output === 'function') {
window.output(() => ipcRenderer.send('open-first-page'));
window.output(goFirstPage);
}
layer.close(index);
},
function (index) {
ipcRenderer.send('open-first-page');
goFirstPage();
}
)
})
@@ -2718,8 +2731,9 @@ $("#about").click(async function () {
'</div>'
});
})
$("#help").click(() => {
ipcRenderer.send('open-help-file');
$("#help").click(function() {
if (window.platformBridge && window.platformBridge.openHelp) window.platformBridge.openHelp();
else if (ipcRenderer && ipcRenderer.send) ipcRenderer.send('open-help-file');
});
// ===========================================================