chore: enhance wip

This commit is contained in:
GyDi 2022-03-03 01:58:05 +08:00
parent bcdae1169e
commit 0f5923a10a
No known key found for this signature in database
GPG Key ID: 1C95E0D3467B3084
3 changed files with 36 additions and 0 deletions

View File

@ -6,6 +6,9 @@ import ReactDOM from "react-dom";
import { RecoilRoot } from "recoil";
import { BrowserRouter } from "react-router-dom";
import Layout from "./pages/_layout";
import setup from "./services/enhance";
setup();
ReactDOM.render(
<React.StrictMode>

22
src/services/enhance.ts Normal file
View File

@ -0,0 +1,22 @@
import { emit, listen } from "@tauri-apps/api/event";
import { CmdType } from "./types";
export default function setup() {
listen("script-handler", (event) => {
const payload = event.payload as CmdType.EnhancedPayload;
console.log(payload);
// setTimeout(() => {
// try {
// const fn = eval(payload.script + "\n\nmixin");
// console.log(fn);
// const result = fn(payload.params || {});
// console.log("result", result);
// emit(payload.callback, JSON.stringify(result)).catch(console.error);
// } catch (err) {
// console.error(err);
// }
// }, 3000);
});
}

View File

@ -121,4 +121,15 @@ export namespace CmdType {
enable_proxy_guard?: boolean;
system_proxy_bypass?: string;
}
export interface ChainItem {
item: ProfileItem;
merge?: object;
script?: string;
}
export interface EnhancedPayload {
chain: ChainItem[];
current: object;
}
}