From e04756545352d48d7984f440cc01208e7e100a62 Mon Sep 17 00:00:00 2001 From: luke358 <1494135711@qq.com> Date: Fri, 19 Jan 2024 21:54:35 +0800 Subject: [PATCH] feat: recipe --- .gitignore | 2 ++ components.d.ts | 4 +++- preload/recipe.js | 60 ----------------------------------------------- 3 files changed, 5 insertions(+), 61 deletions(-) delete mode 100644 preload/recipe.js diff --git a/.gitignore b/.gitignore index 6cb5d23..f7b506f 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,5 @@ recipes/all.json recipes/archives .vscode + +preload/recipe.js diff --git a/components.d.ts b/components.d.ts index 4627702..f9e1f1e 100644 --- a/components.d.ts +++ b/components.d.ts @@ -3,9 +3,11 @@ // @ts-nocheck // Generated by unplugin-vue-components // Read more: https://github.com/vuejs/core/pull/3399 +import '@vue/runtime-core' + export {} -declare module 'vue' { +declare module '@vue/runtime-core' { export interface GlobalComponents { AddServiceDrawer: typeof import('./src/components/AddServiceDrawer.vue')['default'] ContextMenuPopover: typeof import('./src/components/ContextMenuPopover.vue')['default'] diff --git a/preload/recipe.js b/preload/recipe.js deleted file mode 100644 index 2249a70..0000000 --- a/preload/recipe.js +++ /dev/null @@ -1,60 +0,0 @@ -"use strict"; - -// preload/recipe.ts -var import_node_path = require("node:path"); -var import_electron2 = require("electron"); - -// preload/badge.ts -var import_electron = require("electron"); -var BadgeHandler = class { - safeParseInt(text) { - if (text === void 0 || text === null) { - return 0; - } - const parsedNumber = Number.parseInt(text.toString(), 10); - const adjustedNumber = Number.isNaN(parsedNumber) ? 0 : parsedNumber; - return Math.max(adjustedNumber, 0); - } - setBadge(direct, indirect) { - const count = { - direct: this.safeParseInt(direct), - indirect: this.safeParseInt(indirect) - }; - import_electron.ipcRenderer.sendToHost("message-counts", count); - } -}; - -// preload/recipe.ts -var badgeHandler = new BadgeHandler(); -console.log("ddddddddd", badgeHandler); -import_electron2.contextBridge.exposeInMainWorld("API", { - open: window.open, - setBadge: (direct, indirect) => badgeHandler.setBadge(direct, indirect), - safeParseInt: (text) => badgeHandler.safeParseInt(text) - // setDialogTitle: title => dialogTitleHandler.setDialogTitle(title), - // displayNotification: (title, options) => - // notificationsHandler.displayNotification(title, options), - // getDisplayMediaSelector, -}); -var RecipeController = class { - ipcEvents = { - "initialize-recipe": "loadRecipeModule", - "find-in-page": "openFindInPage" - }; - async initialize() { - for (const channel of Object.keys(this.ipcEvents)) { - import_electron2.ipcRenderer.on(channel, (...args) => { - this[this.ipcEvents[channel]](...args); - }); - } - } - loadRecipeModule(_event, config, recipe) { - const modulePath = (0, import_node_path.join)(recipe.path, "webview.js"); - delete require.cache[require.resolve(modulePath)]; - try { - } catch (error) { - console.error("Recipe initialization failed", error); - } - } -}; -new RecipeController();