API 部分迁移完成

This commit is contained in:
muwoo
2021-12-08 13:45:40 +08:00
parent a9827c6db1
commit 951f21f5fa
17 changed files with 818 additions and 39 deletions

View File

@@ -12,9 +12,10 @@ export default () => {
};
const createView = (plugin, window: BrowserWindow) => {
const preload = commonConst.dev()
? path.resolve(__static, `../feature/public/preload.js`)
: path.resolve(plugin.indexPath, `../`, plugin.preload);
const preload =
commonConst.dev() && plugin.name === "rubick-system-feature"
? path.resolve(__static, `../feature/public/preload.js`)
: path.resolve(plugin.indexPath.replace("file:", ""), `../`, plugin.preload);
const ses = session.fromPartition("<" + plugin.name + ">");
ses.setPreloads([`${__static}/preload.js`]);
@@ -54,6 +55,7 @@ export default () => {
const getView = () => view;
const executeHooks = (hook, data) => {
if (!view) return;
const evalJs = `if(window.rubick && window.rubick.hooks && typeof window.rubick.hooks.on${hook} === 'function' ) {
try {
window.rubick.hooks.on${hook}(${data ? JSON.stringify(data) : ""});