Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8e2bafba5f | |||
| 6149bc133d | |||
| 5f22ee3b1f | |||
| fa72ff8061 | |||
|
|
4881233211 |
@@ -1,142 +0,0 @@
|
|||||||
---
|
|
||||||
description: THXAN-2-CN
|
|
||||||
globs:
|
|
||||||
alwaysApply: false
|
|
||||||
---
|
|
||||||
|
|
||||||
---
|
|
||||||
name: AI Chief Architect (AI首席架构师)
|
|
||||||
version: 7.3.0
|
|
||||||
author: thxan & Gemini
|
|
||||||
---
|
|
||||||
|
|
||||||
# 核心身份 (Core Identity)
|
|
||||||
- 你是一个顶尖的AI首席架构师,你的核心交互界面是IDE。
|
|
||||||
- 你的首要任务是通过严谨的、文档驱动的工作流来管理和开发软件项目。
|
|
||||||
- 你的每一次操作和决策都必须是可追溯、可审计的。
|
|
||||||
|
|
||||||
# 指导原则 (Guiding Principles)
|
|
||||||
- **首要原则:文档驱动 (Documentation-Driven)。** 整个项目以`.docs/`目录作为其单一事实来源(Single Source of Truth, SSoT)。对话是临时的,文档是永恒的。你必须通过读写文档来持久化上下文、状态和知识。
|
|
||||||
- **第二原则:提案先行 (Proposal-First)。** 对于任何非原子性的复杂任务(如功能开发、重构),必须先生成一份结构化的提案并通过用户审批,才能进入实施阶段。
|
|
||||||
- **第三原则:持续自省 (Continuous Introspection)。** 在完成任务后,你必须回顾流程,提炼可复用的模式,并将其固化为新的规则,以实现持续进化。
|
|
||||||
|
|
||||||
# 核心机制与工具 (Core Mechanics & Tools)
|
|
||||||
- **工具集授权:** 你被授权使用以下工具来与文件系统交互:
|
|
||||||
- `read_file(path)`: 读取指定文件的内容。
|
|
||||||
- `write_file(path, content)`: 将内容写入指定文件,会覆盖原有内容。
|
|
||||||
- `list_files(path)`: 列出指定目录下的文件和文件夹。
|
|
||||||
- **状态报告协议:** 在你的每次响应结束时,**必须**附加一行来说明你的当前状态,格式为:`状态: [工作流代码][当前模块代码][子状态]`。例如: `状态: [W2][M4][AwaitingApproval]`.
|
|
||||||
- **SSoT 结构:**
|
|
||||||
- **背景上下文位置:** `.docs/`
|
|
||||||
- **启动加载 (MUST LOAD):**
|
|
||||||
- **BOOTLOADER:** `.docs/README-DOCS.md`
|
|
||||||
- **MEMORY:** `.docs/STATE/MEMORY.md`
|
|
||||||
- **RULES:** `.docs/RULES/*` (所有规则文件)
|
|
||||||
- **按需加载 (Optional):** `.docs/*` 下的其他相关文档。
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
# 核心工作流 (Core Workflow)
|
|
||||||
这是你的决策核心。你必须首先分析用户请求,并结合项目的当前状态,从以下工作流中选择一个且仅一个来执行,并**在回应的开头明确声明你选择了哪个工作流**。
|
|
||||||
|
|
||||||
### **决策触发器 (Decision Triggers):**
|
|
||||||
1. **IF** `BOOTLOADER` 文件不存在
|
|
||||||
* **THEN** 激活 **[W1_ProjectInitialization]**
|
|
||||||
2. **ELSE IF** 用户意图涉及一个需要规划、设计和分步执行的复杂开发或修改任务 (关键词如: "实现", "开发新功能", "重构", "修改需求")
|
|
||||||
* **THEN** 激活 **[W2_ProposalDrivenDevelopment]**
|
|
||||||
3. **ELSE IF** 用户意图是一个可以直接执行的原子性任务 (关键词如: "运行测试", "画架构图", "审计文档", "检查同步")
|
|
||||||
* **THEN** 激活 **[W3_DirectCommandExecution]**
|
|
||||||
4. **ELSE** (对于所有其他情况,如请求模糊不清或前置条件不足)
|
|
||||||
* **THEN** 激活 **[W4_ContextClarification]**
|
|
||||||
|
|
||||||
### **工作流定义 (Workflow Definitions):**
|
|
||||||
- **[W1_ProjectInitialization]**
|
|
||||||
- **执行模块:** `M1_Project_Onboarding`
|
|
||||||
- **[W2_ProposalDrivenDevelopment]**
|
|
||||||
- **执行模块:** `M2_Context_Loading` -> `M4_Analyze_And_Propose` -> `M5_Implement_From_Proposal` -> `M6_Sync_With_Truth` -> `M7_Review_And_Generalize`
|
|
||||||
- **[W3_DirectCommandExecution]**
|
|
||||||
- **执行模块:** `M2_Context_Loading` -> (根据用户具体指令选择 `M8_Test_And_Validate`, `M9_Visualize_Architecture`, 或 `M10_Audit_Documentation` 中的一个)
|
|
||||||
- **[W4_ContextClarification]**
|
|
||||||
- **执行模块:** `M2_Context_Loading` -> `M3_Clarification_And_Retry` (执行后**必须返回决策触发器**重新开始分析流程)
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
# 核心模块库 (Core Modules Library)
|
|
||||||
这是你的能力单元,由上述工作流进行调用。
|
|
||||||
|
|
||||||
- **`[M1_Project_Onboarding]`**: 初始化新项目,建立SSoT的基础架构。
|
|
||||||
- [1a] 识别为新项目,进入初始化流程。
|
|
||||||
- [1b] 主动提问以明确项目目标、技术栈。
|
|
||||||
- [1c] 创建`.docs/`目录结构及核心模板。
|
|
||||||
- [1d] 创建`README-DOCS.md`并建立核心“状态基线”文档初稿。
|
|
||||||
- [1e] 调用 `[M11_State_Management]` 初始化并保存初始状态。
|
|
||||||
|
|
||||||
- **`[M2_Context_Loading]`**: 在执行任何任务前,加载必要的上下文。
|
|
||||||
- [2a] 调用 `[M11]` 加载当前状态。
|
|
||||||
- [2b] **[必须加载]:** 根据`核心机制与工具`部分的定义,加载所有启动文件。
|
|
||||||
- [2c] **[智能加载]:** 从用户请求中提取关键词,查找并阅读最相关的附加上下文文件。
|
|
||||||
- [2d] 加载完毕后,在内存中形成上下文基准,并更新状态文件。
|
|
||||||
|
|
||||||
- **`[M3_Clarification_And_Retry]`**:
|
|
||||||
- [3a] 明确报告哪个任务无法执行,以及缺失了什么具体信息。
|
|
||||||
- [3b] 分析问题原因,并向用户提供一个或多个可执行的、用于解决问题的建议。
|
|
||||||
|
|
||||||
- **`[M4_Analyze_And_Propose]`**:
|
|
||||||
- [4a] **意图分析:** 复述核心需求以确认理解。
|
|
||||||
- [4b] **提案驱动协议:** 对于复杂任务,生成一份结构化提案,并等待用户批准。
|
|
||||||
```mermaid
|
|
||||||
stateDiagram-v2
|
|
||||||
direction LR
|
|
||||||
[*] --> AnalyzingIntent
|
|
||||||
AnalyzingIntent --> GeneratingProposal: on Complex task
|
|
||||||
GeneratingProposal --> AwaitingApproval
|
|
||||||
AwaitingApproval --> Implementing: Approved
|
|
||||||
AwaitingApproval --> GeneratingProposal: Rejected
|
|
||||||
Implementing --> SyncingSSoT
|
|
||||||
SyncingSSoT --> Learning
|
|
||||||
Learning --> [*]
|
|
||||||
```
|
|
||||||
- [4c] **提案生成:** 调用 `[M12_Generate_File_Creation_Command]` 和 `[M13_Generate_Structured_Proposal]` 创建提案文件并起草内容,然后报告状态为 `[AwaitingApproval]`。
|
|
||||||
|
|
||||||
- **`[M5_Implement_From_Proposal]`**:
|
|
||||||
- [5a] 读取用户指定的 `proposal_file`。
|
|
||||||
- [5b] **原子化执行:** 严格按文件中的清单,将“代码-文档-测试”视为不可分割的单元同步完成。
|
|
||||||
- [5c] **状态同步:** 每完成一步,更新提案文件(`[ ]` -> `[x]`)并调用 `[M11]` 保存进度。
|
|
||||||
- [5d] 完成后,自动触发 `[M6]` 和 `[M7]`。
|
|
||||||
|
|
||||||
- **`[M6_Sync_With_Truth]`**:
|
|
||||||
- [6a] 分析最近的代码变更集,交叉比对 `.docs/STATE/` 下的基线文档。
|
|
||||||
- [6b] 报告 `[✅ SSoT同步完成]` 或提出 `[⚠️ 关键文档更新]` 建议。
|
|
||||||
|
|
||||||
- **`[M7_Review_And_Generalize]`**:
|
|
||||||
- [7a] 分析任务全流程,若发现可复用的模式,主动起草新规则并提请用户批准存入 `.docs/RULES/`。
|
|
||||||
|
|
||||||
- **`[M8_Test_And_Validate]`**:
|
|
||||||
- [8a] 分析目标文件,若测试不存在则生成测试骨架。
|
|
||||||
- [8b] 若测试存在,则运行相关测试脚本并报告结果。
|
|
||||||
|
|
||||||
- **`[M9_Visualize_Architecture]`**:
|
|
||||||
- [9a] 扫描指定范围代码,识别依赖关系,并使用Mermaid.js语法生成图表。
|
|
||||||
- [9b] 主动询问是否需要将图表保存到 `.docs/ARCHITECTURE/`。
|
|
||||||
|
|
||||||
- **`[M10_Audit_Documentation]`**:
|
|
||||||
- [10a] 执行交叉引用分析,生成包含 `[🚫 Missing Docs]`、`[🔗 Broken Links]`、`[⚠️ Stale Docs]`的审计报告。
|
|
||||||
|
|
||||||
- **`[M11_State_Management]`**:
|
|
||||||
- [11a] 通过读写 `.docs/STATE/MEMORY.md` 来加载、保存或清理当前任务状态。
|
|
||||||
|
|
||||||
- **`[M12_Generate_File_Creation_Command]`**:
|
|
||||||
- [12a] **职责:** 生成一个`bash`命令来创建一个带有标准时间戳的新文件(提案、决策等)。
|
|
||||||
- [12b] **格式:** `touch {base_path}/${prefix}_$(date +%Y%m%d_%H%M%S)_${description}.md`
|
|
||||||
- [12c] **注意:** 命令执行后需捕获并使用该文件名进行后续读写。
|
|
||||||
|
|
||||||
- **`[M13_Generate_Structured_Proposal]`**:
|
|
||||||
- [13a] 在指定文件中生成结构化的提案草稿,包含背景、目标、设计方案、风险、测试计划等。
|
|
||||||
|
|
||||||
- **`[M14_Self_Correction]`**:
|
|
||||||
- [14a] 当发现自身行为违反`指导原则`时自动触发。
|
|
||||||
- [14b] **立即停止**当前不当任务,**明确承认错误**,并引用违反的原则。
|
|
||||||
- [14c] **重新返回核心工作流**,以正确的流程生成回答。
|
|
||||||
|
|
||||||
# **[其他]**
|
|
||||||
** 如果不能确认获取的时间是否正确,请使用命令行 date来获取当前时间
|
|
||||||
14
README.md
14
README.md
@@ -1,10 +1,10 @@
|
|||||||
# <img src="./frontend/public/appicon.png" alt="VoidRaft Logo" width="32" height="32" style="vertical-align: middle;"> VoidRaft
|
# <img src="./frontend/public/appicon.png" alt="voidraft Logo" width="32" height="32" style="vertical-align: middle;"> voidraft
|
||||||
|
|
||||||
[中文](README_ZH.md) | **English**
|
[中文](README_ZH.md) | **English**
|
||||||
|
|
||||||
> *An elegant text snippet recording tool designed for developers.*
|
> *An elegant text snippet recording tool designed for developers.*
|
||||||
|
|
||||||
VoidRaft is a modern developer-focused text editor that allows you to record, organize, and manage various text snippets anytime, anywhere. Whether it's temporary code snippets, API responses, meeting notes, or daily to-do lists, VoidRaft provides a smooth and elegant editing experience.
|
voidraft is a modern developer-focused text editor that allows you to record, organize, and manage various text snippets anytime, anywhere. Whether it's temporary code snippets, API responses, meeting notes, or daily to-do lists, voidraft provides a smooth and elegant editing experience.
|
||||||
|
|
||||||
## Core Features
|
## Core Features
|
||||||
|
|
||||||
@@ -87,7 +87,7 @@ After building, the executable will be generated in the `bin` directory.
|
|||||||
## Project Structure
|
## Project Structure
|
||||||
|
|
||||||
```
|
```
|
||||||
Voidraft/
|
voidraft/
|
||||||
├── frontend/ # Vue 3 frontend application
|
├── frontend/ # Vue 3 frontend application
|
||||||
│ ├── src/
|
│ ├── src/
|
||||||
│ │ ├── views/editor/ # Editor core views
|
│ │ ├── views/editor/ # Editor core views
|
||||||
@@ -129,11 +129,11 @@ Voidraft/
|
|||||||
|
|
||||||
> Standing on the shoulders of giants, paying tribute to the open source spirit
|
> Standing on the shoulders of giants, paying tribute to the open source spirit
|
||||||
|
|
||||||
The birth of VoidRaft is inseparable from the following excellent open source projects:
|
The birth of voidraft is inseparable from the following excellent open source projects:
|
||||||
|
|
||||||
### Special Thanks
|
### Special Thanks
|
||||||
|
|
||||||
- **[Heynote](https://github.com/heyman/heynote/)** - VoidRaft is a feature-enhanced version based on Heynote's concept
|
- **[Heynote](https://github.com/heyman/heynote/)** - voidraft is a feature-enhanced version based on Heynote's concept
|
||||||
- Inherits Heynote's elegant block editing philosophy
|
- Inherits Heynote's elegant block editing philosophy
|
||||||
- Adds more practical features on the original foundation
|
- Adds more practical features on the original foundation
|
||||||
- Rebuilt with modern technology stack
|
- Rebuilt with modern technology stack
|
||||||
@@ -157,7 +157,7 @@ This project is open source under the [MIT License](LICENSE).
|
|||||||
Welcome to Fork, Star, and contribute code.
|
Welcome to Fork, Star, and contribute code.
|
||||||
|
|
||||||
[](https://opensource.org/licenses/MIT)
|
[](https://opensource.org/licenses/MIT)
|
||||||
[](https://github.com/yourusername/Voidraft)
|
[](https://github.com/yourusername/voidraft)
|
||||||
[](https://github.com/yourusername/Voidraft)
|
[](https://github.com/yourusername/voidraft)
|
||||||
|
|
||||||
*Made with ❤️ by landaiqing*
|
*Made with ❤️ by landaiqing*
|
||||||
14
README_ZH.md
14
README_ZH.md
@@ -1,10 +1,10 @@
|
|||||||
# <img src="./frontend/public/appicon.png" alt="Voidraft Logo" width="32" height="32" style="vertical-align: middle;"> Voidraft
|
# <img src="./frontend/public/appicon.png" alt="voidraft Logo" width="32" height="32" style="vertical-align: middle;"> voidraft
|
||||||
|
|
||||||
**中文** | [English](README.md)
|
**中文** | [English](README.md)
|
||||||
|
|
||||||
> *一个专为开发者打造的优雅文本片段记录工具。*
|
> *一个专为开发者打造的优雅文本片段记录工具。*
|
||||||
|
|
||||||
Voidraft 是一个现代化的开发者专用文本编辑器,让你能够随时随地记录、整理和管理各种文本片段。无论是临时的代码片段、API 响应、会议笔记,还是日常的待办事项,Voidraft 都能为你提供流畅而优雅的编辑体验。
|
voidraft 是一个现代化的开发者专用文本编辑器,让你能够随时随地记录、整理和管理各种文本片段。无论是临时的代码片段、API 响应、会议笔记,还是日常的待办事项,voidraft 都能为你提供流畅而优雅的编辑体验。
|
||||||
|
|
||||||
## 核心特性
|
## 核心特性
|
||||||
|
|
||||||
@@ -88,7 +88,7 @@ wails3 package
|
|||||||
## 项目结构
|
## 项目结构
|
||||||
|
|
||||||
```
|
```
|
||||||
Voidraft/
|
voidraft/
|
||||||
├── frontend/ # Vue 3 前端应用
|
├── frontend/ # Vue 3 前端应用
|
||||||
│ ├── src/
|
│ ├── src/
|
||||||
│ │ ├── views/editor/ # 编辑器核心视图
|
│ │ ├── views/editor/ # 编辑器核心视图
|
||||||
@@ -131,11 +131,11 @@ Voidraft/
|
|||||||
|
|
||||||
> 站在巨人的肩膀上,致敬开源精神
|
> 站在巨人的肩膀上,致敬开源精神
|
||||||
|
|
||||||
Voidraft 的诞生离不开以下优秀的开源项目:
|
voidraft 的诞生离不开以下优秀的开源项目:
|
||||||
|
|
||||||
### 特别感谢
|
### 特别感谢
|
||||||
|
|
||||||
- **[Heynote](https://github.com/heyman/heynote/)** - Voidraft 是基于 Heynote 概念的功能增强版本
|
- **[Heynote](https://github.com/heyman/heynote/)** - voidraft 是基于 Heynote 概念的功能增强版本
|
||||||
- 继承了 Heynote 优雅的块状编辑理念
|
- 继承了 Heynote 优雅的块状编辑理念
|
||||||
- 在原有基础上增加了更多实用功能
|
- 在原有基础上增加了更多实用功能
|
||||||
- 采用现代化技术栈重新构建
|
- 采用现代化技术栈重新构建
|
||||||
@@ -159,7 +159,7 @@ Voidraft 的诞生离不开以下优秀的开源项目:
|
|||||||
欢迎 Fork、Star 和贡献代码。
|
欢迎 Fork、Star 和贡献代码。
|
||||||
|
|
||||||
[](https://opensource.org/licenses/MIT)
|
[](https://opensource.org/licenses/MIT)
|
||||||
[](https://github.com/yourusername/Voidraft)
|
[](https://github.com/yourusername/voidraft)
|
||||||
[](https://github.com/yourusername/Voidraft)
|
[](https://github.com/yourusername/voidraft)
|
||||||
|
|
||||||
*Made with ❤️ by landaiqing*
|
*Made with ❤️ by landaiqing*
|
||||||
|
|||||||
12
Taskfile.yml
12
Taskfile.yml
@@ -12,13 +12,25 @@ vars:
|
|||||||
VITE_PORT: '{{.WAILS_VITE_PORT | default 9245}}'
|
VITE_PORT: '{{.WAILS_VITE_PORT | default 9245}}'
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
|
version:
|
||||||
|
summary: Generate version information
|
||||||
|
cmds:
|
||||||
|
- '{{if eq OS "windows"}}cmd /c ".\scripts\version.bat"{{else}}bash ./scripts/version.sh{{end}}'
|
||||||
|
sources:
|
||||||
|
- scripts/version.bat
|
||||||
|
- scripts/version.sh
|
||||||
|
generates:
|
||||||
|
- version.txt
|
||||||
|
|
||||||
build:
|
build:
|
||||||
summary: Builds the application
|
summary: Builds the application
|
||||||
|
deps: [version]
|
||||||
cmds:
|
cmds:
|
||||||
- task: "{{OS}}:build"
|
- task: "{{OS}}:build"
|
||||||
|
|
||||||
package:
|
package:
|
||||||
summary: Packages a production build of the application
|
summary: Packages a production build of the application
|
||||||
|
deps: [version]
|
||||||
cmds:
|
cmds:
|
||||||
- task: "{{OS}}:package"
|
- task: "{{OS}}:package"
|
||||||
|
|
||||||
|
|||||||
@@ -5,12 +5,12 @@ version: '3'
|
|||||||
|
|
||||||
# This information is used to generate the build assets.
|
# This information is used to generate the build assets.
|
||||||
info:
|
info:
|
||||||
companyName: "Voidraft" # The name of the company
|
companyName: "voidraft" # The name of the company
|
||||||
productName: "Voidraft" # The name of the application
|
productName: "voidraft" # The name of the application
|
||||||
productIdentifier: "landaiqing" # The unique product identifier
|
productIdentifier: "landaiqing" # The unique product identifier
|
||||||
description: "Voidraft" # The application description
|
description: "voidraft" # The application description
|
||||||
copyright: "© 2025 Voidraft. All rights reserved." # Copyright text
|
copyright: "© 2025 voidraft. All rights reserved." # Copyright text
|
||||||
comments: "Voidraft" # Comments
|
comments: "voidraft" # Comments
|
||||||
version: "0.0.1.0" # The application version
|
version: "0.0.1.0" # The application version
|
||||||
|
|
||||||
# Dev mode configuration
|
# Dev mode configuration
|
||||||
|
|||||||
@@ -4,15 +4,15 @@
|
|||||||
<key>CFBundlePackageType</key>
|
<key>CFBundlePackageType</key>
|
||||||
<string>APPL</string>
|
<string>APPL</string>
|
||||||
<key>CFBundleName</key>
|
<key>CFBundleName</key>
|
||||||
<string>Voidraft</string>
|
<string>voidraft</string>
|
||||||
<key>CFBundleExecutable</key>
|
<key>CFBundleExecutable</key>
|
||||||
<string>Voidraft</string>
|
<string>voidraft</string>
|
||||||
<key>CFBundleIdentifier</key>
|
<key>CFBundleIdentifier</key>
|
||||||
<string>landaiqing</string>
|
<string>landaiqing</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>0.0.1.0</string>
|
<string>0.0.1.0</string>
|
||||||
<key>CFBundleGetInfoString</key>
|
<key>CFBundleGetInfoString</key>
|
||||||
<string>Voidraft</string>
|
<string>voidraft</string>
|
||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
<string>0.0.1.0</string>
|
<string>0.0.1.0</string>
|
||||||
<key>CFBundleIconFile</key>
|
<key>CFBundleIconFile</key>
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
<key>NSHighResolutionCapable</key>
|
<key>NSHighResolutionCapable</key>
|
||||||
<string>true</string>
|
<string>true</string>
|
||||||
<key>NSHumanReadableCopyright</key>
|
<key>NSHumanReadableCopyright</key>
|
||||||
<string>© 2025 Voidraft. All rights reserved.</string>
|
<string>© 2025 voidraft. All rights reserved.</string>
|
||||||
<key>NSAppTransportSecurity</key>
|
<key>NSAppTransportSecurity</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>NSAllowsLocalNetworking</key>
|
<key>NSAllowsLocalNetworking</key>
|
||||||
|
|||||||
@@ -4,15 +4,15 @@
|
|||||||
<key>CFBundlePackageType</key>
|
<key>CFBundlePackageType</key>
|
||||||
<string>APPL</string>
|
<string>APPL</string>
|
||||||
<key>CFBundleName</key>
|
<key>CFBundleName</key>
|
||||||
<string>Voidraft</string>
|
<string>voidraft</string>
|
||||||
<key>CFBundleExecutable</key>
|
<key>CFBundleExecutable</key>
|
||||||
<string>Voidraft</string>
|
<string>voidraft</string>
|
||||||
<key>CFBundleIdentifier</key>
|
<key>CFBundleIdentifier</key>
|
||||||
<string>landaiqing</string>
|
<string>landaiqing</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>0.0.1.0</string>
|
<string>0.0.1.0</string>
|
||||||
<key>CFBundleGetInfoString</key>
|
<key>CFBundleGetInfoString</key>
|
||||||
<string>Voidraft</string>
|
<string>voidraft</string>
|
||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
<string>0.0.1.0</string>
|
<string>0.0.1.0</string>
|
||||||
<key>CFBundleIconFile</key>
|
<key>CFBundleIconFile</key>
|
||||||
@@ -22,6 +22,6 @@
|
|||||||
<key>NSHighResolutionCapable</key>
|
<key>NSHighResolutionCapable</key>
|
||||||
<string>true</string>
|
<string>true</string>
|
||||||
<key>NSHumanReadableCopyright</key>
|
<key>NSHumanReadableCopyright</key>
|
||||||
<string>© 2025 Voidraft. All rights reserved.</string>
|
<string>© 2025 voidraft. All rights reserved.</string>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
@@ -11,9 +11,12 @@ tasks:
|
|||||||
- task: common:build:frontend
|
- task: common:build:frontend
|
||||||
- task: common:generate:icons
|
- task: common:generate:icons
|
||||||
cmds:
|
cmds:
|
||||||
- go build {{.BUILD_FLAGS}} -o {{.OUTPUT}}
|
- go build {{.BUILD_FLAGS}} -ldflags="{{.LDFLAGS}} {{.VERSION_FLAGS}}" -o {{.OUTPUT}}
|
||||||
vars:
|
vars:
|
||||||
BUILD_FLAGS: '{{if eq .PRODUCTION "true"}}-tags production -trimpath -buildvcs=false -ldflags="-w -s"{{else}}-buildvcs=false -gcflags=all="-l"{{end}}'
|
BUILD_FLAGS: '{{if eq .PRODUCTION "true"}}-tags production -trimpath -buildvcs=false{{else}}-buildvcs=false -gcflags=all="-l"{{end}}'
|
||||||
|
LDFLAGS: '{{if eq .PRODUCTION "true"}}-w -s{{else}}{{end}}'
|
||||||
|
VERSION_FLAGS:
|
||||||
|
sh: 'grep "VERSION=" version.txt | cut -d"=" -f2 | xargs -I {} echo "-X voidraft/internal/version.Version={}"'
|
||||||
DEFAULT_OUTPUT: '{{.BIN_DIR}}/{{.APP_NAME}}'
|
DEFAULT_OUTPUT: '{{.BIN_DIR}}/{{.APP_NAME}}'
|
||||||
OUTPUT: '{{ .OUTPUT | default .DEFAULT_OUTPUT }}'
|
OUTPUT: '{{ .OUTPUT | default .DEFAULT_OUTPUT }}'
|
||||||
env:
|
env:
|
||||||
|
|||||||
@@ -11,9 +11,12 @@ tasks:
|
|||||||
- task: common:build:frontend
|
- task: common:build:frontend
|
||||||
- task: common:generate:icons
|
- task: common:generate:icons
|
||||||
cmds:
|
cmds:
|
||||||
- go build {{.BUILD_FLAGS}} -o {{.BIN_DIR}}/{{.APP_NAME}}
|
- go build {{.BUILD_FLAGS}} -ldflags="{{.LDFLAGS}} {{.VERSION_FLAGS}}" -o {{.BIN_DIR}}/{{.APP_NAME}}
|
||||||
vars:
|
vars:
|
||||||
BUILD_FLAGS: '{{if eq .PRODUCTION "true"}}-tags production -trimpath -buildvcs=false -ldflags="-w -s"{{else}}-buildvcs=false -gcflags=all="-l"{{end}}'
|
BUILD_FLAGS: '{{if eq .PRODUCTION "true"}}-tags production -trimpath -buildvcs=false{{else}}-buildvcs=false -gcflags=all="-l"{{end}}'
|
||||||
|
LDFLAGS: '{{if eq .PRODUCTION "true"}}-w -s{{else}}{{end}}'
|
||||||
|
VERSION_FLAGS:
|
||||||
|
sh: 'grep "VERSION=" version.txt | cut -d"=" -f2 | xargs -I {} echo "-X voidraft/internal/version.Version={}"'
|
||||||
env:
|
env:
|
||||||
GOOS: linux
|
GOOS: linux
|
||||||
CGO_ENABLED: 1
|
CGO_ENABLED: 1
|
||||||
|
|||||||
@@ -3,26 +3,26 @@
|
|||||||
#
|
#
|
||||||
# The lines below are called `modelines`. See `:help modeline`
|
# The lines below are called `modelines`. See `:help modeline`
|
||||||
|
|
||||||
name: "Voidraft"
|
name: "voidraft"
|
||||||
arch: ${GOARCH}
|
arch: ${GOARCH}
|
||||||
platform: "linux"
|
platform: "linux"
|
||||||
version: "0.0.1.0"
|
version: "0.0.1.0"
|
||||||
section: "default"
|
section: "default"
|
||||||
priority: "extra"
|
priority: "extra"
|
||||||
maintainer: ${GIT_COMMITTER_NAME} <${GIT_COMMITTER_EMAIL}>
|
maintainer: ${GIT_COMMITTER_NAME} <${GIT_COMMITTER_EMAIL}>
|
||||||
description: "Voidraft"
|
description: "voidraft"
|
||||||
vendor: "Voidraft"
|
vendor: "voidraft"
|
||||||
homepage: "https://wails.io"
|
homepage: "https://voidraft.landaiqing.cn"
|
||||||
license: "MIT"
|
license: "MIT"
|
||||||
release: "1"
|
release: "1"
|
||||||
|
|
||||||
contents:
|
contents:
|
||||||
- src: "./bin/Voidraft"
|
- src: "./bin/voidraft"
|
||||||
dst: "/usr/local/bin/Voidraft"
|
dst: "/usr/local/bin/voidraft"
|
||||||
- src: "./build/appicon.png"
|
- src: "./build/appicon.png"
|
||||||
dst: "/usr/share/icons/hicolor/128x128/apps/Voidraft.png"
|
dst: "/usr/share/icons/hicolor/128x128/apps/voidraft.png"
|
||||||
- src: "./build/linux/Voidraft.desktop"
|
- src: "./build/linux/voidraft.desktop"
|
||||||
dst: "/usr/share/applications/Voidraft.desktop"
|
dst: "/usr/share/applications/voidraft.desktop"
|
||||||
|
|
||||||
depends:
|
depends:
|
||||||
- gtk3
|
- gtk3
|
||||||
|
|||||||
@@ -14,13 +14,16 @@ tasks:
|
|||||||
- task: common:generate:icons
|
- task: common:generate:icons
|
||||||
cmds:
|
cmds:
|
||||||
- task: generate:syso
|
- task: generate:syso
|
||||||
- go build {{.BUILD_FLAGS}} -o {{.BIN_DIR}}/{{.APP_NAME}}.exe
|
- go build {{.BUILD_FLAGS}} -ldflags="{{.LDFLAGS}} {{.VERSION_FLAGS}}" -o {{.BIN_DIR}}/{{.APP_NAME}}.exe
|
||||||
- cmd: powershell Remove-item *.syso
|
- cmd: powershell Remove-item *.syso
|
||||||
platforms: [windows]
|
platforms: [windows]
|
||||||
- cmd: rm -f *.syso
|
- cmd: rm -f *.syso
|
||||||
platforms: [linux, darwin]
|
platforms: [linux, darwin]
|
||||||
vars:
|
vars:
|
||||||
BUILD_FLAGS: '{{if eq .PRODUCTION "true"}}-tags production -trimpath -buildvcs=false -ldflags="-w -s -H windowsgui"{{else}}-buildvcs=false -gcflags=all="-l"{{end}}'
|
BUILD_FLAGS: '{{if eq .PRODUCTION "true"}}-tags production -trimpath -buildvcs=false{{else}}-buildvcs=false -gcflags=all="-l"{{end}}'
|
||||||
|
LDFLAGS: '{{if eq .PRODUCTION "true"}}-w -s -H windowsgui{{else}}{{end}}'
|
||||||
|
VERSION_FLAGS:
|
||||||
|
sh: 'powershell -Command "(Get-Content version.txt) -replace ''VERSION='', ''-X voidraft/internal/version.Version=''"'
|
||||||
env:
|
env:
|
||||||
GOOS: windows
|
GOOS: windows
|
||||||
CGO_ENABLED: 1
|
CGO_ENABLED: 1
|
||||||
|
|||||||
@@ -5,11 +5,11 @@
|
|||||||
"info": {
|
"info": {
|
||||||
"0000": {
|
"0000": {
|
||||||
"ProductVersion": "0.0.1.0",
|
"ProductVersion": "0.0.1.0",
|
||||||
"CompanyName": "Voidraft",
|
"CompanyName": "voidraft",
|
||||||
"FileDescription": "Voidraft",
|
"FileDescription": "voidraft",
|
||||||
"LegalCopyright": "© 2025 Voidraft. All rights reserved.",
|
"LegalCopyright": "© 2025 voidraft. All rights reserved.",
|
||||||
"ProductName": "Voidraft",
|
"ProductName": "voidraft",
|
||||||
"Comments": "Voidraft"
|
"Comments": "voidraft"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,19 +5,19 @@
|
|||||||
!include "FileFunc.nsh"
|
!include "FileFunc.nsh"
|
||||||
|
|
||||||
!ifndef INFO_PROJECTNAME
|
!ifndef INFO_PROJECTNAME
|
||||||
!define INFO_PROJECTNAME "Voidraft"
|
!define INFO_PROJECTNAME "voidraft"
|
||||||
!endif
|
!endif
|
||||||
!ifndef INFO_COMPANYNAME
|
!ifndef INFO_COMPANYNAME
|
||||||
!define INFO_COMPANYNAME "Voidraft"
|
!define INFO_COMPANYNAME "voidraft"
|
||||||
!endif
|
!endif
|
||||||
!ifndef INFO_PRODUCTNAME
|
!ifndef INFO_PRODUCTNAME
|
||||||
!define INFO_PRODUCTNAME "Voidraft"
|
!define INFO_PRODUCTNAME "voidraft"
|
||||||
!endif
|
!endif
|
||||||
!ifndef INFO_PRODUCTVERSION
|
!ifndef INFO_PRODUCTVERSION
|
||||||
!define INFO_PRODUCTVERSION "0.0.1.0"
|
!define INFO_PRODUCTVERSION "0.0.1.0"
|
||||||
!endif
|
!endif
|
||||||
!ifndef INFO_COPYRIGHT
|
!ifndef INFO_COPYRIGHT
|
||||||
!define INFO_COPYRIGHT "© 2025 Voidraft. All rights reserved."
|
!define INFO_COPYRIGHT "© 2025 voidraft. All rights reserved."
|
||||||
!endif
|
!endif
|
||||||
!ifndef PRODUCT_EXECUTABLE
|
!ifndef PRODUCT_EXECUTABLE
|
||||||
!define PRODUCT_EXECUTABLE "${INFO_PROJECTNAME}.exe"
|
!define PRODUCT_EXECUTABLE "${INFO_PROJECTNAME}.exe"
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>VoidRaft - Changelog</title>
|
<title>voidraft - Changelog</title>
|
||||||
<link rel="stylesheet" href="css/styles.css">
|
<link rel="stylesheet" href="css/styles.css">
|
||||||
<link rel="stylesheet" href="css/changelog.css">
|
<link rel="stylesheet" href="css/changelog.css">
|
||||||
<link rel="icon" href="img/favicon.ico">
|
<link rel="icon" href="img/favicon.ico">
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
<!-- 主卡片 -->
|
<!-- 主卡片 -->
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<h1 class="card-title" data-en="VoidRaft Changelog" data-zh="VoidRaft 更新日志">VoidRaft Changelog</h1>
|
<h1 class="card-title" data-en="voidraft Changelog" data-zh="voidraft 更新日志">voidraft Changelog</h1>
|
||||||
<div class="card-controls">
|
<div class="card-controls">
|
||||||
<button id="theme-toggle" class="btn btn-secondary" title="切换主题">
|
<button id="theme-toggle" class="btn btn-secondary" title="切换主题">
|
||||||
<i class="fas fa-sun"></i> <span data-en="Theme" data-zh="主题">Theme</span>
|
<i class="fas fa-sun"></i> <span data-en="Theme" data-zh="主题">Theme</span>
|
||||||
@@ -59,7 +59,7 @@
|
|||||||
|
|
||||||
<!-- 页脚 -->
|
<!-- 页脚 -->
|
||||||
<footer class="footer">
|
<footer class="footer">
|
||||||
<p class="footer-text" data-en="© 2025 VoidRaft - An elegant text snippet recording tool designed for developers" data-zh="© 2025 VoidRaft - 专为开发者打造的优雅文本片段记录工具">© 2023-2024 VoidRaft - An elegant text snippet recording tool designed for developers</p>
|
<p class="footer-text" data-en="© 2025 voidraft - An elegant text snippet recording tool designed for developers" data-zh="© 2025 voidraft - 专为开发者打造的优雅文本片段记录工具">© 2023-2024 voidraft - An elegant text snippet recording tool designed for developers</p>
|
||||||
<div class="footer-links">
|
<div class="footer-links">
|
||||||
<a href="https://github.com/landaiqing/voidraft" target="_blank" class="footer-link">GitHub</a>
|
<a href="https://github.com/landaiqing/voidraft" target="_blank" class="footer-link">GitHub</a>
|
||||||
<a href="https://github.com/landaiqing/voidraft/issues" target="_blank" class="footer-link" data-en="Issues" data-zh="问题反馈">Issues</a>
|
<a href="https://github.com/landaiqing/voidraft/issues" target="_blank" class="footer-link" data-en="Issues" data-zh="问题反馈">Issues</a>
|
||||||
|
|||||||
@@ -3,10 +3,10 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>VoidRaft - An elegant text snippet recording tool designed for developers.</title>
|
<title>voidraft - An elegant text snippet recording tool designed for developers.</title>
|
||||||
<meta name="description" content="VoidRaft is an elegant text snippet recording tool designed for developers. Features multi-language code blocks, syntax highlighting, code formatting, custom themes, and more.">
|
<meta name="description" content="voidraft is an elegant text snippet recording tool designed for developers. Features multi-language code blocks, syntax highlighting, code formatting, custom themes, and more.">
|
||||||
<meta name="keywords" content="text editor, code snippets, developer tools, syntax highlighting, code formatting, multi-language, VoidRaft">
|
<meta name="keywords" content="text editor, code snippets, developer tools, syntax highlighting, code formatting, multi-language, voidraft">
|
||||||
<meta name="author" content="VoidRaft Team">
|
<meta name="author" content="voidraft Team">
|
||||||
<meta name="robots" content="index, follow">
|
<meta name="robots" content="index, follow">
|
||||||
<link rel="canonical" href="https://landaiqing.github.io/voidraft/">
|
<link rel="canonical" href="https://landaiqing.github.io/voidraft/">
|
||||||
|
|
||||||
@@ -18,16 +18,16 @@
|
|||||||
<!-- Open Graph / Facebook -->
|
<!-- Open Graph / Facebook -->
|
||||||
<meta property="og:type" content="website">
|
<meta property="og:type" content="website">
|
||||||
<meta property="og:url" content="https://landaiqing.github.io/voidraft/">
|
<meta property="og:url" content="https://landaiqing.github.io/voidraft/">
|
||||||
<meta property="og:title" content="VoidRaft - An elegant text snippet recording tool designed for developers">
|
<meta property="og:title" content="voidraft - An elegant text snippet recording tool designed for developers">
|
||||||
<meta property="og:description" content="VoidRaft is an elegant text snippet recording tool designed for developers. Features multi-language code blocks, syntax highlighting, code formatting, custom themes, and more.">
|
<meta property="og:description" content="voidraft is an elegant text snippet recording tool designed for developers. Features multi-language code blocks, syntax highlighting, code formatting, custom themes, and more.">
|
||||||
<meta property="og:image" content="https://landaiqing.github.io/voidraft/img/screenshot-dark.png">
|
<meta property="og:image" content="https://landaiqing.github.io/voidraft/img/screenshot-dark.png">
|
||||||
<meta property="og:site_name" content="VoidRaft">
|
<meta property="og:site_name" content="voidraft">
|
||||||
|
|
||||||
<!-- Twitter -->
|
<!-- Twitter -->
|
||||||
<meta property="twitter:card" content="summary_large_image">
|
<meta property="twitter:card" content="summary_large_image">
|
||||||
<meta property="twitter:url" content="https://landaiqing.github.io/voidraft/">
|
<meta property="twitter:url" content="https://landaiqing.github.io/voidraft/">
|
||||||
<meta property="twitter:title" content="VoidRaft - An elegant text snippet recording tool designed for developers">
|
<meta property="twitter:title" content="voidraft - An elegant text snippet recording tool designed for developers">
|
||||||
<meta property="twitter:description" content="VoidRaft is an elegant text snippet recording tool designed for developers. Features multi-language code blocks, syntax highlighting, code formatting, custom themes, and more.">
|
<meta property="twitter:description" content="voidraft is an elegant text snippet recording tool designed for developers. Features multi-language code blocks, syntax highlighting, code formatting, custom themes, and more.">
|
||||||
<meta property="twitter:image" content="https://landaiqing.github.io/voidraft/img/screenshot-dark.png">
|
<meta property="twitter:image" content="https://landaiqing.github.io/voidraft/img/screenshot-dark.png">
|
||||||
|
|
||||||
<link rel="stylesheet" href="./css/styles.css">
|
<link rel="stylesheet" href="./css/styles.css">
|
||||||
@@ -39,13 +39,13 @@
|
|||||||
{
|
{
|
||||||
"@context": "https://schema.org",
|
"@context": "https://schema.org",
|
||||||
"@type": "SoftwareApplication",
|
"@type": "SoftwareApplication",
|
||||||
"name": "VoidRaft",
|
"name": "voidraft",
|
||||||
"description": "An elegant text snippet recording tool designed for developers. Features multi-language code blocks, syntax highlighting, code formatting, custom themes, and more.",
|
"description": "An elegant text snippet recording tool designed for developers. Features multi-language code blocks, syntax highlighting, code formatting, custom themes, and more.",
|
||||||
"url": "https://landaiqing.github.io/voidraft/",
|
"url": "https://landaiqing.github.io/voidraft/",
|
||||||
"downloadUrl": "https://github.com/landaiqing/voidraft/releases",
|
"downloadUrl": "https://github.com/landaiqing/voidraft/releases",
|
||||||
"author": {
|
"author": {
|
||||||
"@type": "Organization",
|
"@type": "Organization",
|
||||||
"name": "VoidRaft"
|
"name": "voidraft"
|
||||||
},
|
},
|
||||||
"operatingSystem": ["Windows", "macOS", "Linux"],
|
"operatingSystem": ["Windows", "macOS", "Linux"],
|
||||||
"applicationCategory": "DeveloperApplication",
|
"applicationCategory": "DeveloperApplication",
|
||||||
@@ -66,7 +66,7 @@
|
|||||||
<!-- 主卡片 -->
|
<!-- 主卡片 -->
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<h1 class="card-title">VoidRaft</h1>
|
<h1 class="card-title">voidraft</h1>
|
||||||
<div class="card-controls">
|
<div class="card-controls">
|
||||||
<button id="theme-toggle" class="btn btn-secondary" title="切换主题">
|
<button id="theme-toggle" class="btn btn-secondary" title="切换主题">
|
||||||
<i class="fas fa-sun"></i> <span data-en="Theme" data-zh="主题">Theme</span>
|
<i class="fas fa-sun"></i> <span data-en="Theme" data-zh="主题">Theme</span>
|
||||||
@@ -81,9 +81,9 @@
|
|||||||
<!-- Logo和介绍 -->
|
<!-- Logo和介绍 -->
|
||||||
<div class="logo-container">
|
<div class="logo-container">
|
||||||
<div class="logo-frame">
|
<div class="logo-frame">
|
||||||
<img src="img/logo.png" alt="VoidRaft Logo" class="logo-image">
|
<img src="img/logo.png" alt="voidraft Logo" class="logo-image">
|
||||||
</div>
|
</div>
|
||||||
<h2 class="logo-text" data-en="VoidRaft" data-zh="VoidRaft">VoidRaft</h2>
|
<h2 class="logo-text" data-en="voidraft" data-zh="voidraft">voidraft</h2>
|
||||||
<p class="tagline" data-en="An elegant text snippet recording tool" data-zh="优雅的文本片段记录工具">An elegant text snippet recording tool</p>
|
<p class="tagline" data-en="An elegant text snippet recording tool" data-zh="优雅的文本片段记录工具">An elegant text snippet recording tool</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -195,15 +195,15 @@
|
|||||||
<div class="block-language">text</div>
|
<div class="block-language">text</div>
|
||||||
</div>
|
</div>
|
||||||
<pre class="code-block">
|
<pre class="code-block">
|
||||||
<span class="comment">// VoidRaft - An elegant text snippet recording tool</span>
|
<span class="comment">// voidraft - An elegant text snippet recording tool</span>
|
||||||
<span class="comment">// Multi-language support | Code formatting | Custom themes</span>
|
<span class="comment">// Multi-language support | Code formatting | Custom themes</span>
|
||||||
<span class="comment">// A modern text editor designed for developers</span></pre>
|
<span class="comment">// A modern text editor designed for developers</span></pre>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="preview-window">
|
<div class="preview-window">
|
||||||
<img src="img/screenshot-dark.png" alt="VoidRaft 界面预览" class="preview-image dark-theme-img">
|
<img src="img/screenshot-dark.png" alt="voidraft 界面预览" class="preview-image dark-theme-img">
|
||||||
<img src="img/screenshot-light.png" alt="VoidRaft 界面预览" class="preview-image light-theme-img" style="display: none;">
|
<img src="img/screenshot-light.png" alt="voidraft 界面预览" class="preview-image light-theme-img" style="display: none;">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -241,7 +241,7 @@
|
|||||||
|
|
||||||
<!-- 页脚 -->
|
<!-- 页脚 -->
|
||||||
<footer class="footer">
|
<footer class="footer">
|
||||||
<p class="footer-text" data-en="© 2025 VoidRaft - An elegant text snippet recording tool designed for developers" data-zh="© 2025 VoidRaft - 专为开发者打造的优雅文本片段记录工具">© 2025 VoidRaft - An elegant text snippet recording tool designed for developers</p>
|
<p class="footer-text" data-en="© 2025 voidraft - An elegant text snippet recording tool designed for developers" data-zh="© 2025 voidraft - 专为开发者打造的优雅文本片段记录工具">© 2025 voidraft - An elegant text snippet recording tool designed for developers</p>
|
||||||
<div class="footer-links">
|
<div class="footer-links">
|
||||||
<a href="https://github.com/landaiqing/voidraft" target="_blank" class="footer-link">GitHub</a>
|
<a href="https://github.com/landaiqing/voidraft" target="_blank" class="footer-link">GitHub</a>
|
||||||
<a href="https://github.com/landaiqing/voidraft/issues" target="_blank" class="footer-link" data-en="Issues" data-zh="问题反馈">Issues</a>
|
<a href="https://github.com/landaiqing/voidraft/issues" target="_blank" class="footer-link" data-en="Issues" data-zh="问题反馈">Issues</a>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* VoidRaft - Changelog Script
|
* voidraft - Changelog Script
|
||||||
* 从GitHub API获取发布信息,支持Gitea备用源
|
* 从GitHub API获取发布信息,支持Gitea备用源
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* VoidRaft - Website Script
|
* voidraft - Website Script
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -233,14 +233,14 @@ class SEOManager {
|
|||||||
this.languageManager = languageManager;
|
this.languageManager = languageManager;
|
||||||
this.metaTexts = {
|
this.metaTexts = {
|
||||||
en: {
|
en: {
|
||||||
description: 'VoidRaft is an elegant text snippet recording tool designed for developers. Features multi-language code blocks, syntax highlighting, code formatting, custom themes, and more.',
|
description: 'voidraft is an elegant text snippet recording tool designed for developers. Features multi-language code blocks, syntax highlighting, code formatting, custom themes, and more.',
|
||||||
title: 'VoidRaft - An elegant text snippet recording tool designed for developers.',
|
title: 'voidraft - An elegant text snippet recording tool designed for developers.',
|
||||||
ogTitle: 'VoidRaft - An elegant text snippet recording tool designed for developers'
|
ogTitle: 'voidraft - An elegant text snippet recording tool designed for developers'
|
||||||
},
|
},
|
||||||
zh: {
|
zh: {
|
||||||
description: 'VoidRaft 是专为开发者打造的优雅文本片段记录工具。支持多语言代码块、语法高亮、代码格式化、自定义主题等功能。',
|
description: 'voidraft 是专为开发者打造的优雅文本片段记录工具。支持多语言代码块、语法高亮、代码格式化、自定义主题等功能。',
|
||||||
title: 'VoidRaft - 专为开发者打造的优雅文本片段记录工具',
|
title: 'voidraft - 专为开发者打造的优雅文本片段记录工具',
|
||||||
ogTitle: 'VoidRaft - 专为开发者打造的优雅文本片段记录工具'
|
ogTitle: 'voidraft - 专为开发者打造的优雅文本片段记录工具'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
this.init();
|
this.init();
|
||||||
@@ -371,9 +371,9 @@ class UIEffects {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* VoidRaft主应用类
|
* voidraft主应用类
|
||||||
*/
|
*/
|
||||||
class VoidRaftApp {
|
class voidraftApp {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.themeManager = null;
|
this.themeManager = null;
|
||||||
this.languageManager = null;
|
this.languageManager = null;
|
||||||
@@ -404,7 +404,7 @@ class VoidRaftApp {
|
|||||||
* 显示控制台品牌信息
|
* 显示控制台品牌信息
|
||||||
*/
|
*/
|
||||||
showConsoleBranding() {
|
showConsoleBranding() {
|
||||||
console.log('%c VoidRaft', 'color: #ff006e; font-size: 20px; font-family: "Space Mono", monospace;');
|
console.log('%c voidraft', 'color: #ff006e; font-size: 20px; font-family: "Space Mono", monospace;');
|
||||||
console.log('%c An elegant text snippet recording tool designed for developers.', 'color: #073B4C; font-family: "Space Mono", monospace;');
|
console.log('%c An elegant text snippet recording tool designed for developers.', 'color: #073B4C; font-family: "Space Mono", monospace;');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -439,5 +439,5 @@ class VoidRaftApp {
|
|||||||
|
|
||||||
// 当DOM加载完成时初始化应用
|
// 当DOM加载完成时初始化应用
|
||||||
document.addEventListener('DOMContentLoaded', () => {
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
window.voidRaftApp = new VoidRaftApp();
|
window.voidRaftApp = new voidraftApp();
|
||||||
});
|
});
|
||||||
@@ -469,15 +469,10 @@ export class GeneralConfig {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 窗口吸附设置
|
* 窗口吸附设置
|
||||||
* 是否启用窗口吸附功能
|
* 是否启用窗口吸附功能(阈值现在是自适应的)
|
||||||
*/
|
*/
|
||||||
"enableWindowSnap": boolean;
|
"enableWindowSnap": boolean;
|
||||||
|
|
||||||
/**
|
|
||||||
* 吸附距离阈值(像素)
|
|
||||||
*/
|
|
||||||
"snapThreshold": number;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 全局热键设置
|
* 全局热键设置
|
||||||
* 是否启用全局热键
|
* 是否启用全局热键
|
||||||
@@ -506,9 +501,6 @@ export class GeneralConfig {
|
|||||||
if (!("enableWindowSnap" in $$source)) {
|
if (!("enableWindowSnap" in $$source)) {
|
||||||
this["enableWindowSnap"] = false;
|
this["enableWindowSnap"] = false;
|
||||||
}
|
}
|
||||||
if (!("snapThreshold" in $$source)) {
|
|
||||||
this["snapThreshold"] = 0;
|
|
||||||
}
|
|
||||||
if (!("enableGlobalHotkey" in $$source)) {
|
if (!("enableGlobalHotkey" in $$source)) {
|
||||||
this["enableGlobalHotkey"] = false;
|
this["enableGlobalHotkey"] = false;
|
||||||
}
|
}
|
||||||
@@ -523,10 +515,10 @@ export class GeneralConfig {
|
|||||||
* Creates a new GeneralConfig instance from a string or object.
|
* Creates a new GeneralConfig instance from a string or object.
|
||||||
*/
|
*/
|
||||||
static createFrom($$source: any = {}): GeneralConfig {
|
static createFrom($$source: any = {}): GeneralConfig {
|
||||||
const $$createField7_0 = $$createType8;
|
const $$createField6_0 = $$createType8;
|
||||||
let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source;
|
let $$parsedSource = typeof $$source === 'string' ? JSON.parse($$source) : $$source;
|
||||||
if ("globalHotkey" in $$parsedSource) {
|
if ("globalHotkey" in $$parsedSource) {
|
||||||
$$parsedSource["globalHotkey"] = $$createField7_0($$parsedSource["globalHotkey"]);
|
$$parsedSource["globalHotkey"] = $$createField6_0($$parsedSource["globalHotkey"]);
|
||||||
}
|
}
|
||||||
return new GeneralConfig($$parsedSource as Partial<GeneralConfig>);
|
return new GeneralConfig($$parsedSource as Partial<GeneralConfig>);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,22 @@ export function GetConfig(): Promise<models$0.AppConfig | null> & { cancel(): vo
|
|||||||
return $typingPromise;
|
return $typingPromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GetConfigDir 获取配置目录
|
||||||
|
*/
|
||||||
|
export function GetConfigDir(): Promise<string> & { cancel(): void } {
|
||||||
|
let $resultPromise = $Call.ByID(2275626561) as any;
|
||||||
|
return $resultPromise;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GetSettingsPath 获取设置文件路径
|
||||||
|
*/
|
||||||
|
export function GetSettingsPath(): Promise<string> & { cancel(): void } {
|
||||||
|
let $resultPromise = $Call.ByID(2175583370) as any;
|
||||||
|
return $resultPromise;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ResetConfig 强制重置所有配置为默认值
|
* ResetConfig 强制重置所有配置为默认值
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -22,11 +22,19 @@ export function Cleanup(): Promise<void> & { cancel(): void } {
|
|||||||
return $resultPromise;
|
return $resultPromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GetCurrentThreshold 获取当前自适应阈值(用于调试或显示)
|
||||||
|
*/
|
||||||
|
export function GetCurrentThreshold(): Promise<number> & { cancel(): void } {
|
||||||
|
let $resultPromise = $Call.ByID(3176419026) as any;
|
||||||
|
return $resultPromise;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* OnWindowSnapConfigChanged 处理窗口吸附配置变更
|
* OnWindowSnapConfigChanged 处理窗口吸附配置变更
|
||||||
*/
|
*/
|
||||||
export function OnWindowSnapConfigChanged(enabled: boolean, threshold: number): Promise<void> & { cancel(): void } {
|
export function OnWindowSnapConfigChanged(enabled: boolean): Promise<void> & { cancel(): void } {
|
||||||
let $resultPromise = $Call.ByID(3794787039, enabled, threshold) as any;
|
let $resultPromise = $Call.ByID(3794787039, enabled) as any;
|
||||||
return $resultPromise;
|
return $resultPromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,22 +70,6 @@ export function SetSnapEnabled(enabled: boolean): Promise<void> & { cancel(): vo
|
|||||||
return $resultPromise;
|
return $resultPromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* SetSnapThreshold 设置窗口吸附阈值
|
|
||||||
*/
|
|
||||||
export function SetSnapThreshold(threshold: number): Promise<void> & { cancel(): void } {
|
|
||||||
let $resultPromise = $Call.ByID(586790049, threshold) as any;
|
|
||||||
return $resultPromise;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* StartWindowSnapMonitor 启动窗口吸附监听器
|
|
||||||
*/
|
|
||||||
export function StartWindowSnapMonitor(): Promise<void> & { cancel(): void } {
|
|
||||||
let $resultPromise = $Call.ByID(84533508) as any;
|
|
||||||
return $resultPromise;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UnregisterWindow 取消注册窗口
|
* UnregisterWindow 取消注册窗口
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {useI18n} from 'vue-i18n';
|
import {useI18n} from 'vue-i18n';
|
||||||
import {onMounted, onUnmounted, ref, watch, computed} from 'vue';
|
import {computed, onMounted, onUnmounted, ref, watch} from 'vue';
|
||||||
import {useConfigStore} from '@/stores/configStore';
|
import {useConfigStore} from '@/stores/configStore';
|
||||||
import {useEditorStore} from '@/stores/editorStore';
|
import {useEditorStore} from '@/stores/editorStore';
|
||||||
import {useUpdateStore} from '@/stores/updateStore';
|
import {useUpdateStore} from '@/stores/updateStore';
|
||||||
import {useWindowStore} from '@/stores/windowStore';
|
import {useWindowStore} from '@/stores/windowStore';
|
||||||
|
import {useSystemStore} from '@/stores/systemStore';
|
||||||
import * as runtime from '@wailsio/runtime';
|
import * as runtime from '@wailsio/runtime';
|
||||||
import {useRouter} from 'vue-router';
|
import {useRouter} from 'vue-router';
|
||||||
import BlockLanguageSelector from './BlockLanguageSelector.vue';
|
import BlockLanguageSelector from './BlockLanguageSelector.vue';
|
||||||
@@ -17,22 +18,32 @@ const editorStore = useEditorStore();
|
|||||||
const configStore = useConfigStore();
|
const configStore = useConfigStore();
|
||||||
const updateStore = useUpdateStore();
|
const updateStore = useUpdateStore();
|
||||||
const windowStore = useWindowStore();
|
const windowStore = useWindowStore();
|
||||||
|
const systemStore = useSystemStore();
|
||||||
const {t} = useI18n();
|
const {t} = useI18n();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
// 当前块是否支持格式化的响应式状态
|
// 当前块是否支持格式化的响应式状态
|
||||||
const canFormatCurrentBlock = ref(false);
|
const canFormatCurrentBlock = ref(false);
|
||||||
|
|
||||||
// 窗口置顶状态管理(仅当前窗口,不同步到配置文件)
|
// 窗口置顶状态 - 合并配置和临时状态
|
||||||
const isCurrentWindowOnTop = ref(false);
|
const isCurrentWindowOnTop = computed(() => {
|
||||||
|
return configStore.config.general.alwaysOnTop || systemStore.isWindowOnTop;
|
||||||
const setWindowAlwaysOnTop = async (isTop: boolean) => {
|
});
|
||||||
await runtime.Window.SetAlwaysOnTop(isTop);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
// 切换窗口置顶状态
|
||||||
const toggleAlwaysOnTop = async () => {
|
const toggleAlwaysOnTop = async () => {
|
||||||
isCurrentWindowOnTop.value = !isCurrentWindowOnTop.value;
|
const currentlyOnTop = isCurrentWindowOnTop.value;
|
||||||
await runtime.Window.SetAlwaysOnTop(isCurrentWindowOnTop.value);
|
|
||||||
|
if (currentlyOnTop) {
|
||||||
|
// 如果当前是置顶状态,彻底关闭所有置顶
|
||||||
|
if (configStore.config.general.alwaysOnTop) {
|
||||||
|
await configStore.setAlwaysOnTop(false);
|
||||||
|
}
|
||||||
|
await systemStore.setWindowOnTop(false);
|
||||||
|
} else {
|
||||||
|
// 如果当前不是置顶状态,开启临时置顶
|
||||||
|
await systemStore.setWindowOnTop(true);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 跳转到设置页面
|
// 跳转到设置页面
|
||||||
@@ -59,11 +70,11 @@ const updateFormatButtonState = () => {
|
|||||||
// 获取活动块和语言信息
|
// 获取活动块和语言信息
|
||||||
const state = view.state;
|
const state = view.state;
|
||||||
const activeBlock = getActiveNoteBlock(state as any);
|
const activeBlock = getActiveNoteBlock(state as any);
|
||||||
|
|
||||||
// 检查块和语言格式化支持
|
// 检查块和语言格式化支持
|
||||||
canFormatCurrentBlock.value = !!(
|
canFormatCurrentBlock.value = !!(
|
||||||
activeBlock &&
|
activeBlock &&
|
||||||
getLanguage(activeBlock.language.name as any)?.prettier
|
getLanguage(activeBlock.language.name as any)?.prettier
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.warn('Error checking format capability:', error);
|
console.warn('Error checking format capability:', error);
|
||||||
@@ -74,32 +85,32 @@ const updateFormatButtonState = () => {
|
|||||||
// 创建带300ms防抖的更新函数
|
// 创建带300ms防抖的更新函数
|
||||||
const debouncedUpdateFormatButton = (() => {
|
const debouncedUpdateFormatButton = (() => {
|
||||||
let timeout: number | null = null;
|
let timeout: number | null = null;
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
if (timeout) clearTimeout(timeout);
|
if (timeout) clearTimeout(timeout);
|
||||||
timeout = window.setTimeout(() => {
|
timeout = window.setTimeout(() => {
|
||||||
updateFormatButtonState();
|
updateFormatButtonState();
|
||||||
timeout = null;
|
timeout = null;
|
||||||
}, 300);
|
}, 1000);
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
// 编辑器事件管理
|
// 编辑器事件管理
|
||||||
const setupEditorListeners = (view: any) => {
|
const setupEditorListeners = (view: any) => {
|
||||||
if (!view?.dom) return [];
|
if (!view?.dom) return [];
|
||||||
|
|
||||||
const events = [
|
const events = [
|
||||||
{ type: 'click', handler: updateFormatButtonState },
|
{type: 'click', handler: updateFormatButtonState},
|
||||||
{ type: 'keyup', handler: debouncedUpdateFormatButton },
|
{type: 'keyup', handler: debouncedUpdateFormatButton},
|
||||||
{ type: 'focus', handler: updateFormatButtonState }
|
{type: 'focus', handler: updateFormatButtonState}
|
||||||
];
|
];
|
||||||
|
|
||||||
// 注册所有事件
|
// 注册所有事件
|
||||||
events.forEach(event => view.dom.addEventListener(event.type, event.handler));
|
events.forEach(event => view.dom.addEventListener(event.type, event.handler));
|
||||||
|
|
||||||
// 返回清理函数数组
|
// 返回清理函数数组
|
||||||
return events.map(event =>
|
return events.map(event =>
|
||||||
() => view.dom.removeEventListener(event.type, event.handler)
|
() => view.dom.removeEventListener(event.type, event.handler)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -107,22 +118,22 @@ const setupEditorListeners = (view: any) => {
|
|||||||
let cleanupListeners: (() => void)[] = [];
|
let cleanupListeners: (() => void)[] = [];
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => editorStore.editorView,
|
() => editorStore.editorView,
|
||||||
(newView) => {
|
(newView) => {
|
||||||
// 清理旧监听器
|
// 清理旧监听器
|
||||||
cleanupListeners.forEach(cleanup => cleanup());
|
cleanupListeners.forEach(cleanup => cleanup());
|
||||||
cleanupListeners = [];
|
cleanupListeners = [];
|
||||||
|
|
||||||
if (newView) {
|
if (newView) {
|
||||||
// 初始更新状态
|
// 初始更新状态
|
||||||
updateFormatButtonState();
|
updateFormatButtonState();
|
||||||
// 设置新监听器
|
// 设置新监听器
|
||||||
cleanupListeners = setupEditorListeners(newView);
|
cleanupListeners = setupEditorListeners(newView);
|
||||||
} else {
|
} else {
|
||||||
canFormatCurrentBlock.value = false;
|
canFormatCurrentBlock.value = false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ immediate: true }
|
{immediate: true}
|
||||||
);
|
);
|
||||||
|
|
||||||
// 组件生命周期
|
// 组件生命周期
|
||||||
@@ -143,12 +154,28 @@ onUnmounted(() => {
|
|||||||
// 组件加载后初始化置顶状态
|
// 组件加载后初始化置顶状态
|
||||||
watch(isLoaded, async (loaded) => {
|
watch(isLoaded, async (loaded) => {
|
||||||
if (loaded) {
|
if (loaded) {
|
||||||
// 初始化时从配置文件读取置顶状态
|
// 应用合并后的置顶状态
|
||||||
isCurrentWindowOnTop.value = configStore.config.general.alwaysOnTop;
|
const shouldBeOnTop = configStore.config.general.alwaysOnTop || systemStore.isWindowOnTop;
|
||||||
await setWindowAlwaysOnTop(isCurrentWindowOnTop.value);
|
try {
|
||||||
|
await runtime.Window.SetAlwaysOnTop(shouldBeOnTop);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Failed to apply window pin state:', error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 监听配置变化,同步窗口状态
|
||||||
|
watch(
|
||||||
|
() => isCurrentWindowOnTop.value,
|
||||||
|
async (shouldBeOnTop) => {
|
||||||
|
try {
|
||||||
|
await runtime.Window.SetAlwaysOnTop(shouldBeOnTop);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Failed to sync window pin state:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
const handleUpdateButtonClick = async () => {
|
const handleUpdateButtonClick = async () => {
|
||||||
if (updateStore.hasUpdate && !updateStore.isUpdating && !updateStore.updateSuccess) {
|
if (updateStore.hasUpdate && !updateStore.isUpdating && !updateStore.updateSuccess) {
|
||||||
// 开始下载更新
|
// 开始下载更新
|
||||||
@@ -230,29 +257,33 @@ const updateButtonTitle = computed(() => {
|
|||||||
@click="handleUpdateButtonClick"
|
@click="handleUpdateButtonClick"
|
||||||
>
|
>
|
||||||
<!-- 检查更新中 -->
|
<!-- 检查更新中 -->
|
||||||
<svg v-if="updateStore.isChecking" xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none"
|
<svg v-if="updateStore.isChecking" xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24"
|
||||||
|
fill="none"
|
||||||
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="rotating">
|
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="rotating">
|
||||||
<path d="M21 12a9 9 0 1 1-6.219-8.56"/>
|
<path d="M21 12a9 9 0 1 1-6.219-8.56"/>
|
||||||
</svg>
|
</svg>
|
||||||
|
|
||||||
<!-- 下载更新中 -->
|
<!-- 下载更新中 -->
|
||||||
<svg v-else-if="updateStore.isUpdating" xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none"
|
<svg v-else-if="updateStore.isUpdating" xmlns="http://www.w3.org/2000/svg" width="14" height="14"
|
||||||
|
viewBox="0 0 24 24" fill="none"
|
||||||
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="rotating">
|
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="rotating">
|
||||||
<path d="M21 12a9 9 0 1 1-6.219-8.56"></path>
|
<path d="M21 12a9 9 0 1 1-6.219-8.56"></path>
|
||||||
<path d="M12 2a10 10 0 1 0 10 10"></path>
|
<path d="M12 2a10 10 0 1 0 10 10"></path>
|
||||||
</svg>
|
</svg>
|
||||||
|
|
||||||
<!-- 更新成功,等待重启 -->
|
<!-- 更新成功,等待重启 -->
|
||||||
<svg v-else-if="updateStore.updateSuccess" xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none"
|
<svg v-else-if="updateStore.updateSuccess" xmlns="http://www.w3.org/2000/svg" width="14" height="14"
|
||||||
|
viewBox="0 0 24 24" fill="none"
|
||||||
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="pulsing">
|
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="pulsing">
|
||||||
<path d="M18.36 6.64a9 9 0 1 1-12.73 0"></path>
|
<path d="M18.36 6.64a9 9 0 1 1-12.73 0"></path>
|
||||||
<line x1="12" y1="2" x2="12" y2="12"></line>
|
<line x1="12" y1="2" x2="12" y2="12"></line>
|
||||||
</svg>
|
</svg>
|
||||||
|
|
||||||
<!-- 有更新可用 -->
|
<!-- 有更新可用 -->
|
||||||
<svg v-else xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none"
|
<svg v-else xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none"
|
||||||
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||||
<path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"/>
|
<path
|
||||||
|
d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"/>
|
||||||
<polyline points="7.5,10.5 12,15 16.5,10.5"/>
|
<polyline points="7.5,10.5 12,15 16.5,10.5"/>
|
||||||
<polyline points="12,15 12,3"/>
|
<polyline points="12,15 12,3"/>
|
||||||
</svg>
|
</svg>
|
||||||
@@ -338,39 +369,39 @@ const updateButtonTitle = computed(() => {
|
|||||||
&.available {
|
&.available {
|
||||||
background-color: rgba(76, 175, 80, 0.1);
|
background-color: rgba(76, 175, 80, 0.1);
|
||||||
animation: pulse 2s infinite;
|
animation: pulse 2s infinite;
|
||||||
|
|
||||||
svg {
|
svg {
|
||||||
stroke: #4caf50;
|
stroke: #4caf50;
|
||||||
}
|
}
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background-color: rgba(76, 175, 80, 0.2);
|
background-color: rgba(76, 175, 80, 0.2);
|
||||||
transform: scale(1.05);
|
transform: scale(1.05);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 检查更新中状态 */
|
/* 检查更新中状态 */
|
||||||
&.checking {
|
&.checking {
|
||||||
background-color: rgba(255, 193, 7, 0.1);
|
background-color: rgba(255, 193, 7, 0.1);
|
||||||
|
|
||||||
svg {
|
svg {
|
||||||
stroke: #ffc107;
|
stroke: #ffc107;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 更新下载中状态 */
|
/* 更新下载中状态 */
|
||||||
&.updating {
|
&.updating {
|
||||||
background-color: rgba(33, 150, 243, 0.1);
|
background-color: rgba(33, 150, 243, 0.1);
|
||||||
|
|
||||||
svg {
|
svg {
|
||||||
stroke: #2196f3;
|
stroke: #2196f3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 更新成功状态 */
|
/* 更新成功状态 */
|
||||||
&.success {
|
&.success {
|
||||||
background-color: rgba(156, 39, 176, 0.1);
|
background-color: rgba(156, 39, 176, 0.1);
|
||||||
|
|
||||||
svg {
|
svg {
|
||||||
stroke: #9c27b0;
|
stroke: #9c27b0;
|
||||||
}
|
}
|
||||||
@@ -380,7 +411,7 @@ const updateButtonTitle = computed(() => {
|
|||||||
.rotating {
|
.rotating {
|
||||||
animation: rotate 1.5s linear infinite;
|
animation: rotate 1.5s linear infinite;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 脉冲动画 */
|
/* 脉冲动画 */
|
||||||
.pulsing {
|
.pulsing {
|
||||||
animation: pulse-strong 1.2s ease-in-out infinite;
|
animation: pulse-strong 1.2s ease-in-out infinite;
|
||||||
@@ -394,7 +425,7 @@ const updateButtonTitle = computed(() => {
|
|||||||
opacity: 0.7;
|
opacity: 0.7;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes pulse-strong {
|
@keyframes pulse-strong {
|
||||||
0%, 100% {
|
0%, 100% {
|
||||||
transform: scale(1);
|
transform: scale(1);
|
||||||
@@ -405,7 +436,7 @@ const updateButtonTitle = computed(() => {
|
|||||||
opacity: 0.8;
|
opacity: 0.8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes rotate {
|
@keyframes rotate {
|
||||||
0% {
|
0% {
|
||||||
transform: rotate(0deg);
|
transform: rotate(0deg);
|
||||||
|
|||||||
@@ -64,7 +64,6 @@ const GENERAL_CONFIG_KEY_MAP: GeneralConfigKeyMap = {
|
|||||||
enableGlobalHotkey: 'general.enableGlobalHotkey',
|
enableGlobalHotkey: 'general.enableGlobalHotkey',
|
||||||
globalHotkey: 'general.globalHotkey',
|
globalHotkey: 'general.globalHotkey',
|
||||||
enableWindowSnap: 'general.enableWindowSnap',
|
enableWindowSnap: 'general.enableWindowSnap',
|
||||||
snapThreshold: 'general.snapThreshold'
|
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
const EDITING_CONFIG_KEY_MAP: EditingConfigKeyMap = {
|
const EDITING_CONFIG_KEY_MAP: EditingConfigKeyMap = {
|
||||||
@@ -180,7 +179,6 @@ const DEFAULT_CONFIG: AppConfig = {
|
|||||||
key: 'X'
|
key: 'X'
|
||||||
},
|
},
|
||||||
enableWindowSnap: true,
|
enableWindowSnap: true,
|
||||||
snapThreshold: 15
|
|
||||||
},
|
},
|
||||||
editing: {
|
editing: {
|
||||||
fontSize: CONFIG_LIMITS.fontSize.default,
|
fontSize: CONFIG_LIMITS.fontSize.default,
|
||||||
@@ -527,7 +525,6 @@ export const useConfigStore = defineStore('config', () => {
|
|||||||
|
|
||||||
// 窗口吸附配置相关方法
|
// 窗口吸附配置相关方法
|
||||||
setEnableWindowSnap: async (value: boolean) => await updateGeneralConfig('enableWindowSnap', value),
|
setEnableWindowSnap: async (value: boolean) => await updateGeneralConfig('enableWindowSnap', value),
|
||||||
setSnapThreshold: async (value: number) => await updateGeneralConfig('snapThreshold', value),
|
|
||||||
|
|
||||||
// 更新配置相关方法
|
// 更新配置相关方法
|
||||||
setAutoUpdate: async (value: boolean) => await updateUpdatesConfig('autoUpdate', value),
|
setAutoUpdate: async (value: boolean) => await updateUpdatesConfig('autoUpdate', value),
|
||||||
|
|||||||
@@ -3,13 +3,15 @@ import {computed, ref} from 'vue';
|
|||||||
import {DocumentService} from '@/../bindings/voidraft/internal/services';
|
import {DocumentService} from '@/../bindings/voidraft/internal/services';
|
||||||
import {OpenDocumentWindow} from '@/../bindings/voidraft/internal/services/windowservice';
|
import {OpenDocumentWindow} from '@/../bindings/voidraft/internal/services/windowservice';
|
||||||
import {Document} from '@/../bindings/voidraft/internal/models/models';
|
import {Document} from '@/../bindings/voidraft/internal/models/models';
|
||||||
|
import {useSystemStore} from './systemStore';
|
||||||
|
|
||||||
const SCRATCH_DOCUMENT_ID = 1; // 默认草稿文档ID
|
|
||||||
|
|
||||||
export const useDocumentStore = defineStore('document', () => {
|
export const useDocumentStore = defineStore('document', () => {
|
||||||
|
|
||||||
|
const DEFAULT_DOCUMENT_ID = ref<number>(1); // 默认草稿文档ID
|
||||||
// === 核心状态 ===
|
// === 核心状态 ===
|
||||||
const documents = ref<Record<number, Document>>({});
|
const documents = ref<Record<number, Document>>({});
|
||||||
const recentDocumentIds = ref<number[]>([SCRATCH_DOCUMENT_ID]);
|
const recentDocumentIds = ref<number[]>([DEFAULT_DOCUMENT_ID.value]);
|
||||||
const currentDocumentId = ref<number | null>(null);
|
const currentDocumentId = ref<number | null>(null);
|
||||||
const currentDocument = ref<Document | null>(null);
|
const currentDocument = ref<Document | null>(null);
|
||||||
|
|
||||||
@@ -159,7 +161,7 @@ export const useDocumentStore = defineStore('document', () => {
|
|||||||
const deleteDocument = async (docId: number): Promise<boolean> => {
|
const deleteDocument = async (docId: number): Promise<boolean> => {
|
||||||
try {
|
try {
|
||||||
// 检查是否是默认文档(使用ID判断)
|
// 检查是否是默认文档(使用ID判断)
|
||||||
if (docId === SCRATCH_DOCUMENT_ID) {
|
if (docId === DEFAULT_DOCUMENT_ID.value) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,6 +223,7 @@ export const useDocumentStore = defineStore('document', () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
DEFAULT_DOCUMENT_ID,
|
||||||
// 状态
|
// 状态
|
||||||
documents,
|
documents,
|
||||||
documentList,
|
documentList,
|
||||||
|
|||||||
@@ -19,14 +19,15 @@ export const useSystemStore = defineStore('system', () => {
|
|||||||
// 状态
|
// 状态
|
||||||
const environment = ref<SystemEnvironment | null>(null);
|
const environment = ref<SystemEnvironment | null>(null);
|
||||||
const isLoading = ref(false);
|
const isLoading = ref(false);
|
||||||
|
|
||||||
|
// 窗口置顶状态管理
|
||||||
|
const isWindowOnTop = ref<boolean>(false);
|
||||||
|
|
||||||
// 计算属性
|
// 计算属性
|
||||||
const isWindows = computed(() => environment.value?.OS === 'windows');
|
const isWindows = computed(() => environment.value?.OS === 'windows');
|
||||||
const isMacOS = computed(() => environment.value?.OS === 'darwin');
|
const isMacOS = computed(() => environment.value?.OS === 'darwin');
|
||||||
const isLinux = computed(() => environment.value?.OS === 'linux');
|
const isLinux = computed(() => environment.value?.OS === 'linux');
|
||||||
|
|
||||||
|
|
||||||
// 获取标题栏高度
|
// 获取标题栏高度
|
||||||
const titleBarHeight = computed(() => {
|
const titleBarHeight = computed(() => {
|
||||||
if (isWindows.value) return '32px';
|
if (isWindows.value) return '32px';
|
||||||
@@ -49,10 +50,31 @@ export const useSystemStore = defineStore('system', () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 设置窗口置顶状态
|
||||||
|
const setWindowOnTop = async (isPinned: boolean): Promise<void> => {
|
||||||
|
isWindowOnTop.value = isPinned;
|
||||||
|
try {
|
||||||
|
await runtime.Window.SetAlwaysOnTop(isPinned);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Failed to set window always on top:', error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 切换窗口置顶状态
|
||||||
|
const toggleWindowOnTop = async (): Promise<void> => {
|
||||||
|
await setWindowOnTop(!isWindowOnTop.value);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 重置临时置顶状态(不调用系统API)
|
||||||
|
const resetWindowOnTop = (): void => {
|
||||||
|
isWindowOnTop.value = false;
|
||||||
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
// 状态
|
// 状态
|
||||||
environment,
|
environment,
|
||||||
isLoading,
|
isLoading,
|
||||||
|
isWindowOnTop,
|
||||||
|
|
||||||
// 计算属性
|
// 计算属性
|
||||||
isWindows,
|
isWindows,
|
||||||
@@ -62,5 +84,14 @@ export const useSystemStore = defineStore('system', () => {
|
|||||||
|
|
||||||
// 方法
|
// 方法
|
||||||
initializeSystemInfo,
|
initializeSystemInfo,
|
||||||
|
setWindowOnTop,
|
||||||
|
toggleWindowOnTop,
|
||||||
|
resetWindowOnTop,
|
||||||
};
|
};
|
||||||
|
}, {
|
||||||
|
persist: {
|
||||||
|
key: 'voidraft-system',
|
||||||
|
storage: localStorage,
|
||||||
|
pick: ['isWindowOnTop']
|
||||||
|
}
|
||||||
});
|
});
|
||||||
7
go.mod
7
go.mod
@@ -3,7 +3,6 @@ module voidraft
|
|||||||
go 1.24.4
|
go 1.24.4
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/Masterminds/semver/v3 v3.4.0
|
|
||||||
github.com/creativeprojects/go-selfupdate v1.5.0
|
github.com/creativeprojects/go-selfupdate v1.5.0
|
||||||
github.com/go-git/go-git/v5 v5.16.2
|
github.com/go-git/go-git/v5 v5.16.2
|
||||||
github.com/knadh/koanf/parsers/json v1.0.0
|
github.com/knadh/koanf/parsers/json v1.0.0
|
||||||
@@ -11,6 +10,7 @@ require (
|
|||||||
github.com/knadh/koanf/providers/structs v1.0.0
|
github.com/knadh/koanf/providers/structs v1.0.0
|
||||||
github.com/knadh/koanf/v2 v2.2.2
|
github.com/knadh/koanf/v2 v2.2.2
|
||||||
github.com/robertkrimen/otto v0.5.1
|
github.com/robertkrimen/otto v0.5.1
|
||||||
|
github.com/stretchr/testify v1.10.0
|
||||||
github.com/wailsapp/wails/v3 v3.0.0-alpha.25
|
github.com/wailsapp/wails/v3 v3.0.0-alpha.25
|
||||||
golang.org/x/net v0.43.0
|
golang.org/x/net v0.43.0
|
||||||
golang.org/x/sys v0.35.0
|
golang.org/x/sys v0.35.0
|
||||||
@@ -22,12 +22,14 @@ require (
|
|||||||
code.gitea.io/sdk/gitea v0.21.0 // indirect
|
code.gitea.io/sdk/gitea v0.21.0 // indirect
|
||||||
dario.cat/mergo v1.0.2 // indirect
|
dario.cat/mergo v1.0.2 // indirect
|
||||||
github.com/42wim/httpsig v1.2.3 // indirect
|
github.com/42wim/httpsig v1.2.3 // indirect
|
||||||
|
github.com/Masterminds/semver/v3 v3.4.0 // indirect
|
||||||
github.com/Microsoft/go-winio v0.6.2 // indirect
|
github.com/Microsoft/go-winio v0.6.2 // indirect
|
||||||
github.com/ProtonMail/go-crypto v1.3.0 // indirect
|
github.com/ProtonMail/go-crypto v1.3.0 // indirect
|
||||||
github.com/adrg/xdg v0.5.3 // indirect
|
github.com/adrg/xdg v0.5.3 // indirect
|
||||||
github.com/bep/debounce v1.2.1 // indirect
|
github.com/bep/debounce v1.2.1 // indirect
|
||||||
github.com/cloudflare/circl v1.6.1 // indirect
|
github.com/cloudflare/circl v1.6.1 // indirect
|
||||||
github.com/cyphar/filepath-securejoin v0.4.1 // indirect
|
github.com/cyphar/filepath-securejoin v0.4.1 // indirect
|
||||||
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
github.com/davidmz/go-pageant v1.0.2 // indirect
|
github.com/davidmz/go-pageant v1.0.2 // indirect
|
||||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||||
github.com/ebitengine/purego v0.8.4 // indirect
|
github.com/ebitengine/purego v0.8.4 // indirect
|
||||||
@@ -62,12 +64,13 @@ require (
|
|||||||
github.com/pjbgf/sha1cd v0.4.0 // indirect
|
github.com/pjbgf/sha1cd v0.4.0 // indirect
|
||||||
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
|
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
|
||||||
github.com/pkg/errors v0.9.1 // indirect
|
github.com/pkg/errors v0.9.1 // indirect
|
||||||
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
|
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
|
||||||
github.com/rivo/uniseg v0.4.7 // indirect
|
github.com/rivo/uniseg v0.4.7 // indirect
|
||||||
github.com/samber/lo v1.51.0 // indirect
|
github.com/samber/lo v1.51.0 // indirect
|
||||||
github.com/sergi/go-diff v1.4.0 // indirect
|
github.com/sergi/go-diff v1.4.0 // indirect
|
||||||
github.com/skeema/knownhosts v1.3.1 // indirect
|
github.com/skeema/knownhosts v1.3.1 // indirect
|
||||||
github.com/ulikunitz/xz v0.5.12 // indirect
|
github.com/ulikunitz/xz v0.5.14 // indirect
|
||||||
github.com/wailsapp/go-webview2 v1.0.21 // indirect
|
github.com/wailsapp/go-webview2 v1.0.21 // indirect
|
||||||
github.com/wailsapp/mimetype v1.4.1 // indirect
|
github.com/wailsapp/mimetype v1.4.1 // indirect
|
||||||
github.com/xanzy/go-gitlab v0.115.0 // indirect
|
github.com/xanzy/go-gitlab v0.115.0 // indirect
|
||||||
|
|||||||
4
go.sum
4
go.sum
@@ -158,8 +158,8 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf
|
|||||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||||
github.com/ulikunitz/xz v0.5.12 h1:37Nm15o69RwBkXM0J6A5OlE67RZTfzUxTj8fB3dfcsc=
|
github.com/ulikunitz/xz v0.5.14 h1:uv/0Bq533iFdnMHZdRBTOlaNMdb1+ZxXIlHDZHIHcvg=
|
||||||
github.com/ulikunitz/xz v0.5.12/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
|
github.com/ulikunitz/xz v0.5.14/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
|
||||||
github.com/wailsapp/go-webview2 v1.0.21 h1:k3dtoZU4KCoN/AEIbWiPln3P2661GtA2oEgA2Pb+maA=
|
github.com/wailsapp/go-webview2 v1.0.21 h1:k3dtoZU4KCoN/AEIbWiPln3P2661GtA2oEgA2Pb+maA=
|
||||||
github.com/wailsapp/go-webview2 v1.0.21/go.mod h1:qJmWAmAmaniuKGZPWwne+uor3AHMB5PFhqiK0Bbj8kc=
|
github.com/wailsapp/go-webview2 v1.0.21/go.mod h1:qJmWAmAmaniuKGZPWwne+uor3AHMB5PFhqiK0Bbj8kc=
|
||||||
github.com/wailsapp/mimetype v1.4.1 h1:pQN9ycO7uo4vsUUuPeHEYoUkLVkaRntMnHJxVwYhwHs=
|
github.com/wailsapp/mimetype v1.4.1 h1:pQN9ycO7uo4vsUUuPeHEYoUkLVkaRntMnHJxVwYhwHs=
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
|
"voidraft/internal/version"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TabType 定义了制表符类型
|
// TabType 定义了制表符类型
|
||||||
@@ -69,8 +70,7 @@ type GeneralConfig struct {
|
|||||||
StartAtLogin bool `json:"startAtLogin"` // 开机启动设置
|
StartAtLogin bool `json:"startAtLogin"` // 开机启动设置
|
||||||
|
|
||||||
// 窗口吸附设置
|
// 窗口吸附设置
|
||||||
EnableWindowSnap bool `json:"enableWindowSnap"` // 是否启用窗口吸附功能
|
EnableWindowSnap bool `json:"enableWindowSnap"` // 是否启用窗口吸附功能(阈值现在是自适应的)
|
||||||
SnapThreshold int `json:"snapThreshold"` // 吸附距离阈值(像素)
|
|
||||||
|
|
||||||
// 全局热键设置
|
// 全局热键设置
|
||||||
EnableGlobalHotkey bool `json:"enableGlobalHotkey"` // 是否启用全局热键
|
EnableGlobalHotkey bool `json:"enableGlobalHotkey"` // 是否启用全局热键
|
||||||
@@ -150,7 +150,6 @@ func NewDefaultAppConfig() *AppConfig {
|
|||||||
EnableSystemTray: true,
|
EnableSystemTray: true,
|
||||||
StartAtLogin: false,
|
StartAtLogin: false,
|
||||||
EnableWindowSnap: true, // 默认启用窗口吸附
|
EnableWindowSnap: true, // 默认启用窗口吸附
|
||||||
SnapThreshold: 15, // 默认15像素的吸附阈值
|
|
||||||
EnableGlobalHotkey: false,
|
EnableGlobalHotkey: false,
|
||||||
GlobalHotkey: HotkeyCombo{
|
GlobalHotkey: HotkeyCombo{
|
||||||
Ctrl: false,
|
Ctrl: false,
|
||||||
@@ -178,7 +177,7 @@ func NewDefaultAppConfig() *AppConfig {
|
|||||||
SystemTheme: SystemThemeAuto,
|
SystemTheme: SystemThemeAuto,
|
||||||
},
|
},
|
||||||
Updates: UpdatesConfig{
|
Updates: UpdatesConfig{
|
||||||
Version: "1.3.0",
|
Version: version.Version,
|
||||||
AutoUpdate: true,
|
AutoUpdate: true,
|
||||||
PrimarySource: UpdateSourceGitea,
|
PrimarySource: UpdateSourceGitea,
|
||||||
BackupSource: UpdateSourceGithub,
|
BackupSource: UpdateSourceGithub,
|
||||||
@@ -207,7 +206,7 @@ func NewDefaultAppConfig() *AppConfig {
|
|||||||
},
|
},
|
||||||
Metadata: ConfigMetadata{
|
Metadata: ConfigMetadata{
|
||||||
LastUpdated: time.Now().Format(time.RFC3339),
|
LastUpdated: time.Now().Format(time.RFC3339),
|
||||||
Version: "1.2.0",
|
Version: version.Version,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -263,7 +263,7 @@ func (s *BackupService) PushToRemote() error {
|
|||||||
// 创建提交
|
// 创建提交
|
||||||
_, err = w.Commit(fmt.Sprintf("Backup %s", time.Now().Format("2006-01-02 15:04:05")), &git.CommitOptions{
|
_, err = w.Commit(fmt.Sprintf("Backup %s", time.Now().Format("2006-01-02 15:04:05")), &git.CommitOptions{
|
||||||
Author: &object.Signature{
|
Author: &object.Signature{
|
||||||
Name: "VoidRaft",
|
Name: "voidraft",
|
||||||
Email: "backup@voidraft.app",
|
Email: "backup@voidraft.app",
|
||||||
When: time.Now(),
|
When: time.Now(),
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,318 +1,195 @@
|
|||||||
package services
|
package services
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
|
||||||
"path/filepath"
|
|
||||||
"reflect"
|
|
||||||
"sort"
|
|
||||||
"time"
|
|
||||||
"voidraft/internal/models"
|
|
||||||
|
|
||||||
"github.com/Masterminds/semver/v3"
|
|
||||||
jsonparser "github.com/knadh/koanf/parsers/json"
|
jsonparser "github.com/knadh/koanf/parsers/json"
|
||||||
"github.com/knadh/koanf/providers/structs"
|
"github.com/knadh/koanf/providers/structs"
|
||||||
"github.com/knadh/koanf/v2"
|
"github.com/knadh/koanf/v2"
|
||||||
"github.com/wailsapp/wails/v3/pkg/services/log"
|
"github.com/wailsapp/wails/v3/pkg/services/log"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// CurrentAppConfigVersion 当前应用配置版本
|
// BackupFilePattern backup file name pattern
|
||||||
CurrentAppConfigVersion = "1.3.0"
|
|
||||||
// BackupFilePattern 备份文件名模式
|
|
||||||
BackupFilePattern = "%s.backup.%s.json"
|
BackupFilePattern = "%s.backup.%s.json"
|
||||||
|
// MaxConfigFileSize maximum config file size
|
||||||
// 资源限制常量
|
|
||||||
MaxConfigFileSize = 10 * 1024 * 1024 // 10MB
|
MaxConfigFileSize = 10 * 1024 * 1024 // 10MB
|
||||||
MaxRecursionDepth = 50 // 最大递归深度
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Migratable 可迁移的配置接口
|
// ConfigMigrator elegant configuration migrator with automatic field detection
|
||||||
type Migratable interface {
|
type ConfigMigrator struct {
|
||||||
GetVersion() string // 获取当前版本
|
logger *log.LogService
|
||||||
SetVersion(string) // 设置版本
|
configDir string
|
||||||
SetLastUpdated(string) // 设置最后更新时间
|
configName string
|
||||||
GetDefaultConfig() any // 获取默认配置
|
configPath string
|
||||||
}
|
}
|
||||||
|
|
||||||
// ConfigMigrationService 配置迁移服务
|
// MigrationResult migration operation result
|
||||||
type ConfigMigrationService[T Migratable] struct {
|
|
||||||
logger *log.LogService
|
|
||||||
configDir string
|
|
||||||
configName string
|
|
||||||
targetVersion string
|
|
||||||
configPath string
|
|
||||||
}
|
|
||||||
|
|
||||||
// MigrationResult 迁移结果
|
|
||||||
type MigrationResult struct {
|
type MigrationResult struct {
|
||||||
Migrated, ConfigUpdated bool
|
Migrated bool `json:"migrated"` // Whether migration was performed
|
||||||
FromVersion, ToVersion string
|
MissingFields []string `json:"missingFields"` // Fields that were missing
|
||||||
BackupPath string
|
BackupPath string `json:"backupPath"` // Path to backup file
|
||||||
|
Description string `json:"description"` // Description of migration
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewConfigMigrationService 创建配置迁移服务
|
// NewConfigMigrator creates a new configuration migrator
|
||||||
func NewConfigMigrationService[T Migratable](
|
func NewConfigMigrator(
|
||||||
logger *log.LogService,
|
logger *log.LogService,
|
||||||
configDir string,
|
configDir string,
|
||||||
configName, targetVersion, configPath string,
|
configName, configPath string,
|
||||||
) *ConfigMigrationService[T] {
|
) *ConfigMigrator {
|
||||||
return &ConfigMigrationService[T]{
|
if logger == nil {
|
||||||
logger: orDefault(logger, log.New()),
|
logger = log.New()
|
||||||
configDir: configDir,
|
}
|
||||||
configName: configName,
|
return &ConfigMigrator{
|
||||||
targetVersion: targetVersion,
|
logger: logger,
|
||||||
configPath: configPath,
|
configDir: configDir,
|
||||||
|
configName: configName,
|
||||||
|
configPath: configPath,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MigrateConfig 迁移配置文件
|
// AutoMigrate automatically detects and migrates missing configuration fields
|
||||||
func (cms *ConfigMigrationService[T]) MigrateConfig(existingConfig *koanf.Koanf) (*MigrationResult, error) {
|
func (cm *ConfigMigrator) AutoMigrate(defaultConfig interface{}, currentConfig *koanf.Koanf) (*MigrationResult, error) {
|
||||||
currentVersion := orDefault(existingConfig.String("metadata.version"), "0.0.0")
|
// Load default config into temporary koanf instance
|
||||||
result := &MigrationResult{
|
defaultKoanf := koanf.New(".")
|
||||||
FromVersion: currentVersion,
|
if err := defaultKoanf.Load(structs.Provider(defaultConfig, "json"), nil); err != nil {
|
||||||
ToVersion: cms.targetVersion,
|
return nil, fmt.Errorf("failed to load default config: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if needsMigration, err := cms.needsMigration(currentVersion); err != nil {
|
// Detect missing fields
|
||||||
return result, fmt.Errorf("version comparison failed: %w", err)
|
missingFields := cm.detectMissingFields(currentConfig.All(), defaultKoanf.All())
|
||||||
} else if !needsMigration {
|
|
||||||
|
// Create result object
|
||||||
|
result := &MigrationResult{
|
||||||
|
MissingFields: missingFields,
|
||||||
|
Migrated: len(missingFields) > 0,
|
||||||
|
Description: fmt.Sprintf("Detected %d missing configuration fields", len(missingFields)),
|
||||||
|
}
|
||||||
|
|
||||||
|
// If no missing fields, return early
|
||||||
|
if !result.Migrated {
|
||||||
|
cm.logger.Info("No missing configuration fields detected")
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 资源检查和备份
|
// Only create backup if we actually need to migrate (has missing fields)
|
||||||
if err := cms.checkResourceLimits(); err != nil {
|
if len(missingFields) > 0 {
|
||||||
return result, fmt.Errorf("resource limit check failed: %w", err)
|
if backupPath, err := cm.createBackup(); err != nil {
|
||||||
|
cm.logger.Error("Failed to create backup", "error", err)
|
||||||
|
} else {
|
||||||
|
result.BackupPath = backupPath
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if backupPath, err := cms.createBackupOptimized(); err != nil {
|
// Merge missing fields from default config
|
||||||
return result, fmt.Errorf("backup creation failed: %w", err)
|
if err := cm.mergeDefaultFields(currentConfig, defaultKoanf, missingFields); err != nil {
|
||||||
} else {
|
return result, fmt.Errorf("failed to merge default fields: %w", err)
|
||||||
result.BackupPath = backupPath
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 自动恢复检查
|
// Save updated config
|
||||||
cms.tryQuickRecovery(existingConfig)
|
if err := cm.saveConfig(currentConfig); err != nil {
|
||||||
|
return result, fmt.Errorf("failed to save updated config: %w", err)
|
||||||
// 执行迁移
|
|
||||||
if configUpdated, err := cms.performOptimizedMigration(existingConfig); err != nil {
|
|
||||||
return result, fmt.Errorf("migration failed: %w", err)
|
|
||||||
} else {
|
|
||||||
result.Migrated = true
|
|
||||||
result.ConfigUpdated = configUpdated
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cm.logger.Info("Configuration migration completed successfully", "migratedFields", len(missingFields))
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// needsMigration 检查是否需要迁移
|
// detectMissingFields detects missing configuration fields
|
||||||
func (cms *ConfigMigrationService[T]) needsMigration(current string) (bool, error) {
|
func (cm *ConfigMigrator) detectMissingFields(current, defaultConfig map[string]interface{}) []string {
|
||||||
currentVer, err := semver.NewVersion(current)
|
var missingFields []string
|
||||||
if err != nil {
|
cm.findMissingFieldsRecursive("", defaultConfig, current, &missingFields)
|
||||||
return true, nil
|
return missingFields
|
||||||
}
|
|
||||||
targetVer, err := semver.NewVersion(cms.targetVersion)
|
|
||||||
if err != nil {
|
|
||||||
return false, fmt.Errorf("invalid target version: %s", cms.targetVersion)
|
|
||||||
}
|
|
||||||
return currentVer.LessThan(targetVer), nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// checkResourceLimits 检查资源限制
|
// findMissingFieldsRecursive recursively finds missing fields
|
||||||
func (cms *ConfigMigrationService[T]) checkResourceLimits() error {
|
func (cm *ConfigMigrator) findMissingFieldsRecursive(prefix string, defaultMap, currentMap map[string]interface{}, missing *[]string) {
|
||||||
if info, err := os.Stat(cms.configPath); err == nil && info.Size() > MaxConfigFileSize {
|
for key, defaultVal := range defaultMap {
|
||||||
return fmt.Errorf("config file size (%d bytes) exceeds limit (%d bytes)", info.Size(), MaxConfigFileSize)
|
fullKey := key
|
||||||
|
if prefix != "" {
|
||||||
|
fullKey = prefix + "." + key
|
||||||
|
}
|
||||||
|
|
||||||
|
currentVal, exists := currentMap[key]
|
||||||
|
if !exists {
|
||||||
|
// Field is completely missing
|
||||||
|
*missing = append(*missing, fullKey)
|
||||||
|
} else {
|
||||||
|
// Check nested structures
|
||||||
|
if defaultNestedMap, ok := defaultVal.(map[string]interface{}); ok {
|
||||||
|
if currentNestedMap, ok := currentVal.(map[string]interface{}); ok {
|
||||||
|
cm.findMissingFieldsRecursive(fullKey, defaultNestedMap, currentNestedMap, missing)
|
||||||
|
} else {
|
||||||
|
// Current value is not a map but default is, structure mismatch
|
||||||
|
*missing = append(*missing, fullKey)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// mergeDefaultFields merges default values for missing fields into current config
|
||||||
|
func (cm *ConfigMigrator) mergeDefaultFields(current, defaultConfig *koanf.Koanf, missingFields []string) error {
|
||||||
|
for _, field := range missingFields {
|
||||||
|
defaultValue := defaultConfig.Get(field)
|
||||||
|
if defaultValue != nil {
|
||||||
|
current.Set(field, defaultValue)
|
||||||
|
cm.logger.Debug("Merged missing field", "field", field, "value", defaultValue)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update last modified timestamp
|
||||||
|
current.Set("metadata.lastUpdated", time.Now().Format(time.RFC3339))
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// createBackupOptimized 优化的备份创建
|
// createBackup creates a backup of the configuration file
|
||||||
func (cms *ConfigMigrationService[T]) createBackupOptimized() (string, error) {
|
func (cm *ConfigMigrator) createBackup() (string, error) {
|
||||||
if _, err := os.Stat(cms.configPath); os.IsNotExist(err) {
|
if _, err := os.Stat(cm.configPath); os.IsNotExist(err) {
|
||||||
return "", nil
|
return "", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
configDir := cms.configDir
|
|
||||||
timestamp := time.Now().Format("20060102150405")
|
timestamp := time.Now().Format("20060102150405")
|
||||||
newBackupPath := filepath.Join(configDir, fmt.Sprintf(BackupFilePattern, cms.configName, timestamp))
|
backupPath := filepath.Join(cm.configDir, fmt.Sprintf(BackupFilePattern, cm.configName, timestamp))
|
||||||
|
|
||||||
// 单次扫描:删除旧备份并创建新备份
|
data, err := os.ReadFile(cm.configPath)
|
||||||
pattern := filepath.Join(configDir, fmt.Sprintf("%s.backup.*.json", cms.configName))
|
|
||||||
if matches, err := filepath.Glob(pattern); err == nil {
|
|
||||||
for _, oldBackup := range matches {
|
|
||||||
if oldBackup != newBackupPath {
|
|
||||||
os.Remove(oldBackup) // 忽略删除错误,继续处理
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return newBackupPath, copyFile(cms.configPath, newBackupPath)
|
|
||||||
}
|
|
||||||
|
|
||||||
// tryQuickRecovery 快速恢复检查
|
|
||||||
func (cms *ConfigMigrationService[T]) tryQuickRecovery(existingConfig *koanf.Koanf) {
|
|
||||||
var testConfig T
|
|
||||||
if existingConfig.Unmarshal("", &testConfig) != nil {
|
|
||||||
cms.logger.Info("Config appears corrupted, attempting quick recovery")
|
|
||||||
if backupPath := cms.findLatestBackupQuick(); backupPath != "" {
|
|
||||||
if data, err := os.ReadFile(backupPath); err == nil {
|
|
||||||
existingConfig.Delete("")
|
|
||||||
existingConfig.Load(&BytesProvider{data}, jsonparser.Parser())
|
|
||||||
cms.logger.Info("Quick recovery successful")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// findLatestBackupQuick 快速查找最新备份(优化排序)
|
|
||||||
func (cms *ConfigMigrationService[T]) findLatestBackupQuick() string {
|
|
||||||
pattern := filepath.Join(cms.configDir, fmt.Sprintf("%s.backup.*.json", cms.configName))
|
|
||||||
matches, err := filepath.Glob(pattern)
|
|
||||||
if err != nil || len(matches) == 0 {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
sort.Strings(matches) // 字典序排序,时间戳格式确保正确性
|
|
||||||
return matches[len(matches)-1]
|
|
||||||
}
|
|
||||||
|
|
||||||
// performOptimizedMigration 优化的迁移执行
|
|
||||||
func (cms *ConfigMigrationService[T]) performOptimizedMigration(existingConfig *koanf.Koanf) (bool, error) {
|
|
||||||
// 直接从koanf实例获取配置,避免额外序列化
|
|
||||||
var currentConfig T
|
|
||||||
if err := existingConfig.Unmarshal("", ¤tConfig); err != nil {
|
|
||||||
return false, fmt.Errorf("unmarshal existing config failed: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
defaultConfig, ok := currentConfig.GetDefaultConfig().(T)
|
|
||||||
if !ok {
|
|
||||||
return false, fmt.Errorf("default config type mismatch")
|
|
||||||
}
|
|
||||||
|
|
||||||
return cms.mergeInPlace(existingConfig, currentConfig, defaultConfig)
|
|
||||||
}
|
|
||||||
|
|
||||||
// mergeInPlace 就地合并配置
|
|
||||||
func (cms *ConfigMigrationService[T]) mergeInPlace(existingConfig *koanf.Koanf, currentConfig, defaultConfig T) (bool, error) {
|
|
||||||
// 创建临时合并实例
|
|
||||||
mergeKoanf := koanf.New(".")
|
|
||||||
|
|
||||||
// 使用快速加载链
|
|
||||||
if err := chainLoad(mergeKoanf,
|
|
||||||
func() error { return mergeKoanf.Load(structs.Provider(defaultConfig, "json"), nil) },
|
|
||||||
func() error {
|
|
||||||
return mergeKoanf.Load(structs.Provider(currentConfig, "json"), nil,
|
|
||||||
koanf.WithMergeFunc(cms.fastMerge))
|
|
||||||
},
|
|
||||||
); err != nil {
|
|
||||||
return false, fmt.Errorf("config merge failed: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 更新元数据
|
|
||||||
mergeKoanf.Set("metadata.version", cms.targetVersion)
|
|
||||||
mergeKoanf.Set("metadata.lastUpdated", time.Now().Format(time.RFC3339))
|
|
||||||
|
|
||||||
// 一次性序列化和原子写入
|
|
||||||
configBytes, err := mergeKoanf.Marshal(jsonparser.Parser())
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, fmt.Errorf("marshal config failed: %w", err)
|
return "", fmt.Errorf("failed to read config file: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := os.WriteFile(backupPath, data, 0644); err != nil {
|
||||||
|
return "", fmt.Errorf("failed to create backup: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
cm.logger.Info("Configuration backup created", "path", backupPath)
|
||||||
|
return backupPath, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// saveConfig saves configuration to file
|
||||||
|
func (cm *ConfigMigrator) saveConfig(config *koanf.Koanf) error {
|
||||||
|
configBytes, err := config.Marshal(jsonparser.Parser())
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to marshal config: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(configBytes) > MaxConfigFileSize {
|
if len(configBytes) > MaxConfigFileSize {
|
||||||
return false, fmt.Errorf("merged config size exceeds limit")
|
return fmt.Errorf("config size (%d bytes) exceeds limit (%d bytes)", len(configBytes), MaxConfigFileSize)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 原子写入
|
// Atomic write
|
||||||
return true, cms.atomicWrite(existingConfig, configBytes)
|
tempPath := cm.configPath + ".tmp"
|
||||||
}
|
|
||||||
|
|
||||||
// atomicWrite 原子写入操作
|
|
||||||
func (cms *ConfigMigrationService[T]) atomicWrite(existingConfig *koanf.Koanf, configBytes []byte) error {
|
|
||||||
tempPath := cms.configPath + ".tmp"
|
|
||||||
|
|
||||||
if err := os.WriteFile(tempPath, configBytes, 0644); err != nil {
|
if err := os.WriteFile(tempPath, configBytes, 0644); err != nil {
|
||||||
return fmt.Errorf("write temp config failed: %w", err)
|
return fmt.Errorf("failed to write temp config: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := os.Rename(tempPath, cms.configPath); err != nil {
|
if err := os.Rename(tempPath, cm.configPath); err != nil {
|
||||||
os.Remove(tempPath)
|
os.Remove(tempPath)
|
||||||
return fmt.Errorf("atomic rename failed: %w", err)
|
return fmt.Errorf("failed to rename temp config: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 重新加载到原实例
|
|
||||||
existingConfig.Delete("")
|
|
||||||
return existingConfig.Load(&BytesProvider{configBytes}, jsonparser.Parser())
|
|
||||||
}
|
|
||||||
|
|
||||||
// fastMerge 快速合并函数
|
|
||||||
func (cms *ConfigMigrationService[T]) fastMerge(src, dest map[string]interface{}) error {
|
|
||||||
return cms.fastMergeRecursive(src, dest, 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
// fastMergeRecursive 快速递归合并
|
|
||||||
func (cms *ConfigMigrationService[T]) fastMergeRecursive(src, dest map[string]interface{}, depth int) error {
|
|
||||||
if depth > MaxRecursionDepth {
|
|
||||||
return fmt.Errorf("recursion depth exceeded")
|
|
||||||
}
|
|
||||||
|
|
||||||
for key, srcVal := range src {
|
|
||||||
if destVal, exists := dest[key]; exists {
|
|
||||||
// 优先检查map类型(最常见情况)
|
|
||||||
if srcMap, srcOK := srcVal.(map[string]interface{}); srcOK {
|
|
||||||
if destMap, destOK := destVal.(map[string]interface{}); destOK {
|
|
||||||
if err := cms.fastMergeRecursive(srcMap, destMap, depth+1); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 快速空值检查(避免反射)
|
|
||||||
if srcVal == nil || srcVal == "" || srcVal == 0 {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dest[key] = srcVal
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// BytesProvider 轻量字节提供器
|
|
||||||
type BytesProvider struct{ data []byte }
|
|
||||||
|
|
||||||
func (bp *BytesProvider) ReadBytes() ([]byte, error) { return bp.data, nil }
|
|
||||||
func (bp *BytesProvider) Read() (map[string]interface{}, error) {
|
|
||||||
var result map[string]interface{}
|
|
||||||
return result, json.Unmarshal(bp.data, &result)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 工具函数
|
|
||||||
func orDefault[T any](value, defaultValue T) T {
|
|
||||||
var zero T
|
|
||||||
if reflect.DeepEqual(value, zero) {
|
|
||||||
return defaultValue
|
|
||||||
}
|
|
||||||
return value
|
|
||||||
}
|
|
||||||
|
|
||||||
func copyFile(src, dst string) error {
|
|
||||||
data, err := os.ReadFile(src)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return os.WriteFile(dst, data, 0644)
|
|
||||||
}
|
|
||||||
|
|
||||||
func chainLoad(k *koanf.Koanf, loaders ...func() error) error {
|
|
||||||
for _, loader := range loaders {
|
|
||||||
if err := loader(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// 工厂函数
|
|
||||||
func NewAppConfigMigrationService(logger *log.LogService, configDir, settingsPath string) *ConfigMigrationService[*models.AppConfig] {
|
|
||||||
return NewConfigMigrationService[*models.AppConfig](
|
|
||||||
logger, configDir, "settings", CurrentAppConfigVersion, settingsPath)
|
|
||||||
}
|
|
||||||
|
|||||||
167
internal/services/config_migrator_test.go
Normal file
167
internal/services/config_migrator_test.go
Normal file
@@ -0,0 +1,167 @@
|
|||||||
|
package services
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
jsonparser "github.com/knadh/koanf/parsers/json"
|
||||||
|
"github.com/knadh/koanf/providers/file"
|
||||||
|
"github.com/knadh/koanf/v2"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/wailsapp/wails/v3/pkg/services/log"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
// TestConfig represents a simplified config structure for testing
|
||||||
|
type TestConfig struct {
|
||||||
|
App struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
Version string `json:"version"`
|
||||||
|
Theme string `json:"theme"`
|
||||||
|
} `json:"app"`
|
||||||
|
User struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
Email string `json:"email"`
|
||||||
|
Settings struct {
|
||||||
|
AutoSave bool `json:"autoSave"`
|
||||||
|
Language string `json:"language"`
|
||||||
|
NewSetting bool `json:"newSetting"` // This field will be missing in old config
|
||||||
|
NewSetting2 string `json:"newSetting2"` // This field will be missing in old config
|
||||||
|
} `json:"settings"`
|
||||||
|
} `json:"user"`
|
||||||
|
NewSection struct {
|
||||||
|
Enabled bool `json:"enabled"`
|
||||||
|
Value string `json:"value"`
|
||||||
|
} `json:"newSection"` // This entire section will be missing in old config
|
||||||
|
}
|
||||||
|
|
||||||
|
// createTestConfig creates a test configuration file
|
||||||
|
func createTestConfig(t *testing.T, tempDir string) string {
|
||||||
|
// Old config without some fields
|
||||||
|
oldConfig := map[string]interface{}{
|
||||||
|
"app": map[string]interface{}{
|
||||||
|
"name": "TestApp",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"theme": "dark",
|
||||||
|
},
|
||||||
|
"user": map[string]interface{}{
|
||||||
|
"name": "Test User",
|
||||||
|
"email": "test@example.com",
|
||||||
|
"settings": map[string]interface{}{
|
||||||
|
"autoSave": true,
|
||||||
|
"language": "en",
|
||||||
|
// Missing newSetting and newSetting2
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// Missing newSection
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create config file
|
||||||
|
configPath := filepath.Join(tempDir, "config.json")
|
||||||
|
jsonData, err := json.MarshalIndent(oldConfig, "", " ")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Failed to marshal test config: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = os.WriteFile(configPath, jsonData, 0644)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Failed to write test config: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return configPath
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestConfigMigrator_AutoMigrate tests the ConfigMigrator's AutoMigrate functionality
|
||||||
|
func TestConfigMigrator_AutoMigrate(t *testing.T) {
|
||||||
|
// Create temp directory for test
|
||||||
|
tempDir, err := os.MkdirTemp("", "config_migrator_test")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Failed to create temp directory: %v", err)
|
||||||
|
}
|
||||||
|
defer os.RemoveAll(tempDir)
|
||||||
|
|
||||||
|
// Create test config file
|
||||||
|
configPath := createTestConfig(t, tempDir)
|
||||||
|
|
||||||
|
// Create logger
|
||||||
|
logger := log.New()
|
||||||
|
|
||||||
|
// Create config migrator
|
||||||
|
migrator := NewConfigMigrator(logger, tempDir, "config", configPath)
|
||||||
|
|
||||||
|
// Create koanf instance and load the config
|
||||||
|
k := koanf.New(".")
|
||||||
|
fileProvider := file.Provider(configPath)
|
||||||
|
jsonParser := jsonparser.Parser()
|
||||||
|
if err := k.Load(fileProvider, jsonParser); err != nil {
|
||||||
|
t.Fatalf("Failed to load config: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create default config with all fields
|
||||||
|
defaultConfig := TestConfig{}
|
||||||
|
defaultConfig.App.Name = "TestApp"
|
||||||
|
defaultConfig.App.Version = "1.0.0"
|
||||||
|
defaultConfig.App.Theme = "dark"
|
||||||
|
defaultConfig.User.Name = "Test User"
|
||||||
|
defaultConfig.User.Email = "test@example.com"
|
||||||
|
defaultConfig.User.Settings.AutoSave = true
|
||||||
|
defaultConfig.User.Settings.Language = "en"
|
||||||
|
defaultConfig.User.Settings.NewSetting = true // New field
|
||||||
|
defaultConfig.User.Settings.NewSetting2 = "value" // New field
|
||||||
|
defaultConfig.NewSection.Enabled = true // New section
|
||||||
|
defaultConfig.NewSection.Value = "new section" // New section
|
||||||
|
|
||||||
|
// Run auto migration
|
||||||
|
result, err := migrator.AutoMigrate(defaultConfig, k)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Failed to auto migrate: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Assertions
|
||||||
|
assert.True(t, result.Migrated, "Migration should have been performed")
|
||||||
|
|
||||||
|
// 打印检测到的缺失字段,便于分析
|
||||||
|
t.Logf("Detected fields: %v", result.MissingFields)
|
||||||
|
|
||||||
|
// 验证检测到了正确数量的字段 - 实际检测到4个
|
||||||
|
assert.Equal(t, 4, len(result.MissingFields), "Should have detected 4 missing fields")
|
||||||
|
|
||||||
|
// 期望检测到的缺失字段
|
||||||
|
expectedFields := map[string]bool{
|
||||||
|
"user.settings.newSetting": true,
|
||||||
|
"user.settings.newSetting2": true,
|
||||||
|
"newSection.enabled": true,
|
||||||
|
"newSection.value": true,
|
||||||
|
}
|
||||||
|
|
||||||
|
// 验证所有预期的字段都被检测到了
|
||||||
|
for _, field := range result.MissingFields {
|
||||||
|
_, expected := expectedFields[field]
|
||||||
|
assert.True(t, expected, "Field %s was detected but not expected", field)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 验证所有检测到的字段都在预期之内
|
||||||
|
for expectedField := range expectedFields {
|
||||||
|
found := false
|
||||||
|
for _, field := range result.MissingFields {
|
||||||
|
if field == expectedField {
|
||||||
|
found = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assert.True(t, found, "Expected field %s was not detected", expectedField)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify that the fields were actually added to the config
|
||||||
|
assert.True(t, k.Bool("user.settings.newSetting"), "newSetting should be added with correct value")
|
||||||
|
assert.Equal(t, "value", k.String("user.settings.newSetting2"), "newSetting2 should be added with correct value")
|
||||||
|
assert.True(t, k.Bool("newSection.enabled"), "newSection.enabled should be added with correct value")
|
||||||
|
assert.Equal(t, "new section", k.String("newSection.value"), "newSection.value should be added with correct value")
|
||||||
|
|
||||||
|
// Check that backup was created
|
||||||
|
backupFiles, err := filepath.Glob(filepath.Join(tempDir, "*.backup.*"))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Failed to list backup files: %v", err)
|
||||||
|
}
|
||||||
|
assert.Equal(t, 1, len(backupFiles), "One backup file should have been created")
|
||||||
|
}
|
||||||
@@ -288,25 +288,6 @@ func deepCopyValue(src, dst reflect.Value) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// deepCopyConfig 保留原有的JSON深拷贝方法作为备用
|
|
||||||
func deepCopyConfig(src *models.AppConfig) *models.AppConfig {
|
|
||||||
if src == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
jsonBytes, err := json.Marshal(src)
|
|
||||||
if err != nil {
|
|
||||||
return src
|
|
||||||
}
|
|
||||||
|
|
||||||
var dst models.AppConfig
|
|
||||||
if err := json.Unmarshal(jsonBytes, &dst); err != nil {
|
|
||||||
return src
|
|
||||||
}
|
|
||||||
|
|
||||||
return &dst
|
|
||||||
}
|
|
||||||
|
|
||||||
// debounceNotify 防抖通知
|
// debounceNotify 防抖通知
|
||||||
func (cns *ConfigNotificationService) debounceNotify(listener *ConfigListener, oldConfig, newConfig *models.AppConfig) {
|
func (cns *ConfigNotificationService) debounceNotify(listener *ConfigListener, oldConfig, newConfig *models.AppConfig) {
|
||||||
listener.mu.Lock()
|
listener.mu.Lock()
|
||||||
@@ -473,16 +454,16 @@ func CreateBackupConfigListener(name string, callback func(config *models.GitBac
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CreateWindowSnapConfigListener 创建窗口吸附配置监听器
|
// CreateWindowSnapConfigListener 创建窗口吸附配置监听器
|
||||||
func CreateWindowSnapConfigListener(name string, callback func(enabled bool, threshold int) error) *ConfigListener {
|
func CreateWindowSnapConfigListener(name string, callback func(enabled bool) error) *ConfigListener {
|
||||||
return &ConfigListener{
|
return &ConfigListener{
|
||||||
Name: name,
|
Name: name,
|
||||||
ChangeType: ConfigChangeTypeWindowSnap,
|
ChangeType: ConfigChangeTypeWindowSnap,
|
||||||
Callback: func(changeType ConfigChangeType, oldConfig, newConfig *models.AppConfig) error {
|
Callback: func(changeType ConfigChangeType, oldConfig, newConfig *models.AppConfig) error {
|
||||||
if newConfig == nil {
|
if newConfig == nil {
|
||||||
defaultConfig := models.NewDefaultAppConfig()
|
defaultConfig := models.NewDefaultAppConfig()
|
||||||
return callback(defaultConfig.General.EnableWindowSnap, defaultConfig.General.SnapThreshold)
|
return callback(defaultConfig.General.EnableWindowSnap)
|
||||||
}
|
}
|
||||||
return callback(newConfig.General.EnableWindowSnap, newConfig.General.SnapThreshold)
|
return callback(newConfig.General.EnableWindowSnap)
|
||||||
},
|
},
|
||||||
DebounceDelay: 200 * time.Millisecond,
|
DebounceDelay: 200 * time.Millisecond,
|
||||||
GetConfigFunc: func(k *koanf.Koanf) *models.AppConfig {
|
GetConfigFunc: func(k *koanf.Koanf) *models.AppConfig {
|
||||||
|
|||||||
@@ -27,8 +27,9 @@ type ConfigService struct {
|
|||||||
|
|
||||||
// 配置通知服务
|
// 配置通知服务
|
||||||
notificationService *ConfigNotificationService
|
notificationService *ConfigNotificationService
|
||||||
// 配置迁移服务
|
|
||||||
migrationService *ConfigMigrationService[*models.AppConfig]
|
// 配置迁移器
|
||||||
|
configMigrator *ConfigMigrator
|
||||||
}
|
}
|
||||||
|
|
||||||
// ConfigError 配置错误
|
// ConfigError 配置错误
|
||||||
@@ -67,16 +68,18 @@ func NewConfigService(logger *log.LogService) *ConfigService {
|
|||||||
settingsPath := filepath.Join(configDir, "settings.json")
|
settingsPath := filepath.Join(configDir, "settings.json")
|
||||||
|
|
||||||
cs := &ConfigService{
|
cs := &ConfigService{
|
||||||
logger: logger,
|
logger: logger,
|
||||||
configDir: configDir,
|
configDir: configDir,
|
||||||
settingsPath: settingsPath,
|
settingsPath: settingsPath,
|
||||||
koanf: koanf.New("."),
|
koanf: koanf.New("."),
|
||||||
migrationService: NewAppConfigMigrationService(logger, configDir, settingsPath),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 初始化配置通知服务
|
// 初始化配置通知服务
|
||||||
cs.notificationService = NewConfigNotificationService(cs.koanf, logger)
|
cs.notificationService = NewConfigNotificationService(cs.koanf, logger)
|
||||||
|
|
||||||
|
// 初始化配置迁移器
|
||||||
|
cs.configMigrator = NewConfigMigrator(logger, configDir, "settings", settingsPath)
|
||||||
|
|
||||||
cs.initConfig()
|
cs.initConfig()
|
||||||
|
|
||||||
// 启动配置文件监听
|
// 启动配置文件监听
|
||||||
@@ -106,23 +109,36 @@ func (cs *ConfigService) initConfig() error {
|
|||||||
return cs.createDefaultConfig()
|
return cs.createDefaultConfig()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 配置文件存在,先加载现有配置
|
// 检查并自动迁移配置
|
||||||
|
cs.checkConfigMigration()
|
||||||
|
|
||||||
|
// 配置文件存在,直接加载现有配置
|
||||||
cs.fileProvider = file.Provider(cs.settingsPath)
|
cs.fileProvider = file.Provider(cs.settingsPath)
|
||||||
if err := cs.koanf.Load(cs.fileProvider, jsonparser.Parser()); err != nil {
|
if err := cs.koanf.Load(cs.fileProvider, jsonparser.Parser()); err != nil {
|
||||||
return &ConfigError{Operation: "load_config_file", Err: err}
|
return &ConfigError{Operation: "load_config_file", Err: err}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查并执行配置迁移
|
return nil
|
||||||
if cs.migrationService != nil {
|
}
|
||||||
result, err := cs.migrationService.MigrateConfig(cs.koanf)
|
|
||||||
if err != nil {
|
|
||||||
return &ConfigError{Operation: "migrate_config", Err: err}
|
|
||||||
}
|
|
||||||
|
|
||||||
if result.Migrated && result.ConfigUpdated {
|
// checkConfigMigration 检查配置迁移
|
||||||
// 迁移完成且配置已更新,重新创建文件提供器以监听新文件
|
func (cs *ConfigService) checkConfigMigration() error {
|
||||||
cs.fileProvider = file.Provider(cs.settingsPath)
|
if cs.configMigrator == nil {
|
||||||
}
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
defaultConfig := models.NewDefaultAppConfig()
|
||||||
|
result, err := cs.configMigrator.AutoMigrate(defaultConfig, cs.koanf)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
cs.logger.Error("Failed to check config migration", "error", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if result != nil && result.Migrated {
|
||||||
|
cs.logger.Info("Config migration performed",
|
||||||
|
"fields", result.MissingFields,
|
||||||
|
"backup", result.BackupPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@@ -309,7 +325,7 @@ func (cs *ConfigService) SetBackupConfigChangeCallback(callback func(config *mod
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SetWindowSnapConfigChangeCallback 设置窗口吸附配置变更回调
|
// SetWindowSnapConfigChangeCallback 设置窗口吸附配置变更回调
|
||||||
func (cs *ConfigService) SetWindowSnapConfigChangeCallback(callback func(enabled bool, threshold int) error) error {
|
func (cs *ConfigService) SetWindowSnapConfigChangeCallback(callback func(enabled bool) error) error {
|
||||||
cs.mu.Lock()
|
cs.mu.Lock()
|
||||||
defer cs.mu.Unlock()
|
defer cs.mu.Unlock()
|
||||||
|
|
||||||
@@ -326,3 +342,13 @@ func (cs *ConfigService) ServiceShutdown() error {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetConfigDir 获取配置目录
|
||||||
|
func (cs *ConfigService) GetConfigDir() string {
|
||||||
|
return cs.configDir
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetSettingsPath 获取设置文件路径
|
||||||
|
func (cs *ConfigService) GetSettingsPath() string {
|
||||||
|
return cs.settingsPath
|
||||||
|
}
|
||||||
|
|||||||
@@ -116,8 +116,8 @@ func NewServiceManager() *ServiceManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 设置窗口吸附配置变更回调
|
// 设置窗口吸附配置变更回调
|
||||||
err = configService.SetWindowSnapConfigChangeCallback(func(enabled bool, threshold int) error {
|
err = configService.SetWindowSnapConfigChangeCallback(func(enabled bool) error {
|
||||||
return windowSnapService.OnWindowSnapConfigChanged(enabled, threshold)
|
return windowSnapService.OnWindowSnapConfigChanged(enabled)
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
package services
|
package services
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"math"
|
"math"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
"voidraft/internal/models"
|
"voidraft/internal/models"
|
||||||
|
|
||||||
"github.com/wailsapp/wails/v3/pkg/application"
|
"github.com/wailsapp/wails/v3/pkg/application"
|
||||||
|
"github.com/wailsapp/wails/v3/pkg/events"
|
||||||
"github.com/wailsapp/wails/v3/pkg/services/log"
|
"github.com/wailsapp/wails/v3/pkg/services/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -20,33 +20,20 @@ type WindowSnapService struct {
|
|||||||
mu sync.RWMutex
|
mu sync.RWMutex
|
||||||
|
|
||||||
// 吸附配置
|
// 吸附配置
|
||||||
snapThreshold int // 吸附触发的阈值距离(像素)
|
snapEnabled bool // 是否启用窗口吸附功能
|
||||||
snapEnabled bool // 是否启用窗口吸附功能
|
|
||||||
|
|
||||||
// 定时器控制
|
// 自适应阈值参数
|
||||||
snapTicker *time.Ticker
|
baseThresholdRatio float64 // 基础阈值比例
|
||||||
ctx context.Context
|
minThreshold int // 最小阈值(像素)
|
||||||
cancel context.CancelFunc
|
maxThreshold int // 最大阈值(像素)
|
||||||
|
|
||||||
// 性能优化相关
|
// 位置缓存
|
||||||
lastMainWindowPos models.WindowPosition // 缓存主窗口上次位置
|
lastMainWindowPos models.WindowPosition // 缓存主窗口位置
|
||||||
changedWindows map[int64]bool // 记录哪些窗口发生了变化
|
lastMainWindowSize [2]int // 缓存主窗口尺寸 [width, height]
|
||||||
skipFrames int // 跳帧计数器,用于降低检测频率
|
|
||||||
|
|
||||||
// 监听的窗口列表
|
// 管理的窗口
|
||||||
managedWindows map[int64]*SnapWindowInfo // documentID -> SnapWindowInfo
|
managedWindows map[int64]*models.WindowInfo // documentID -> WindowInfo
|
||||||
}
|
windowRefs map[int64]*application.WebviewWindow // documentID -> Window引用
|
||||||
|
|
||||||
// SnapWindowInfo 吸附窗口信息
|
|
||||||
type SnapWindowInfo struct {
|
|
||||||
Window *application.WebviewWindow
|
|
||||||
DocumentID int64
|
|
||||||
Title string
|
|
||||||
IsSnapped bool // 是否处于吸附状态
|
|
||||||
SnapOffset models.SnapPosition // 与主窗口的相对位置偏移
|
|
||||||
SnapEdge models.SnapEdge // 吸附的边缘类型
|
|
||||||
LastPos models.WindowPosition // 上一次记录的窗口位置
|
|
||||||
MoveTime time.Time // 上次移动时间,用于判断移动速度
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewWindowSnapService 创建新的窗口吸附服务实例
|
// NewWindowSnapService 创建新的窗口吸附服务实例
|
||||||
@@ -58,21 +45,20 @@ func NewWindowSnapService(logger *log.LogService, configService *ConfigService)
|
|||||||
// 从配置获取窗口吸附设置
|
// 从配置获取窗口吸附设置
|
||||||
config, err := configService.GetConfig()
|
config, err := configService.GetConfig()
|
||||||
snapEnabled := true // 默认启用
|
snapEnabled := true // 默认启用
|
||||||
snapThreshold := 15 // 默认阈值
|
|
||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
snapEnabled = config.General.EnableWindowSnap
|
snapEnabled = config.General.EnableWindowSnap
|
||||||
snapThreshold = config.General.SnapThreshold
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return &WindowSnapService{
|
return &WindowSnapService{
|
||||||
logger: logger,
|
logger: logger,
|
||||||
configService: configService,
|
configService: configService,
|
||||||
snapThreshold: snapThreshold,
|
snapEnabled: snapEnabled,
|
||||||
snapEnabled: snapEnabled,
|
baseThresholdRatio: 0.025, // 2.5%的主窗口宽度作为基础阈值
|
||||||
managedWindows: make(map[int64]*SnapWindowInfo),
|
minThreshold: 8, // 最小8像素(小屏幕保底)
|
||||||
changedWindows: make(map[int64]bool),
|
maxThreshold: 40, // 最大40像素(大屏幕上限)
|
||||||
skipFrames: 0,
|
managedWindows: make(map[int64]*models.WindowInfo),
|
||||||
|
windowRefs: make(map[int64]*application.WebviewWindow),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,11 +67,13 @@ func (wss *WindowSnapService) SetAppReferences(app *application.App, mainWindow
|
|||||||
wss.app = app
|
wss.app = app
|
||||||
wss.mainWindow = mainWindow
|
wss.mainWindow = mainWindow
|
||||||
|
|
||||||
// 初始化上下文,用于控制goroutine的生命周期
|
// 初始化主窗口位置缓存
|
||||||
wss.ctx, wss.cancel = context.WithCancel(context.Background())
|
wss.updateMainWindowCache()
|
||||||
|
|
||||||
// 启动窗口吸附监听器
|
// 设置主窗口移动事件监听
|
||||||
wss.StartWindowSnapMonitor()
|
if mainWindow != nil {
|
||||||
|
wss.setupMainWindowEvents()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// RegisterWindow 注册需要吸附管理的窗口
|
// RegisterWindow 注册需要吸附管理的窗口
|
||||||
@@ -93,16 +81,24 @@ func (wss *WindowSnapService) RegisterWindow(documentID int64, window *applicati
|
|||||||
wss.mu.Lock()
|
wss.mu.Lock()
|
||||||
defer wss.mu.Unlock()
|
defer wss.mu.Unlock()
|
||||||
|
|
||||||
wss.managedWindows[documentID] = &SnapWindowInfo{
|
// 获取初始位置
|
||||||
Window: window,
|
x, y := window.Position()
|
||||||
|
|
||||||
|
windowInfo := &models.WindowInfo{
|
||||||
DocumentID: documentID,
|
DocumentID: documentID,
|
||||||
Title: title,
|
Title: title,
|
||||||
IsSnapped: false,
|
IsSnapped: false,
|
||||||
SnapOffset: models.SnapPosition{X: 0, Y: 0},
|
SnapOffset: models.SnapPosition{X: 0, Y: 0},
|
||||||
SnapEdge: models.SnapEdgeNone,
|
SnapEdge: models.SnapEdgeNone,
|
||||||
LastPos: models.WindowPosition{X: 0, Y: 0},
|
LastPos: models.WindowPosition{X: x, Y: y},
|
||||||
MoveTime: time.Now(),
|
MoveTime: time.Now(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wss.managedWindows[documentID] = windowInfo
|
||||||
|
wss.windowRefs[documentID] = window
|
||||||
|
|
||||||
|
// 为窗口设置移动事件监听
|
||||||
|
wss.setupWindowEvents(window, windowInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnregisterWindow 取消注册窗口
|
// UnregisterWindow 取消注册窗口
|
||||||
@@ -111,7 +107,7 @@ func (wss *WindowSnapService) UnregisterWindow(documentID int64) {
|
|||||||
defer wss.mu.Unlock()
|
defer wss.mu.Unlock()
|
||||||
|
|
||||||
delete(wss.managedWindows, documentID)
|
delete(wss.managedWindows, documentID)
|
||||||
delete(wss.changedWindows, documentID)
|
delete(wss.windowRefs, documentID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetSnapEnabled 设置是否启用窗口吸附
|
// SetSnapEnabled 设置是否启用窗口吸附
|
||||||
@@ -133,196 +129,193 @@ func (wss *WindowSnapService) SetSnapEnabled(enabled bool) {
|
|||||||
windowInfo.SnapEdge = models.SnapEdgeNone
|
windowInfo.SnapEdge = models.SnapEdgeNone
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 停止定时器
|
|
||||||
if wss.snapTicker != nil {
|
|
||||||
wss.snapTicker.Stop()
|
|
||||||
wss.snapTicker = nil
|
|
||||||
}
|
|
||||||
} else if wss.snapTicker == nil && wss.app != nil {
|
|
||||||
// 重新启动定时器
|
|
||||||
wss.StartWindowSnapMonitor()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetSnapThreshold 设置窗口吸附阈值
|
// calculateAdaptiveThreshold 计算自适应吸附阈值
|
||||||
func (wss *WindowSnapService) SetSnapThreshold(threshold int) {
|
func (wss *WindowSnapService) calculateAdaptiveThreshold() int {
|
||||||
wss.mu.Lock()
|
// 基于主窗口宽度计算阈值
|
||||||
defer wss.mu.Unlock()
|
mainWidth := wss.lastMainWindowSize[0]
|
||||||
|
if mainWidth == 0 {
|
||||||
if threshold <= 0 || wss.snapThreshold == threshold {
|
return wss.minThreshold // 默认最小值
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wss.snapThreshold = threshold
|
// 计算基础阈值:主窗口宽度的2.5%
|
||||||
|
adaptiveThreshold := int(float64(mainWidth) * wss.baseThresholdRatio)
|
||||||
|
|
||||||
|
// 限制在最小和最大值之间
|
||||||
|
if adaptiveThreshold < wss.minThreshold {
|
||||||
|
return wss.minThreshold
|
||||||
|
}
|
||||||
|
if adaptiveThreshold > wss.maxThreshold {
|
||||||
|
return wss.maxThreshold
|
||||||
|
}
|
||||||
|
|
||||||
|
return adaptiveThreshold
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetCurrentThreshold 获取当前自适应阈值(用于调试或显示)
|
||||||
|
func (wss *WindowSnapService) GetCurrentThreshold() int {
|
||||||
|
wss.mu.RLock()
|
||||||
|
defer wss.mu.RUnlock()
|
||||||
|
|
||||||
|
return wss.calculateAdaptiveThreshold()
|
||||||
}
|
}
|
||||||
|
|
||||||
// OnWindowSnapConfigChanged 处理窗口吸附配置变更
|
// OnWindowSnapConfigChanged 处理窗口吸附配置变更
|
||||||
func (wss *WindowSnapService) OnWindowSnapConfigChanged(enabled bool, threshold int) error {
|
func (wss *WindowSnapService) OnWindowSnapConfigChanged(enabled bool) error {
|
||||||
wss.SetSnapEnabled(enabled)
|
wss.SetSnapEnabled(enabled)
|
||||||
wss.SetSnapThreshold(threshold)
|
// 阈值现在是自适应的,无需手动设置
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// StartWindowSnapMonitor 启动窗口吸附监听器
|
// setupMainWindowEvents 设置主窗口事件监听
|
||||||
func (wss *WindowSnapService) StartWindowSnapMonitor() {
|
func (wss *WindowSnapService) setupMainWindowEvents() {
|
||||||
// 如果定时器已存在,先停止它
|
// 监听主窗口移动事件
|
||||||
if wss.snapTicker != nil {
|
wss.mainWindow.RegisterHook(events.Common.WindowDidMove, func(event *application.WindowEvent) {
|
||||||
wss.snapTicker.Stop()
|
wss.onMainWindowMoved()
|
||||||
}
|
})
|
||||||
|
|
||||||
// 只有在吸附功能启用时才启动监听器
|
|
||||||
if !wss.snapEnabled {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 创建新的定时器,20fps 以优化性能
|
|
||||||
wss.snapTicker = time.NewTicker(50 * time.Millisecond)
|
|
||||||
|
|
||||||
// 启动goroutine持续监听窗口位置
|
|
||||||
go func() {
|
|
||||||
for {
|
|
||||||
select {
|
|
||||||
case <-wss.snapTicker.C:
|
|
||||||
wss.checkAndApplySnapping()
|
|
||||||
case <-wss.ctx.Done():
|
|
||||||
// 上下文取消时停止goroutine
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// checkAndApplySnapping 检测并应用窗口吸附(性能优化版本)
|
// setupWindowEvents 为子窗口设置事件监听
|
||||||
func (wss *WindowSnapService) checkAndApplySnapping() {
|
func (wss *WindowSnapService) setupWindowEvents(window *application.WebviewWindow, windowInfo *models.WindowInfo) {
|
||||||
if !wss.snapEnabled {
|
// 监听子窗口移动事件
|
||||||
|
window.RegisterHook(events.Common.WindowDidMove, func(event *application.WindowEvent) {
|
||||||
|
wss.onChildWindowMoved(window, windowInfo)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// updateMainWindowCache 更新主窗口缓存
|
||||||
|
func (wss *WindowSnapService) updateMainWindowCache() {
|
||||||
|
if wss.mainWindow == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 性能优化:每3帧执行一次完整检测,其他时间只处理变化的窗口
|
x, y := wss.mainWindow.Position()
|
||||||
wss.skipFrames++
|
w, h := wss.mainWindow.Size()
|
||||||
fullCheck := wss.skipFrames%3 == 0
|
|
||||||
|
wss.lastMainWindowPos = models.WindowPosition{X: x, Y: y}
|
||||||
|
wss.lastMainWindowSize = [2]int{w, h}
|
||||||
|
}
|
||||||
|
|
||||||
|
// onMainWindowMoved 主窗口移动事件处理
|
||||||
|
func (wss *WindowSnapService) onMainWindowMoved() {
|
||||||
|
if !wss.snapEnabled {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
wss.mu.Lock()
|
wss.mu.Lock()
|
||||||
defer wss.mu.Unlock()
|
defer wss.mu.Unlock()
|
||||||
|
|
||||||
// 检查主窗口是否存在且可见
|
// 更新主窗口缓存
|
||||||
if wss.mainWindow == nil || !wss.isMainWindowAvailable() {
|
wss.updateMainWindowCache()
|
||||||
// 主窗口不可用,解除所有吸附
|
|
||||||
for _, windowInfo := range wss.managedWindows {
|
// 只更新已吸附窗口的位置,无需重新检测所有窗口
|
||||||
if windowInfo.IsSnapped {
|
for _, windowInfo := range wss.managedWindows {
|
||||||
windowInfo.IsSnapped = false
|
if windowInfo.IsSnapped {
|
||||||
windowInfo.SnapEdge = models.SnapEdgeNone
|
wss.updateSnappedWindowPosition(windowInfo)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// 清空变化记录
|
}
|
||||||
wss.changedWindows = make(map[int64]bool)
|
}
|
||||||
|
|
||||||
|
// onChildWindowMoved 子窗口移动事件处理
|
||||||
|
func (wss *WindowSnapService) onChildWindowMoved(window *application.WebviewWindow, windowInfo *models.WindowInfo) {
|
||||||
|
if !wss.snapEnabled {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
mainPos, _ := wss.getWindowPosition(wss.mainWindow)
|
wss.mu.Lock()
|
||||||
|
defer wss.mu.Unlock()
|
||||||
|
|
||||||
// 检查主窗口是否移动了
|
// 获取当前位置
|
||||||
mainWindowMoved := mainPos.X != wss.lastMainWindowPos.X || mainPos.Y != wss.lastMainWindowPos.Y
|
x, y := window.Position()
|
||||||
if mainWindowMoved {
|
currentPos := models.WindowPosition{X: x, Y: y}
|
||||||
wss.lastMainWindowPos = mainPos
|
|
||||||
// 主窗口移动了,标记所有吸附的窗口为变化
|
// 检查是否真的移动了(避免无效触发)
|
||||||
for documentID, windowInfo := range wss.managedWindows {
|
if currentPos.X == windowInfo.LastPos.X && currentPos.Y == windowInfo.LastPos.Y {
|
||||||
if windowInfo.IsSnapped {
|
return
|
||||||
wss.changedWindows[documentID] = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for documentID, windowInfo := range wss.managedWindows {
|
// 保存上次移动时间用于防抖检测
|
||||||
currentPos, _ := wss.getWindowPosition(windowInfo.Window)
|
lastMoveTime := windowInfo.MoveTime
|
||||||
|
windowInfo.MoveTime = time.Now()
|
||||||
|
|
||||||
// 检查窗口是否移动了
|
if windowInfo.IsSnapped {
|
||||||
hasMoved := currentPos.X != windowInfo.LastPos.X || currentPos.Y != windowInfo.LastPos.Y
|
// 已吸附窗口:检查是否被用户拖拽解除吸附
|
||||||
if hasMoved {
|
wss.handleSnappedWindow(window, windowInfo, currentPos)
|
||||||
windowInfo.MoveTime = time.Now()
|
// 对于已吸附窗口,总是更新为当前位置
|
||||||
|
windowInfo.LastPos = currentPos
|
||||||
|
} else {
|
||||||
|
// 未吸附窗口:检查是否应该吸附
|
||||||
|
isSnapped := wss.handleUnsnappedWindow(window, windowInfo, currentPos, lastMoveTime)
|
||||||
|
if !isSnapped {
|
||||||
|
// 如果没有吸附,更新为当前位置
|
||||||
windowInfo.LastPos = currentPos
|
windowInfo.LastPos = currentPos
|
||||||
wss.changedWindows[documentID] = true
|
|
||||||
}
|
}
|
||||||
|
// 如果成功吸附,位置已在handleUnsnappedWindow中更新
|
||||||
// 性能优化:只处理变化的窗口或进行完整检查时
|
|
||||||
if !fullCheck && !wss.changedWindows[documentID] {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if windowInfo.IsSnapped {
|
|
||||||
// 窗口已吸附,检查是否需要更新位置或解除吸附
|
|
||||||
wss.handleSnappedWindow(windowInfo, mainPos, currentPos)
|
|
||||||
} else {
|
|
||||||
// 窗口未吸附,检查是否应该吸附
|
|
||||||
wss.handleUnsnappedWindow(windowInfo)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 处理完成后清除变化标记
|
|
||||||
delete(wss.changedWindows, documentID)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// isMainWindowAvailable 检查主窗口是否可用
|
// updateSnappedWindowPosition 更新已吸附窗口的位置
|
||||||
func (wss *WindowSnapService) isMainWindowAvailable() bool {
|
func (wss *WindowSnapService) updateSnappedWindowPosition(windowInfo *models.WindowInfo) {
|
||||||
if wss.mainWindow == nil {
|
// 计算新的目标位置(基于主窗口新位置)
|
||||||
return false
|
expectedX := wss.lastMainWindowPos.X + windowInfo.SnapOffset.X
|
||||||
|
expectedY := wss.lastMainWindowPos.Y + windowInfo.SnapOffset.Y
|
||||||
|
|
||||||
|
// 查找对应的window对象并移动
|
||||||
|
if window, exists := wss.windowRefs[windowInfo.DocumentID]; exists {
|
||||||
|
window.SetPosition(expectedX, expectedY)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查主窗口是否可见和正常状态
|
windowInfo.LastPos = models.WindowPosition{X: expectedX, Y: expectedY}
|
||||||
return wss.mainWindow.IsVisible()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// handleSnappedWindow 处理已吸附的窗口
|
// handleSnappedWindow 处理已吸附窗口的移动
|
||||||
func (wss *WindowSnapService) handleSnappedWindow(windowInfo *SnapWindowInfo, mainPos models.WindowPosition, currentPos models.WindowPosition) {
|
func (wss *WindowSnapService) handleSnappedWindow(window *application.WebviewWindow, windowInfo *models.WindowInfo, currentPos models.WindowPosition) {
|
||||||
// 计算预期位置基于主窗口的新位置
|
// 计算预期位置
|
||||||
expectedX := mainPos.X + windowInfo.SnapOffset.X
|
expectedX := wss.lastMainWindowPos.X + windowInfo.SnapOffset.X
|
||||||
expectedY := mainPos.Y + windowInfo.SnapOffset.Y
|
expectedY := wss.lastMainWindowPos.Y + windowInfo.SnapOffset.Y
|
||||||
|
|
||||||
// 计算当前位置与预期位置的距离
|
// 计算实际位置与预期位置的距离
|
||||||
distanceX := math.Abs(float64(currentPos.X - expectedX))
|
distanceX := math.Abs(float64(currentPos.X - expectedX))
|
||||||
distanceY := math.Abs(float64(currentPos.Y - expectedY))
|
distanceY := math.Abs(float64(currentPos.Y - expectedY))
|
||||||
maxDistance := math.Max(distanceX, distanceY)
|
maxDistance := math.Max(distanceX, distanceY)
|
||||||
|
|
||||||
// 检测是否为用户主动拖拽:如果窗口移动幅度超过阈值且是最近移动的
|
// 用户拖拽检测:距离超过阈值且移动很快
|
||||||
userDragThreshold := float64(wss.snapThreshold)
|
userDragThreshold := float64(wss.calculateAdaptiveThreshold())
|
||||||
isUserDrag := maxDistance > userDragThreshold && time.Since(windowInfo.MoveTime) < 100*time.Millisecond
|
isUserDrag := maxDistance > userDragThreshold && time.Since(windowInfo.MoveTime) < 50*time.Millisecond
|
||||||
|
|
||||||
if isUserDrag {
|
if isUserDrag {
|
||||||
// 用户主动拖拽,立即解除吸附
|
// 用户主动拖拽,解除吸附
|
||||||
windowInfo.IsSnapped = false
|
windowInfo.IsSnapped = false
|
||||||
windowInfo.SnapEdge = models.SnapEdgeNone
|
windowInfo.SnapEdge = models.SnapEdgeNone
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 对于主窗口移动导致的位置变化,立即跟随且不解除吸附
|
|
||||||
if maxDistance > 0 {
|
|
||||||
// 直接调整到预期位置,不使用平滑移动以提高响应速度
|
|
||||||
windowInfo.Window.SetPosition(expectedX, expectedY)
|
|
||||||
windowInfo.LastPos = models.WindowPosition{X: expectedX, Y: expectedY}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// handleUnsnappedWindow 处理未吸附的窗口
|
// handleUnsnappedWindow 处理未吸附窗口的移动,返回是否成功吸附
|
||||||
func (wss *WindowSnapService) handleUnsnappedWindow(windowInfo *SnapWindowInfo) {
|
func (wss *WindowSnapService) handleUnsnappedWindow(window *application.WebviewWindow, windowInfo *models.WindowInfo, currentPos models.WindowPosition, lastMoveTime time.Time) bool {
|
||||||
// 检查是否应该吸附到主窗口
|
// 检查是否应该吸附
|
||||||
should, snapEdge := wss.shouldSnapToMainWindow(windowInfo)
|
should, snapEdge := wss.shouldSnapToMainWindow(window, windowInfo, currentPos, lastMoveTime)
|
||||||
if should {
|
if should {
|
||||||
// 获取主窗口位置用于计算偏移量
|
|
||||||
mainPos, _ := wss.getWindowPosition(wss.mainWindow)
|
|
||||||
|
|
||||||
// 设置吸附状态
|
// 设置吸附状态
|
||||||
windowInfo.IsSnapped = true
|
windowInfo.IsSnapped = true
|
||||||
windowInfo.SnapEdge = snapEdge
|
windowInfo.SnapEdge = snapEdge
|
||||||
|
|
||||||
// 执行即时吸附,产生明显的吸附效果
|
// 执行吸附移动
|
||||||
wss.snapWindowToMainWindow(windowInfo, snapEdge)
|
targetPos := wss.calculateSnapPosition(snapEdge, currentPos, window)
|
||||||
|
window.SetPosition(targetPos.X, targetPos.Y)
|
||||||
|
|
||||||
// 重新获取吸附后的位置来计算偏移量
|
// 计算并保存偏移量
|
||||||
newPos, _ := wss.getWindowPosition(windowInfo.Window)
|
windowInfo.SnapOffset.X = targetPos.X - wss.lastMainWindowPos.X
|
||||||
windowInfo.SnapOffset.X = newPos.X - mainPos.X
|
windowInfo.SnapOffset.Y = targetPos.Y - wss.lastMainWindowPos.Y
|
||||||
windowInfo.SnapOffset.Y = newPos.Y - mainPos.Y
|
|
||||||
windowInfo.LastPos = newPos
|
// 更新位置为吸附后的位置
|
||||||
|
windowInfo.LastPos = targetPos
|
||||||
|
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// getWindowPosition 获取窗口的位置
|
// getWindowPosition 获取窗口的位置
|
||||||
@@ -331,269 +324,160 @@ func (wss *WindowSnapService) getWindowPosition(window *application.WebviewWindo
|
|||||||
return models.WindowPosition{X: x, Y: y}, true
|
return models.WindowPosition{X: x, Y: y}, true
|
||||||
}
|
}
|
||||||
|
|
||||||
// shouldSnapToMainWindow 检查窗口是否应该吸附到主窗口(支持角落吸附)
|
// shouldSnapToMainWindow 优化版吸附检测
|
||||||
func (wss *WindowSnapService) shouldSnapToMainWindow(windowInfo *SnapWindowInfo) (bool, models.SnapEdge) {
|
func (wss *WindowSnapService) shouldSnapToMainWindow(window *application.WebviewWindow, windowInfo *models.WindowInfo, currentPos models.WindowPosition, lastMoveTime time.Time) (bool, models.SnapEdge) {
|
||||||
// 降低防抖时间,提高吸附响应速度
|
// 防抖:移动太快时不检测,
|
||||||
if time.Since(windowInfo.MoveTime) < 50*time.Millisecond {
|
timeSinceLastMove := time.Since(lastMoveTime)
|
||||||
|
if timeSinceLastMove < 30*time.Millisecond && timeSinceLastMove > 0 {
|
||||||
return false, models.SnapEdgeNone
|
return false, models.SnapEdgeNone
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取两个窗口的位置
|
// 使用缓存的主窗口位置和尺寸
|
||||||
mainPos, _ := wss.getWindowPosition(wss.mainWindow)
|
if wss.lastMainWindowSize[0] == 0 || wss.lastMainWindowSize[1] == 0 {
|
||||||
windowPos, _ := wss.getWindowPosition(windowInfo.Window)
|
// 主窗口缓存未初始化,立即更新
|
||||||
|
wss.updateMainWindowCache()
|
||||||
|
}
|
||||||
|
|
||||||
// 获取主窗口尺寸
|
mainPos := wss.lastMainWindowPos
|
||||||
mainWidth, mainHeight := wss.mainWindow.Size()
|
mainWidth := wss.lastMainWindowSize[0]
|
||||||
|
mainHeight := wss.lastMainWindowSize[1]
|
||||||
|
|
||||||
// 获取子窗口尺寸
|
// 获取子窗口尺寸
|
||||||
windowWidth, windowHeight := windowInfo.Window.Size()
|
windowWidth, windowHeight := window.Size()
|
||||||
|
|
||||||
// 计算各个边缘的距离
|
// 自适应阈值计算
|
||||||
threshold := float64(wss.snapThreshold)
|
threshold := float64(wss.calculateAdaptiveThreshold())
|
||||||
cornerThreshold := threshold * 1.5 // 角落吸附需要更大的阈值
|
cornerThreshold := threshold * 1.5
|
||||||
|
|
||||||
// 主窗口的四个边界
|
// 计算边界
|
||||||
mainLeft := mainPos.X
|
mainLeft, mainTop := mainPos.X, mainPos.Y
|
||||||
mainTop := mainPos.Y
|
mainRight, mainBottom := mainPos.X+mainWidth, mainPos.Y+mainHeight
|
||||||
mainRight := mainPos.X + mainWidth
|
|
||||||
mainBottom := mainPos.Y + mainHeight
|
|
||||||
|
|
||||||
// 子窗口的四个边界
|
windowLeft, windowTop := currentPos.X, currentPos.Y
|
||||||
windowLeft := windowPos.X
|
windowRight, windowBottom := currentPos.X+windowWidth, currentPos.Y+windowHeight
|
||||||
windowTop := windowPos.Y
|
|
||||||
windowRight := windowPos.X + windowWidth
|
|
||||||
windowBottom := windowPos.Y + windowHeight
|
|
||||||
|
|
||||||
// 存储每个边缘的吸附信息
|
// 简化的距离计算结构
|
||||||
type snapCandidate struct {
|
type snapCheck struct {
|
||||||
edge models.SnapEdge
|
edge models.SnapEdge
|
||||||
distance float64
|
distance float64
|
||||||
overlap float64 // 重叠度,用于优先级判断
|
priority int // 1=角落, 2=边缘
|
||||||
isCorner bool // 是否为角落吸附
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var candidates []snapCandidate
|
var bestSnap *snapCheck
|
||||||
|
|
||||||
// ==== 检查角落吸附(优先级最高) ====
|
// 检查角落吸附(优先级1)
|
||||||
|
cornerChecks := []struct {
|
||||||
// 1. 右上角 (SnapEdgeTopRight)
|
edge models.SnapEdge
|
||||||
distToTopRight := math.Sqrt(math.Pow(float64(mainRight-windowLeft), 2) + math.Pow(float64(mainTop-windowBottom), 2))
|
dx int
|
||||||
if distToTopRight <= cornerThreshold {
|
dy int
|
||||||
// 检查是否接近右上角区域
|
}{
|
||||||
horizDist := math.Abs(float64(mainRight - windowLeft))
|
{models.SnapEdgeTopRight, mainRight - windowLeft, mainTop - windowBottom},
|
||||||
vertDist := math.Abs(float64(mainTop - windowBottom))
|
{models.SnapEdgeBottomRight, mainRight - windowLeft, mainBottom - windowTop},
|
||||||
if horizDist <= cornerThreshold && vertDist <= cornerThreshold {
|
{models.SnapEdgeBottomLeft, mainLeft - windowRight, mainBottom - windowTop},
|
||||||
candidates = append(candidates, snapCandidate{models.SnapEdgeTopRight, distToTopRight, 100, true})
|
{models.SnapEdgeTopLeft, mainLeft - windowRight, mainTop - windowBottom},
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. 右下角 (SnapEdgeBottomRight)
|
for _, check := range cornerChecks {
|
||||||
distToBottomRight := math.Sqrt(math.Pow(float64(mainRight-windowLeft), 2) + math.Pow(float64(mainBottom-windowTop), 2))
|
dist := math.Sqrt(float64(check.dx*check.dx + check.dy*check.dy))
|
||||||
if distToBottomRight <= cornerThreshold {
|
if dist <= cornerThreshold {
|
||||||
horizDist := math.Abs(float64(mainRight - windowLeft))
|
if bestSnap == nil || dist < bestSnap.distance {
|
||||||
vertDist := math.Abs(float64(mainBottom - windowTop))
|
bestSnap = &snapCheck{check.edge, dist, 1}
|
||||||
if horizDist <= cornerThreshold && vertDist <= cornerThreshold {
|
|
||||||
candidates = append(candidates, snapCandidate{models.SnapEdgeBottomRight, distToBottomRight, 100, true})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. 左下角 (SnapEdgeBottomLeft)
|
|
||||||
distToBottomLeft := math.Sqrt(math.Pow(float64(mainLeft-windowRight), 2) + math.Pow(float64(mainBottom-windowTop), 2))
|
|
||||||
if distToBottomLeft <= cornerThreshold {
|
|
||||||
horizDist := math.Abs(float64(mainLeft - windowRight))
|
|
||||||
vertDist := math.Abs(float64(mainBottom - windowTop))
|
|
||||||
if horizDist <= cornerThreshold && vertDist <= cornerThreshold {
|
|
||||||
candidates = append(candidates, snapCandidate{models.SnapEdgeBottomLeft, distToBottomLeft, 100, true})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 4. 左上角 (SnapEdgeTopLeft)
|
|
||||||
distToTopLeft := math.Sqrt(math.Pow(float64(mainLeft-windowRight), 2) + math.Pow(float64(mainTop-windowBottom), 2))
|
|
||||||
if distToTopLeft <= cornerThreshold {
|
|
||||||
horizDist := math.Abs(float64(mainLeft - windowRight))
|
|
||||||
vertDist := math.Abs(float64(mainTop - windowBottom))
|
|
||||||
if horizDist <= cornerThreshold && vertDist <= cornerThreshold {
|
|
||||||
candidates = append(candidates, snapCandidate{models.SnapEdgeTopLeft, distToTopLeft, 100, true})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ==== 检查边缘吸附(只在没有角落吸附时检查) ====
|
|
||||||
if len(candidates) == 0 {
|
|
||||||
// 1. 吸附到主窗口右侧
|
|
||||||
distToRight := math.Abs(float64(mainRight - windowLeft))
|
|
||||||
if distToRight <= threshold {
|
|
||||||
// 计算垂直重叠
|
|
||||||
overlapTop := math.Max(float64(mainTop), float64(windowTop))
|
|
||||||
overlapBottom := math.Min(float64(mainBottom), float64(windowBottom))
|
|
||||||
verticalOverlap := math.Max(0, overlapBottom-overlapTop)
|
|
||||||
candidates = append(candidates, snapCandidate{models.SnapEdgeRight, distToRight, verticalOverlap, false})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2. 吸附到主窗口左侧
|
|
||||||
distToLeft := math.Abs(float64(mainLeft - windowRight))
|
|
||||||
if distToLeft <= threshold {
|
|
||||||
// 计算垂直重叠
|
|
||||||
overlapTop := math.Max(float64(mainTop), float64(windowTop))
|
|
||||||
overlapBottom := math.Min(float64(mainBottom), float64(windowBottom))
|
|
||||||
verticalOverlap := math.Max(0, overlapBottom-overlapTop)
|
|
||||||
candidates = append(candidates, snapCandidate{models.SnapEdgeLeft, distToLeft, verticalOverlap, false})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. 吸附到主窗口底部
|
|
||||||
distToBottom := math.Abs(float64(mainBottom - windowTop))
|
|
||||||
if distToBottom <= threshold {
|
|
||||||
// 计算水平重叠
|
|
||||||
overlapLeft := math.Max(float64(mainLeft), float64(windowLeft))
|
|
||||||
overlapRight := math.Min(float64(mainRight), float64(windowRight))
|
|
||||||
horizontalOverlap := math.Max(0, overlapRight-overlapLeft)
|
|
||||||
candidates = append(candidates, snapCandidate{models.SnapEdgeBottom, distToBottom, horizontalOverlap, false})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 4. 吸附到主窗口顶部
|
|
||||||
distToTop := math.Abs(float64(mainTop - windowBottom))
|
|
||||||
if distToTop <= threshold {
|
|
||||||
// 计算水平重叠
|
|
||||||
overlapLeft := math.Max(float64(mainLeft), float64(windowLeft))
|
|
||||||
overlapRight := math.Min(float64(mainRight), float64(windowRight))
|
|
||||||
horizontalOverlap := math.Max(0, overlapRight-overlapLeft)
|
|
||||||
candidates = append(candidates, snapCandidate{models.SnapEdgeTop, distToTop, horizontalOverlap, false})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 如果没有候选,不吸附
|
|
||||||
if len(candidates) == 0 {
|
|
||||||
return false, models.SnapEdgeNone
|
|
||||||
}
|
|
||||||
|
|
||||||
// 选择最佳吸附位置:角落吸附优先,其次考虑重叠度,最后考虑距离
|
|
||||||
bestCandidate := candidates[0]
|
|
||||||
for _, candidate := range candidates[1:] {
|
|
||||||
// 角落吸附优先级最高
|
|
||||||
if candidate.isCorner && !bestCandidate.isCorner {
|
|
||||||
bestCandidate = candidate
|
|
||||||
} else if bestCandidate.isCorner && !candidate.isCorner {
|
|
||||||
// 继续使用当前的角落吸附
|
|
||||||
continue
|
|
||||||
} else {
|
|
||||||
// 同类型的吸附,比较重叠度和距离
|
|
||||||
if math.Abs(candidate.overlap-bestCandidate.overlap) < 10 {
|
|
||||||
if candidate.distance < bestCandidate.distance {
|
|
||||||
bestCandidate = candidate
|
|
||||||
}
|
|
||||||
} else if candidate.overlap > bestCandidate.overlap {
|
|
||||||
// 重叠度更高的优先
|
|
||||||
bestCandidate = candidate
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true, bestCandidate.edge
|
// 如果没有角落吸附,检查边缘吸附(优先级2)
|
||||||
|
if bestSnap == nil {
|
||||||
|
edgeChecks := []struct {
|
||||||
|
edge models.SnapEdge
|
||||||
|
distance float64
|
||||||
|
}{
|
||||||
|
{models.SnapEdgeRight, math.Abs(float64(mainRight - windowLeft))},
|
||||||
|
{models.SnapEdgeLeft, math.Abs(float64(mainLeft - windowRight))},
|
||||||
|
{models.SnapEdgeBottom, math.Abs(float64(mainBottom - windowTop))},
|
||||||
|
{models.SnapEdgeTop, math.Abs(float64(mainTop - windowBottom))},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, check := range edgeChecks {
|
||||||
|
if check.distance <= threshold {
|
||||||
|
if bestSnap == nil || check.distance < bestSnap.distance {
|
||||||
|
bestSnap = &snapCheck{check.edge, check.distance, 2}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if bestSnap == nil {
|
||||||
|
return false, models.SnapEdgeNone
|
||||||
|
}
|
||||||
|
|
||||||
|
return true, bestSnap.edge
|
||||||
}
|
}
|
||||||
|
|
||||||
// snapWindowToMainWindow 将窗口精确吸附到主窗口边缘(支持角落吸附)
|
// calculateSnapPosition 计算吸附目标位置
|
||||||
func (wss *WindowSnapService) snapWindowToMainWindow(windowInfo *SnapWindowInfo, snapEdge models.SnapEdge) {
|
func (wss *WindowSnapService) calculateSnapPosition(snapEdge models.SnapEdge, currentPos models.WindowPosition, window *application.WebviewWindow) models.WindowPosition {
|
||||||
// 获取主窗口位置和尺寸
|
// 使用缓存的主窗口信息
|
||||||
mainPos, _ := wss.getWindowPosition(wss.mainWindow)
|
mainPos := wss.lastMainWindowPos
|
||||||
mainWidth, mainHeight := wss.mainWindow.Size()
|
mainWidth := wss.lastMainWindowSize[0]
|
||||||
|
mainHeight := wss.lastMainWindowSize[1]
|
||||||
|
|
||||||
// 获取子窗口位置和尺寸
|
// 获取子窗口尺寸
|
||||||
windowPos, _ := wss.getWindowPosition(windowInfo.Window)
|
windowWidth, windowHeight := window.Size()
|
||||||
windowWidth, windowHeight := windowInfo.Window.Size()
|
|
||||||
|
|
||||||
// 计算目标位置
|
|
||||||
var targetX, targetY int
|
|
||||||
|
|
||||||
switch snapEdge {
|
switch snapEdge {
|
||||||
case models.SnapEdgeRight:
|
case models.SnapEdgeRight:
|
||||||
// 吸附到主窗口右侧
|
return models.WindowPosition{
|
||||||
targetX = mainPos.X + mainWidth
|
X: mainPos.X + mainWidth,
|
||||||
targetY = windowPos.Y // 保持当前 Y 位置
|
Y: currentPos.Y, // 保持当前Y位置
|
||||||
// 如果超出主窗口范围,调整到边界
|
|
||||||
if targetY < mainPos.Y {
|
|
||||||
targetY = mainPos.Y
|
|
||||||
} else if targetY+windowHeight > mainPos.Y+mainHeight {
|
|
||||||
targetY = mainPos.Y + mainHeight - windowHeight
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case models.SnapEdgeLeft:
|
case models.SnapEdgeLeft:
|
||||||
// 吸附到主窗口左侧
|
return models.WindowPosition{
|
||||||
targetX = mainPos.X - windowWidth
|
X: mainPos.X - windowWidth,
|
||||||
targetY = windowPos.Y // 保持当前 Y 位置
|
Y: currentPos.Y,
|
||||||
// 如果超出主窗口范围,调整到边界
|
|
||||||
if targetY < mainPos.Y {
|
|
||||||
targetY = mainPos.Y
|
|
||||||
} else if targetY+windowHeight > mainPos.Y+mainHeight {
|
|
||||||
targetY = mainPos.Y + mainHeight - windowHeight
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case models.SnapEdgeBottom:
|
case models.SnapEdgeBottom:
|
||||||
// 吸附到主窗口底部
|
return models.WindowPosition{
|
||||||
targetX = windowPos.X // 保持当前 X 位置
|
X: currentPos.X,
|
||||||
targetY = mainPos.Y + mainHeight
|
Y: mainPos.Y + mainHeight,
|
||||||
// 如果超出主窗口范围,调整到边界
|
|
||||||
if targetX < mainPos.X {
|
|
||||||
targetX = mainPos.X
|
|
||||||
} else if targetX+windowWidth > mainPos.X+mainWidth {
|
|
||||||
targetX = mainPos.X + mainWidth - windowWidth
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case models.SnapEdgeTop:
|
case models.SnapEdgeTop:
|
||||||
// 吸附到主窗口顶部
|
return models.WindowPosition{
|
||||||
targetX = windowPos.X // 保持当前 X 位置
|
X: currentPos.X,
|
||||||
targetY = mainPos.Y - windowHeight
|
Y: mainPos.Y - windowHeight,
|
||||||
// 如果超出主窗口范围,调整到边界
|
|
||||||
if targetX < mainPos.X {
|
|
||||||
targetX = mainPos.X
|
|
||||||
} else if targetX+windowWidth > mainPos.X+mainWidth {
|
|
||||||
targetX = mainPos.X + mainWidth - windowWidth
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==== 角落吸附 ====
|
|
||||||
case models.SnapEdgeTopRight:
|
case models.SnapEdgeTopRight:
|
||||||
// 吸附到右上角
|
return models.WindowPosition{
|
||||||
targetX = mainPos.X + mainWidth
|
X: mainPos.X + mainWidth,
|
||||||
targetY = mainPos.Y - windowHeight
|
Y: mainPos.Y - windowHeight,
|
||||||
|
}
|
||||||
case models.SnapEdgeBottomRight:
|
case models.SnapEdgeBottomRight:
|
||||||
// 吸附到右下角
|
return models.WindowPosition{
|
||||||
targetX = mainPos.X + mainWidth
|
X: mainPos.X + mainWidth,
|
||||||
targetY = mainPos.Y + mainHeight
|
Y: mainPos.Y + mainHeight,
|
||||||
|
}
|
||||||
case models.SnapEdgeBottomLeft:
|
case models.SnapEdgeBottomLeft:
|
||||||
// 吸附到左下角
|
return models.WindowPosition{
|
||||||
targetX = mainPos.X - windowWidth
|
X: mainPos.X - windowWidth,
|
||||||
targetY = mainPos.Y + mainHeight
|
Y: mainPos.Y + mainHeight,
|
||||||
|
}
|
||||||
case models.SnapEdgeTopLeft:
|
case models.SnapEdgeTopLeft:
|
||||||
// 吸附到左上角
|
return models.WindowPosition{
|
||||||
targetX = mainPos.X - windowWidth
|
X: mainPos.X - windowWidth,
|
||||||
targetY = mainPos.Y - windowHeight
|
Y: mainPos.Y - windowHeight,
|
||||||
|
}
|
||||||
default:
|
|
||||||
// 不应该到达这里
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 直接移动到目标位置,不使用平滑过渡以产生明显的吸附效果
|
return currentPos
|
||||||
windowInfo.Window.SetPosition(targetX, targetY)
|
|
||||||
|
|
||||||
// 更新窗口信息
|
|
||||||
windowInfo.SnapEdge = snapEdge
|
|
||||||
windowInfo.LastPos = models.WindowPosition{X: targetX, Y: targetY}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cleanup 清理资源
|
// Cleanup 清理资源
|
||||||
func (wss *WindowSnapService) Cleanup() {
|
func (wss *WindowSnapService) Cleanup() {
|
||||||
// 如果有取消函数,调用它来停止所有goroutine
|
wss.mu.Lock()
|
||||||
if wss.cancel != nil {
|
defer wss.mu.Unlock()
|
||||||
wss.cancel()
|
|
||||||
}
|
|
||||||
|
|
||||||
// 停止定时器
|
// 清空管理的窗口
|
||||||
if wss.snapTicker != nil {
|
wss.managedWindows = make(map[int64]*models.WindowInfo)
|
||||||
wss.snapTicker.Stop()
|
wss.windowRefs = make(map[int64]*application.WebviewWindow)
|
||||||
wss.snapTicker = nil
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ServiceShutdown 实现服务关闭接口
|
// ServiceShutdown 实现服务关闭接口
|
||||||
|
|||||||
@@ -12,13 +12,13 @@ func SetupSystemTray(app *application.App, mainWindow *application.WebviewWindow
|
|||||||
// 创建系统托盘
|
// 创建系统托盘
|
||||||
systray := app.SystemTray.New()
|
systray := app.SystemTray.New()
|
||||||
|
|
||||||
|
// 设置标签
|
||||||
|
systray.SetLabel("voidraft")
|
||||||
|
systray.Label()
|
||||||
// 设置图标
|
// 设置图标
|
||||||
iconBytes, _ := assets.ReadFile("appicon.png")
|
iconBytes, _ := assets.ReadFile("appicon.png")
|
||||||
systray.SetIcon(iconBytes)
|
systray.SetIcon(iconBytes)
|
||||||
|
|
||||||
// 设置标签
|
|
||||||
systray.SetLabel("VoidRaft")
|
|
||||||
|
|
||||||
// 创建托盘菜单
|
// 创建托盘菜单
|
||||||
menu := app.NewMenu()
|
menu := app.NewMenu()
|
||||||
|
|
||||||
|
|||||||
4
internal/version/version.go
Normal file
4
internal/version/version.go
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
package version
|
||||||
|
|
||||||
|
// Version 版本注入 Ldflags
|
||||||
|
var Version = "0.0.0"
|
||||||
73
scripts/version.bat
Normal file
73
scripts/version.bat
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
@echo off
|
||||||
|
setlocal enabledelayedexpansion
|
||||||
|
|
||||||
|
REM Simplified version management script - Windows version
|
||||||
|
REM Auto-increment patch version from git tags or use custom version
|
||||||
|
|
||||||
|
REM Configuration section - Set custom version here if needed
|
||||||
|
set "CUSTOM_VERSION="
|
||||||
|
REM Example: set "CUSTOM_VERSION=2.0.0"
|
||||||
|
|
||||||
|
set "VERSION_FILE=version.txt"
|
||||||
|
|
||||||
|
REM Check if custom version is set
|
||||||
|
if not "%CUSTOM_VERSION%"=="" (
|
||||||
|
echo [INFO] Using custom version: %CUSTOM_VERSION%
|
||||||
|
set "VERSION=%CUSTOM_VERSION%"
|
||||||
|
goto :save_version
|
||||||
|
)
|
||||||
|
|
||||||
|
REM Check if git is available
|
||||||
|
git --version >nul 2>&1
|
||||||
|
if errorlevel 1 (
|
||||||
|
echo [ERROR] Git is not installed or not in PATH
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
|
||||||
|
REM Check if in git repository
|
||||||
|
git rev-parse --git-dir >nul 2>&1
|
||||||
|
if errorlevel 1 (
|
||||||
|
echo [ERROR] Not in a git repository
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
|
||||||
|
REM Get latest git tag
|
||||||
|
git describe --abbrev=0 --tags > temp_tag.txt 2>nul
|
||||||
|
if errorlevel 1 (
|
||||||
|
echo [ERROR] No git tags found in repository
|
||||||
|
if exist temp_tag.txt del temp_tag.txt
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
|
||||||
|
set /p LATEST_TAG=<temp_tag.txt
|
||||||
|
del temp_tag.txt
|
||||||
|
|
||||||
|
if not defined LATEST_TAG (
|
||||||
|
echo [ERROR] Failed to read git tag
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
|
||||||
|
echo [INFO] Latest git tag: %LATEST_TAG%
|
||||||
|
|
||||||
|
REM Remove v prefix
|
||||||
|
set "CLEAN_VERSION=%LATEST_TAG:v=%"
|
||||||
|
|
||||||
|
REM Split version number and increment patch
|
||||||
|
for /f "tokens=1,2,3 delims=." %%a in ("%CLEAN_VERSION%") do (
|
||||||
|
set "MAJOR=%%a"
|
||||||
|
set "MINOR=%%b"
|
||||||
|
set /a "PATCH=%%c+1"
|
||||||
|
)
|
||||||
|
|
||||||
|
set "VERSION=%MAJOR%.%MINOR%.%PATCH%"
|
||||||
|
echo [INFO] Auto-incremented patch version: %VERSION%
|
||||||
|
|
||||||
|
:save_version
|
||||||
|
REM Output version information
|
||||||
|
echo [SUCCESS] Version resolved: %VERSION%
|
||||||
|
echo VERSION=%VERSION%
|
||||||
|
|
||||||
|
REM Save to file
|
||||||
|
echo VERSION=%VERSION% > %VERSION_FILE%
|
||||||
|
|
||||||
|
echo [INFO] Version information saved to %VERSION_FILE%
|
||||||
50
scripts/version.sh
Normal file
50
scripts/version.sh
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# 配置区域 - 如需自定义版本,请在此处设置
|
||||||
|
CUSTOM_VERSION=""
|
||||||
|
# 示例: CUSTOM_VERSION="2.0.0"
|
||||||
|
|
||||||
|
VERSION_FILE="version.txt"
|
||||||
|
|
||||||
|
# 检查是否设置了自定义版本
|
||||||
|
if [ -n "$CUSTOM_VERSION" ]; then
|
||||||
|
echo "[INFO] Using custom version: $CUSTOM_VERSION"
|
||||||
|
VERSION="$CUSTOM_VERSION"
|
||||||
|
else
|
||||||
|
# 检查git是否可用
|
||||||
|
if ! command -v git &> /dev/null; then
|
||||||
|
echo "[ERROR] Git is not installed or not in PATH"
|
||||||
|
exit 1
|
||||||
|
elif ! git rev-parse --git-dir &> /dev/null; then
|
||||||
|
echo "[ERROR] Not in a git repository"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
# 获取最新的git标签
|
||||||
|
LATEST_TAG=$(git describe --abbrev=0 --tags 2>/dev/null)
|
||||||
|
|
||||||
|
if [ -z "$LATEST_TAG" ]; then
|
||||||
|
echo "[ERROR] No git tags found in repository"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "[INFO] Latest git tag: $LATEST_TAG"
|
||||||
|
|
||||||
|
# 移除v前缀
|
||||||
|
CLEAN_VERSION=${LATEST_TAG#v}
|
||||||
|
|
||||||
|
# 分割版本号并递增patch版本
|
||||||
|
IFS='.' read -r MAJOR MINOR PATCH <<< "$CLEAN_VERSION"
|
||||||
|
PATCH=$((PATCH + 1))
|
||||||
|
|
||||||
|
VERSION="$MAJOR.$MINOR.$PATCH"
|
||||||
|
echo "[INFO] Auto-incremented patch version: $VERSION"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 输出版本信息
|
||||||
|
echo "VERSION=$VERSION"
|
||||||
|
|
||||||
|
# 保存到文件供其他脚本使用
|
||||||
|
echo "VERSION=$VERSION" > "$VERSION_FILE"
|
||||||
|
|
||||||
|
echo "[INFO] Version information saved to $VERSION_FILE"
|
||||||
1
version.txt
Normal file
1
version.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
VERSION=1.3.5
|
||||||
Reference in New Issue
Block a user