Skip to content

Commit

Permalink
chore: enhance wip
Browse files Browse the repository at this point in the history
  • Loading branch information
zzzgydi committed Mar 2, 2022
1 parent bcdae11 commit 0f5923a
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
22 changes: 22 additions & 0 deletions src/services/enhance.ts
Original file line number Diff line number Diff line change
@@ -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);
});
}
11 changes: 11 additions & 0 deletions src/services/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit 0f5923a

Please sign in to comment.