From 21f6940b81de61f51eab0d5e4b8adad710520978 Mon Sep 17 00:00:00 2001 From: QC2168 Date: Wed, 11 Dec 2024 21:01:26 +0800 Subject: [PATCH] feat: update vite-plugin-utools --- README.md | 9 +++++---- package.json | 2 +- plugin.json | 20 -------------------- plugin.json5 | 35 +++++++++++++++++++++++++++++++++++ vite.config.ts | 7 +------ 5 files changed, 42 insertions(+), 31 deletions(-) delete mode 100644 plugin.json create mode 100644 plugin.json5 diff --git a/README.md b/README.md index 1ba2fc3..7685a41 100644 --- a/README.md +++ b/README.md @@ -8,11 +8,11 @@ ## ✨ 特性 -- 🌈 开箱即用的`Vite+Vue3`的`Utools`插件开发模板 +- 🌈 开箱即用的`Vite+Vue3+TS`的`Utools`插件开发模板 - ⚡ 开发环境自动注入`HMR`字段 - 🦍 自动构建`upx`包 - 🧸 构建`utools/preload`文件,自动处理插件第三方依赖(依赖脚本位于`script/build.js`) -- 🚀 构建桌面应用(`electron`) +- 🚀 构建桌面应用(`electron` 不需要可移除) ## 🥩 开始使用 @@ -49,9 +49,10 @@ pnpm build > 原理:通过读取提供的`preload.js`文件,获取所需的依赖包后,在插件打包目录下执行`npm install`实现依赖安装 ```js -const install = require("@qc2168/vite-plugin-utools").install +import { install } from '@qc2168/vite-plugin-utools'; // 添加编译后的preload文件 -install(['./dist/preload.js', './dist/preload2.js']) +install(['./dist/preload.js']); + ``` ### 如何启动插件 diff --git a/package.json b/package.json index c5c8336..638b992 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "preview": "vite preview" }, "dependencies": { - "@qc2168/vite-plugin-utools": "^1.5.1", + "@qc2168/vite-plugin-utools": "^1.6.0", "vue": "^3.5.13" }, "devDependencies": { diff --git a/plugin.json b/plugin.json deleted file mode 100644 index 93be0ee..0000000 --- a/plugin.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "logo": "logo.png", - "preload": "preload.js", - "main": "index.html", - "name": "your plugin ID", - "version": "1.0.0", - "pluginName": "template", - "description": "plugin template", - "author": "QC2168", - "homepage": "https://github.com/QC2168", - "features": [ - { - "code": "template", - "explain": "插件模板主界面", - "cmds": [ - "template" - ] - } - ] -} diff --git a/plugin.json5 b/plugin.json5 new file mode 100644 index 0000000..55a576b --- /dev/null +++ b/plugin.json5 @@ -0,0 +1,35 @@ +{ + // 下列属性为插件必需属性,了解更多属性请往前 官方文档-完整配置篇 + // https://www.u.tools/docs/developer/config.html + // 插件图标路径 + logo: "logo.png", + // 预加载脚本 + preload: "preload.js", + // 插件入口页面 + main: "index.html", + // 插件ID + name: "your plugin ID", + // 版本号 + version: "1.0.0", + // 显示名称 + pluginName: "template", + // 描述 + description: "plugin template", + // 作者 + author: "QC2168", + // 主页 + homepage: "https://github.com/QC2168", + // 功能列表 + features: [ + { + // 功能代码 + code: "template", + // 功能说明 + explain: "插件模板主界面", + // 触发命令 + cmds: [ + "template" + ] + } + ] +} diff --git a/vite.config.ts b/vite.config.ts index 1830c42..730a696 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -26,12 +26,7 @@ export default defineConfig(({ command, mode }) => { mode: isBuild ? BuildMode.ExcludeDependencies : BuildMode.IncludeDependencies } ], - hmr: { - pluginJsonPath: './plugin.json' - }, - upx: { - pluginJsonPath: './plugin.json', - } + hmr: true, }), isStartElectron && electron([ {