🐛 修复 #264

 支持 db.postAttachment 和 db.getAttachment
♻️ 重构版本更新机制
This commit is contained in:
muwoo
2023-10-18 11:02:14 +08:00
parent a7a85a7c62
commit bde5377282
12 changed files with 195 additions and 120 deletions

View File

@@ -73,23 +73,31 @@ export default () => {
const init = (plugin, window: BrowserWindow) => {
if (view === null || view === undefined) {
if (viewInstance.getView(plugin.name) && !commonConst.dev()) {
view = viewInstance.getView(plugin.name).view;
window.setBrowserView(view);
view.inited = true;
viewReadyFn(window, plugin);
} else {
createView(plugin, window);
viewInstance.addView(plugin.name, view);
}
createView(plugin, window);
// if (viewInstance.getView(plugin.name) && !commonConst.dev()) {
// view = viewInstance.getView(plugin.name).view;
// window.setBrowserView(view);
// view.inited = true;
// viewReadyFn(window, plugin);
// } else {
// createView(plugin, window);
// viewInstance.addView(plugin.name, view);
// }
// eslint-disable-next-line @typescript-eslint/no-var-requires
require('@electron/remote/main').enable(view.webContents);
}
};
const createView = (plugin, window: BrowserWindow) => {
const { tplPath, indexPath, development, name, main, pluginSetting, ext } =
plugin;
const {
tplPath,
indexPath,
development,
name,
main = 'index.html',
pluginSetting,
ext,
} = plugin;
let pluginIndexPath = tplPath || indexPath;
let preloadPath;
let darkMode;
@@ -160,7 +168,7 @@ export default () => {
window.removeBrowserView(view);
window.setSize(800, 60);
executeHooks('PluginOut', null);
window.webContents.executeJavaScript(`window.initRubick()`);
window.webContents?.executeJavaScript(`window.initRubick()`);
view = undefined;
};
@@ -174,7 +182,7 @@ export default () => {
} catch(e) {}
}
`;
view.webContents.executeJavaScript(evalJs);
view.webContents?.executeJavaScript(evalJs);
};
return {