Skip to content

Commit 12f31a4

Browse files
committed
feat: 重命名项目为 PromptKey 并优化代码结构
- 将项目名称从 "prompt-manager" 改为 "PromptKey" - 更新了相关的文件名和代码中的引用 - 优化了项目结构,明确了 GUI 和服务的分离 - 更新了 README 文档,增加了构建和开发说明 - 调整了样式文件,移除了未使用的旧样式
1 parent 4410169 commit 12f31a4

15 files changed

Lines changed: 123 additions & 935 deletions

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ panic = "abort"
1414
strip = "symbols"
1515

1616
[package]
17-
name = "prompt-manager"
17+
name = "promptkey"
1818
version = "0.1.0"
1919
edition = "2021"
20-
default-run = "prompt-manager"
20+
default-run = "promptkey"
2121

2222
[[bin]]
23-
name = "prompt-manager"
23+
name = "promptkey"
2424
path = "src/main.rs"
2525

2626
[[bin]]

PM.ico

-4.19 KB
Binary file not shown.

PromptKey.ico

31.3 KB
Binary file not shown.

README.md

Lines changed: 94 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Prompt Manager
1+
# PromptKey
22

3-
Prompt Manager 是一个面向 AI 重度用户的系统级提示词管理器,支持全局快捷键、按应用上下文感知和专业模板管理,让用户在任何软件中一键调用高质量 Prompt。
3+
PromptKey 是一个面向 AI 重度用户的系统级提示词管理器,支持全局快捷键、按应用上下文感知和专业模板管理,让用户在任何软件中一键调用高质量 Prompt。
44

55
## 功能特点
66

@@ -10,24 +10,49 @@ Prompt Manager 是一个面向 AI 重度用户的系统级提示词管理器,
1010
- 按应用上下文路由
1111
- 本地 SQLite 存储
1212

13-
## 安装与运行
13+
## 安装与构建
14+
15+
### 构建步骤
1416

1517
```bash
1618
# 克隆项目
1719
git clone <repository-url>
18-
cd PromptManager
20+
cd PromptKey
1921

20-
# 构建项目
21-
cargo build
22+
# 清理之前的构建缓存(可选)
23+
cargo clean
24+
25+
# 构建 GUI 应用
26+
cargo build --release --bin promptkey
27+
28+
# 构建后台服务
29+
cargo build --release -p service
30+
31+
# 验证构建结果
32+
ls target/release/
33+
# 应该看到: promptkey.exe, service.exe, launcher.exe
2234
```
2335

36+
### 项目架构
37+
38+
PromptKey 采用双进程架构:
39+
- `promptkey.exe`: 主 GUI 应用,负责用户界面和系统托盘
40+
- `service.exe`: 后台服务,负责全局热键监听和文本注入
41+
- `launcher.exe`: 启动器,同时启动 GUI 和服务进程
42+
2443
## 使用方法
2544

2645
### 启动应用
2746

2847
```bash
29-
# 启动系统托盘应用
30-
cargo run
48+
# 方式1: 直接运行 GUI(推荐)
49+
./target/release/promptkey.exe
50+
51+
# 方式2: 使用启动脚本
52+
./start-prompt-manager.ps1
53+
54+
# 方式3: 开发模式
55+
cargo run --bin promptkey
3156
```
3257

3358
应用启动后会在系统托盘中显示图标,可以通过以下方式控制:
@@ -45,31 +70,86 @@ cargo run
4570

4671
## 配置
4772

48-
配置文件位于: `%APPDATA%/PromptManager/config.yaml`
73+
配置文件位于: `%APPDATA%/PromptKey/config.yaml`
4974

5075
默认配置:
5176
```yaml
5277
hotkey: "Ctrl+Alt+Space"
53-
database_path: "C:\\Users\\<you>\\AppData\\Roaming\\PromptManager\\promptmgr.db"
78+
database_path: "C:\\Users\\<you>\\AppData\\Roaming\\PromptKey\\promptkey.db"
5479
injection:
5580
order: ["uia", "clipboard", "sendinput"]
5681
allow_clipboard: true
82+
uia_value_pattern_mode: "overwrite"
5783
```
5884
85+
### 配置说明
86+
87+
- `hotkey`: 全局热键组合,支持 Ctrl、Alt、Shift 修饰键
88+
- `database_path`: SQLite 数据库文件路径
89+
- `injection.order`: 文本注入策略优先级
90+
- `injection.allow_clipboard`: 是否允许使用剪贴板注入
91+
- `injection.uia_value_pattern_mode`: UIA 注入模式(overwrite/append)
92+
5993
## 开发
6094

61-
本项目使用 Rust 编写,主要依赖:
95+
本项目使用 Rust 编写,基于 Tauri v2 框架,主要依赖:
96+
- tauri: 跨平台桌面应用框架
6297
- windows: Windows API 绑定
6398
- tokio: 异步运行时
6499
- rusqlite: SQLite 数据库
65100
- serde: 序列化/反序列化
66101

67-
运行开发版本:
102+
### 开发环境运行
103+
68104
```bash
69-
cargo run
105+
# 运行 GUI 应用(开发模式)
106+
cargo run --bin promptkey
107+
108+
# 单独运行后台服务(调试)
109+
cargo run -p service
110+
111+
# 运行启动器
112+
cargo run --bin launcher
70113
```
71114

72-
构建发布版本:
115+
### 构建说明
116+
73117
```bash
118+
# 构建开发版本
119+
cargo build
120+
121+
# 构建发布版本(推荐)
74122
cargo build --release
123+
124+
# 仅构建 GUI
125+
cargo build --release --bin promptkey
126+
127+
# 仅构建服务
128+
cargo build --release -p service
129+
130+
# 清理构建缓存
131+
cargo clean
132+
```
133+
134+
### 项目结构
135+
136+
```
137+
PromptKey/
138+
├── src/ # GUI 应用源码
139+
│ ├── main.rs # 主 GUI 应用
140+
│ ├── launcher.rs # 启动器
141+
│ ├── index.html # 前端界面
142+
│ ├── styles.css # 界面样式
143+
│ └── main_simple.js # 前端逻辑
144+
├── service/ # 后台服务源码
145+
│ └── src/
146+
│ ├── main.rs # 服务主程序
147+
│ ├── config/ # 配置管理
148+
│ ├── hotkey/ # 热键处理
149+
│ ├── injector/ # 文本注入
150+
│ └── context/ # 应用上下文
151+
├── target/ # 构建输出
152+
│ ├── debug/ # 开发版本
153+
│ └── release/ # 发布版本
154+
└── start-prompt-manager.* # 启动脚本
75155
```

service/src/config/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ impl Config {
165165
pub fn get_config_path() -> Result<String, Box<dyn std::error::Error>> {
166166
// 获取APPDATA路径
167167
let appdata = std::env::var("APPDATA")?;
168-
let config_dir = format!("{}\\PromptManager", appdata);
168+
let config_dir = format!("{}\\PromptKey", appdata);
169169

170170
// 创建配置目录(如果不存在)
171171
fs::create_dir_all(&config_dir)?;
@@ -263,7 +263,7 @@ impl Default for Config {
263263
fn default() -> Self {
264264
// 获取默认数据库路径
265265
let database_path = if let Ok(appdata) = std::env::var("APPDATA") {
266-
format!("{}\\PromptManager\\promptmgr.db", appdata)
266+
format!("{}\\PromptKey\\promptmgr.db", appdata)
267267
} else {
268268
"promptmgr.db".to_string() // fallback
269269
};

service/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ fn main() {
1313
// 初始化日志记录器
1414
env_logger::init();
1515

16-
log::info!("🎯 DEBUG VERSION: Prompt Manager service starting with DEBUG CODE...");
16+
log::info!("🎯 DEBUG VERSION: PromptKey service starting with DEBUG CODE...");
1717

1818
// 加载配置
1919
let config = match config::Config::load() {
@@ -118,7 +118,7 @@ fn main() {
118118
// 停止热键服务
119119
hotkey_service.stop();
120120

121-
log::info!("Prompt Manager service stopped");
121+
log::info!("PromptKey service stopped");
122122
}
123123

124124
fn run_main_loop(

src/index.html

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,11 @@
33
<head>
44
<meta charset="UTF-8">
55
<meta name="viewport" id="viewport" content="width=device-width, initial-scale=1.0">
6-
<title>Prompt Manager</title>
6+
<title>PromptKey</title>
77
<link rel="stylesheet" href="styles.css">
88
</head>
99
<body class="theme-light">
1010
<div class="app-container">
11-
<!-- 顶部状态栏 -->
12-
<header class="app-header">
13-
<div class="header-left">
14-
<h1>Prompt Manager</h1>
15-
</div>
16-
<div class="header-right">
17-
<div class="app-status">
18-
<span class="status-label">状态:</span>
19-
<span class="status-active">运行中</span>
20-
</div>
21-
</div>
22-
</header>
23-
2411
<!-- 主要内容区域 -->
2512
<main class="main-content">
2613
<!-- 侧边栏导航 -->

src/launcher.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::thread;
33
use std::time::Duration;
44

55
fn main() {
6-
println!("正在启动 Prompt Manager...");
6+
println!("正在启动 PromptKey...");
77

88
// 启动服务进程
99
let service_handle = thread::spawn(|| {
@@ -34,7 +34,7 @@ fn main() {
3434
}
3535
});
3636

37-
println!("Prompt Manager 已启动,后台服务和GUI界面正在运行中...");
37+
println!("PromptKey 已启动,后台服务和GUI界面正在运行中...");
3838
println!("提示:请在文本编辑器中按下 Ctrl+Alt+Space 测试功能");
3939

4040
// 等待线程完成

src/main.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,13 @@ fn resolve_service_exe_path() -> Result<String, String> {
121121
let exe_dir = current_exe.parent()
122122
.ok_or_else(|| "无法获取当前可执行文件目录".to_string())?;
123123

124-
// 典型 dev: target/debug/prompt-manager.exe => 同目录下 service.exe
124+
// 典型 dev: target/debug/promptkey.exe => 同目录下 service.exe
125125
let candidate_debug = exe_dir.join(if cfg!(windows) { "service.exe" } else { "service" });
126126
if candidate_debug.exists() {
127127
return Ok(candidate_debug.to_string_lossy().into_owned());
128128
}
129129

130-
// 典型 release: target/release/prompt-manager.exe => 同目录下 service(.exe)
130+
// 典型 release: target/release/promptkey.exe => 同目录下 service(.exe)
131131
// 若当前不是 release 目录,尝试 sibling "release"
132132
if let Some(target_dir) = exe_dir.parent() {
133133
let candidate_release_dir = target_dir.join("release");
@@ -378,7 +378,7 @@ fn delete_prompt(id: i32) -> Result<(), String> {
378378
// 打开数据库并确保目录/表存在,设置 busy_timeout 与 WAL
379379
fn open_db() -> Result<rusqlite::Connection, String> {
380380
let database_path = if let Ok(appdata) = std::env::var("APPDATA") {
381-
format!("{}\\PromptManager\\promptmgr.db", appdata)
381+
format!("{}\\PromptKey\\promptmgr.db", appdata)
382382
} else {
383383
return Err("无法获取APPDATA路径".to_string());
384384
};
@@ -492,7 +492,7 @@ fn create_and_show_window(app: &AppHandle) {
492492

493493
// 创建新窗口
494494
let window = WebviewWindowBuilder::new(app, "main", WebviewUrl::App("index.html".into()))
495-
.title("Prompt Manager")
495+
.title("PromptKey")
496496
.inner_size(1000.0, 700.0)
497497
.min_inner_size(800.0, 600.0)
498498
.build()
@@ -543,7 +543,7 @@ fn default_uia_value_pattern_mode() -> String { "overwrite".into() }
543543

544544
fn config_path() -> Result<std::path::PathBuf, String> {
545545
let appdata = std::env::var("APPDATA").map_err(|e| format!("读取APPDATA失败: {}", e))?;
546-
let dir = std::path::Path::new(&appdata).join("PromptManager");
546+
let dir = std::path::Path::new(&appdata).join("PromptKey");
547547
std::fs::create_dir_all(&dir).map_err(|e| format!("创建配置目录失败: {}", e))?;
548548
Ok(dir.join("config.yaml"))
549549
}
@@ -557,7 +557,7 @@ fn load_or_default_config() -> Result<AppConfig, String> {
557557
} else {
558558
// database_path 默认与服务一致
559559
let database_path = if let Ok(appdata) = std::env::var("APPDATA") {
560-
format!("{}\\PromptManager\\promptmgr.db", appdata)
560+
format!("{}\\PromptKey\\promptmgr.db", appdata)
561561
} else {
562562
"promptmgr.db".to_string()
563563
};

0 commit comments

Comments
 (0)