- 修复配置窗口'选择本地模型'按钮无响应问题 - 添加 tauri-plugin-dialog 和 tauri-plugin-clipboard-manager 依赖 - 在 main.rs 中注册插件 - 创建 capabilities/default.json 配置权限 - 修复工具栏按钮不显示问题 - 将 .waifu-tool 的 display 从 none 改为 block - 修复模型显示比例问题 - 禁用 reloadPositionScale 避免覆盖尺寸设置 - 移除 onResized 回调中的模型尺寸重置 - 设置模型宽度为窗口的 50% - 修复切换 workspace 后模型尺寸恢复问题 - 添加窗口置顶设置,显示时重新设置 always_on_top - 更新 CLAUDE.md 文档 - 添加 .gitignore - 更新 README.md - 添加 docs/impl/debug-log-20260531.md 记录调试过程 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
141 lines
3.2 KiB
Markdown
141 lines
3.2 KiB
Markdown
# EzVibeR+ 调试修复日志 - 2026-05-31
|
||
|
||
## 问题1:配置窗口"选择本地模型"按钮无响应
|
||
|
||
### 原因
|
||
`@tauri-apps/plugin-dialog` 只在 `package.json` 前端依赖中声明,但没有在 Rust 后端注册。
|
||
|
||
Tauri v2 要求插件必须:
|
||
1. 在 `Cargo.toml` 中添加依赖
|
||
2. 在 `main.rs` 中用 `.plugin()` 注册
|
||
|
||
### 修复内容
|
||
|
||
**1. Cargo.toml** - 添加插件依赖:
|
||
```toml
|
||
tauri = { version = "2.11.1", features = ["tray-icon", "image-png"] }
|
||
tauri-plugin-dialog = "2"
|
||
tauri-plugin-clipboard-manager = "2"
|
||
```
|
||
|
||
**2. src-tauri/src/main.rs** - 注册插件:
|
||
```rust
|
||
.plugin(tauri_plugin_dialog::init())
|
||
.plugin(tauri_plugin_clipboard_manager::init())
|
||
```
|
||
|
||
**3. 创建 capabilities 配置** - `src-tauri/capabilities/default.json`:
|
||
```json
|
||
{
|
||
"identifier": "default",
|
||
"windows": ["main", "config"],
|
||
"permissions": [
|
||
"core:default",
|
||
"dialog:allow-open",
|
||
"clipboard-manager:allow-write-text",
|
||
"clipboard-manager:allow-read-text"
|
||
]
|
||
}
|
||
```
|
||
|
||
---
|
||
|
||
## 问题2:工具栏按钮不显示/无法点击
|
||
|
||
### 原因
|
||
CSS 中 `.waifu-tool` 默认 `display: none`,只在 hover 时显示。但透明窗口可能无法正确触发 hover。
|
||
|
||
### 修复内容
|
||
|
||
**src/assets/waifu.css** - 修改为始终显示:
|
||
```css
|
||
.waifu-tool {
|
||
display: block; /* 原为 none */
|
||
...
|
||
}
|
||
```
|
||
|
||
---
|
||
|
||
## 问题3:模型在窗口中显示比例不对,太宽
|
||
|
||
### 原因
|
||
`loadModel` 函数中设置了模型尺寸,但随后被 `reloadPositionScale()` 和 `onResized` 回调覆盖。
|
||
|
||
### 修复内容
|
||
|
||
**1. src/live2d/index.vue - init()** - 禁用 reloadPositionScale:
|
||
```javascript
|
||
// await reloadPositionScale(); // 暂时禁用
|
||
```
|
||
|
||
**2. src/live2d/index.vue - onResized 回调** - 不再重置模型尺寸:
|
||
```javascript
|
||
// 删除了 modelRef.value!.width = ... 的覆盖逻辑
|
||
```
|
||
|
||
**3. src/live2d/index.vue - loadModel()** - 设置模型尺寸:
|
||
```javascript
|
||
const w = size?.width! / factor;
|
||
const h = size?.height! / factor;
|
||
model.width = w * 0.5; // 宽度50%
|
||
model.height = h;
|
||
```
|
||
|
||
---
|
||
|
||
## 问题4:切换 workspace 后模型尺寸恢复
|
||
|
||
### 原因
|
||
`onResized` 回调每次窗口尺寸变化都会重置模型宽高为窗口大小。
|
||
|
||
### 修复内容
|
||
|
||
**src/live2d/index.vue - onResized** - 移除模型尺寸重置:
|
||
```javascript
|
||
// 不再重置模型尺寸,避免切换workspace时变形
|
||
// 仅保存窗口尺寸到配置
|
||
```
|
||
|
||
---
|
||
|
||
## 问题5:窗口置顶在切换 workspace 后失效
|
||
|
||
### 原因
|
||
窗口重新显示时没有重新设置 `always_on_top`。
|
||
|
||
### 修复内容
|
||
|
||
**src-tauri/src/main.rs** - 显示窗口时重新设置置顶:
|
||
```rust
|
||
"show" => {
|
||
if let Some(w) = app.get_webview_window("main") {
|
||
w.show().unwrap();
|
||
w.set_always_on_top(true).unwrap(); // 新增
|
||
}
|
||
}
|
||
```
|
||
|
||
---
|
||
|
||
## 配置文件变更
|
||
|
||
### tauri.conf.json
|
||
- 窗口配置保持 `alwaysOnTop: true`
|
||
- 窗口尺寸 215x200
|
||
|
||
### CLAUDE.md
|
||
- 更新项目架构文档
|
||
- 添加前端文件说明
|
||
- 补充后端模块细节
|
||
- 添加事件系统说明
|
||
|
||
---
|
||
|
||
## 备注
|
||
|
||
- 编译命令:`npm run build` (前端) + `cargo build --release` (后端)
|
||
- 前端构建产物在 `dist/`
|
||
- 后端编译产物在 `src-tauri/target/release/live2d`
|
||
- 配置文件位置:`~/.live2D/live2d.conf.json`
|
||
- Web 服务器端口随机分配,存储在配置文件中 |