-
Notifications
You must be signed in to change notification settings - Fork 89
Add plugin md表格互转 v1.0.0 #272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
7788jay
wants to merge
3
commits into
ZToolsCenter:main
Choose a base branch
from
7788jay:plugin/md-table-convert
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "permissions": { | ||
| "allow": [ | ||
| "Bash(winget --version)" | ||
| ] | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| { | ||
| "permissions": { | ||
| "allow": [ | ||
| "Bash(npx vue-tsc *)", | ||
| "Bash(where node *)", | ||
| "Bash(where npx *)", | ||
| "Bash(winget install *)", | ||
| "Bash(mkdir -p \"E:/nodejs/node_cache\" 2>&1)", | ||
| "Bash(cmd //c dir \"E:\\\\\" 2>&1)", | ||
| "Bash(git rm *)" | ||
| ], | ||
| "additionalDirectories": [ | ||
| "E:\\nodejs" | ||
| ] | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| # Logs | ||
| logs | ||
| *.log | ||
| npm-debug.log* | ||
| yarn-debug.log* | ||
| yarn-error.log* | ||
| pnpm-debug.log* | ||
| lerna-debug.log* | ||
|
|
||
| node_modules | ||
| dist | ||
| dist-ssr | ||
| *.local | ||
| .claude/ | ||
|
|
||
| # Editor directories and files | ||
| .vscode/* | ||
| !.vscode/extensions.json | ||
| .idea | ||
| .DS_Store | ||
| *.suo | ||
| *.ntvs* | ||
| *.njsproj | ||
| *.sln | ||
| *.sw? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,281 @@ | ||
| # {{PLUGIN_NAME}} | ||
|
|
||
| > {{DESCRIPTION}} | ||
|
|
||
| 这是一个使用 **Vue 3 + Vite + TypeScript** 构建的 ZTools 插件。 | ||
|
|
||
| ## ✨ 功能特性 | ||
|
|
||
| ### 📌 已包含的示例功能 | ||
|
|
||
| - **Hello** - 基础功能指令示例 | ||
| - 触发指令:`你好` / `hello` | ||
| - 展示简单的 Vue 组件界面 | ||
|
|
||
| - **读文件** - 文件读取功能示例 | ||
| - 功能指令:`读文件` | ||
| - 匹配指令:支持拖拽文件触发 | ||
| - 演示如何使用 Node.js 能力读取文件内容 | ||
|
|
||
| - **保存为文件** - 文件写入功能示例 | ||
| - 匹配指令:任意文本/图片 → `保存为文件` | ||
| - 演示如何将剪贴板内容保存为文件 | ||
|
|
||
| ## 📁 项目结构 | ||
|
|
||
| ``` | ||
| . | ||
| ├── public/ | ||
| │ ├── logo.png # 插件图标 | ||
| │ ├── plugin.json # 插件配置文件 | ||
| │ └── preload/ # Preload 脚本目录 | ||
| │ ├── package.json # Preload 依赖配置 | ||
| │ └── services.js # Node.js 能力扩展 | ||
| ├── src/ | ||
| │ ├── main.ts # 入口文件 | ||
| │ ├── main.css # 全局样式 | ||
| │ ├── App.vue # 根组件 | ||
| │ ├── env.d.ts # 类型声明 | ||
| │ ├── Hello/ # Hello 功能组件 | ||
| │ │ └── index.vue | ||
| │ ├── Read/ # 读文件功能组件 | ||
| │ │ └── index.vue | ||
| │ └── Write/ # 写文件功能组件 | ||
| │ └── index.vue | ||
| ├── index.html # HTML 模板 | ||
| ├── vite.config.js # Vite 配置 | ||
| ├── tsconfig.json # TypeScript 配置 | ||
| ├── package.json # 项目依赖 | ||
| └── README.md # 项目文档 | ||
| ``` | ||
|
|
||
| ## 🚀 快速开始 | ||
|
|
||
| ### 安装依赖 | ||
|
|
||
| ```bash | ||
| npm install | ||
| ``` | ||
|
|
||
| ### 开发模式 | ||
|
|
||
| ```bash | ||
| npm run dev | ||
| ``` | ||
|
|
||
| 开发服务器将在 `http://localhost:5173` 启动。ZTools 会自动加载开发版本。 | ||
|
|
||
| ### 构建生产版本 | ||
|
|
||
| ```bash | ||
| npm run build | ||
| ``` | ||
|
|
||
| 构建产物将输出到 `dist/` 目录。 | ||
|
|
||
| ## 📖 开发指南 | ||
|
|
||
| ### 1. 修改插件配置 | ||
|
|
||
| 编辑 `public/plugin.json` 文件: | ||
|
|
||
| ```json | ||
| { | ||
| "name": "你的插件名称", | ||
| "description": "插件描述", | ||
| "author": "作者名称", | ||
| "version": "1.0.0", | ||
| "features": [ | ||
| // 添加你的功能配置 | ||
| ] | ||
| } | ||
| ``` | ||
|
|
||
| ### 2. 创建新功能 | ||
|
|
||
| #### 步骤 1: 创建 Vue 组件 | ||
|
|
||
| 在 `src/` 目录下创建新的功能组件: | ||
|
|
||
| ```vue | ||
| <!-- src/MyFeature/index.vue --> | ||
| <template> | ||
| <div class="my-feature"> | ||
| <h1>{{ title }}</h1> | ||
| <!-- 你的组件内容 --> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script setup lang="ts"> | ||
| import { ref } from 'vue' | ||
|
|
||
| const title = ref('我的新功能') | ||
| </script> | ||
|
|
||
| <style scoped> | ||
| .my-feature { | ||
| padding: 20px; | ||
| } | ||
| </style> | ||
| ``` | ||
|
|
||
| #### 步骤 2: 注册路由 | ||
|
|
||
| 在 `src/App.vue` 中添加路由: | ||
|
|
||
| ```vue | ||
| <script setup lang="ts"> | ||
| import MyFeature from './MyFeature/index.vue' | ||
|
|
||
| const routes = { | ||
| hello: Hello, | ||
| read: Read, | ||
| write: Write, | ||
| myfeature: MyFeature // 添加新路由 | ||
| } | ||
| </script> | ||
| ``` | ||
|
|
||
| #### 步骤 3: 配置功能 | ||
|
|
||
| 在 `plugin.json` 中添加功能配置: | ||
|
|
||
| ```json | ||
| { | ||
| "code": "myfeature", | ||
| "explain": "我的新功能", | ||
| "icon": "logo.png", | ||
| "cmds": ["触发指令"] | ||
| } | ||
| ``` | ||
|
|
||
| ### 3. 使用 Node.js 能力 | ||
|
|
||
| #### 扩展 Preload 服务 | ||
|
|
||
| 编辑 `public/preload/services.js`: | ||
|
|
||
| ```javascript | ||
| const fs = require('fs') | ||
| const path = require('path') | ||
|
|
||
| module.exports = { | ||
| // 示例:读取文件 | ||
| readFile: (filePath) => { | ||
| return fs.readFileSync(filePath, 'utf-8') | ||
| }, | ||
|
|
||
| // 添加你的服务 | ||
| myService: (params) => { | ||
| // 实现你的逻辑 | ||
| return result | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| #### 在 Vue 组件中调用 | ||
|
|
||
| ```vue | ||
| <script setup lang="ts"> | ||
| const handleRead = async () => { | ||
| try { | ||
| const content = await window.services.readFile('/path/to/file') | ||
| console.log(content) | ||
| } catch (error) { | ||
| console.error('读取失败:', error) | ||
| } | ||
| } | ||
| </script> | ||
| ``` | ||
|
|
||
| ### 4. 使用 ZTools API | ||
|
|
||
| ```vue | ||
| <script setup lang="ts"> | ||
| // 获取剪贴板内容 | ||
| const text = await window.ztools.getClipboardContent() | ||
|
|
||
| // 隐藏主窗口 | ||
| window.ztools.hideMainWindow() | ||
|
|
||
| // 显示提示 | ||
| window.ztools.showTip('操作成功') | ||
|
|
||
| // 更多 API 请参考官方文档 | ||
| </script> | ||
| ``` | ||
|
|
||
| ## 🎨 样式开发 | ||
|
|
||
| ### 使用 CSS 变量 | ||
|
|
||
| ZTools 提供了一套 CSS 变量用于主题适配: | ||
|
|
||
| ```css | ||
| .my-component { | ||
| background: var(--bg-color); | ||
| color: var(--text-color); | ||
| border: 1px solid var(--border-color); | ||
| } | ||
| ``` | ||
|
|
||
| ### 暗色模式支持 | ||
|
|
||
| ```css | ||
| @media (prefers-color-scheme: dark) { | ||
| .my-component { | ||
| /* 暗色模式样式 */ | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ## 📦 构建与发布 | ||
|
|
||
| ### 1. 构建插件 | ||
|
|
||
| ```bash | ||
| npm run build | ||
| ``` | ||
|
|
||
| ### 2. 测试构建产物 | ||
|
|
||
| 将 `dist/` 目录中的所有文件复制到 ZTools 插件目录进行测试。 | ||
|
|
||
| ### 3. 发布到插件市场 | ||
|
|
||
| 1. 确保 `plugin.json` 中的信息完整准确 | ||
| 2. 准备好插件截图和详细说明 | ||
| 3. 访问 ZTools 插件市场提交插件 | ||
|
|
||
| ## 📚 相关资源 | ||
|
|
||
| - [ZTools 官方文档](https://github.com/ztool-center/ztools) | ||
| - [ZTools API 文档](https://github.com/ztool-center/ztools-api-types) | ||
| - [Vue 3 文档](https://vuejs.org/) | ||
| - [Vite 文档](https://vitejs.dev/) | ||
|
|
||
| ## ❓ 常见问题 | ||
|
|
||
| ### Q: 如何调试插件? | ||
|
|
||
| A: 使用 `npm run dev` 启动开发服务器,在插件界面中点击插件头像图标,在弹出的菜单中选择"打开开发者工具"进行调试。 | ||
|
|
||
| ### Q: 如何访问 Node.js 能力? | ||
|
|
||
| A: 通过 `public/preload/services.js` 文件扩展服务,然后在组件中使用 `window.services` 调用。 | ||
|
|
||
| ### Q: 插件图标不显示? | ||
|
|
||
| A: 确保 `public/logo.png` 文件存在,且在 `plugin.json` 中正确配置了 `logo` 字段。 | ||
|
|
||
| ### Q: 如何处理大文件上传? | ||
|
|
||
| A: 建议使用 Node.js 流式处理,在 preload 脚本中实现文件分块处理逻辑。 | ||
|
|
||
| ## 📄 开源协议 | ||
|
|
||
| MIT License | ||
|
|
||
| --- | ||
|
|
||
| **祝你开发愉快!** 🎉 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| <!doctype html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
| </head> | ||
| <body> | ||
| <div id="app"></div> | ||
| <script type="module" src="/src/main.ts"></script> | ||
| </body> | ||
| </html> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.claude/settings.local.json是本地 AI 助手(如 Claude Code)生成的本地配置文件,其中包含特定于你个人电脑的绝对路径(如E:\\nodejs)。这类本地配置文件不应该提交到公共代码仓库中。建议将其从 Git 中移除,并添加到.gitignore中。