docs: add PR description in Chinese and English
This commit is contained in:
1 parent
99273ccd2c
commit
c9eeb009a0
2 files changed
+88
No files matched your search
@@ -0,0 +1,44 @@
|
||||
# fix(export): "Date Range" file naming mode not working in export global config
|
||||
|
||||
## Problem
|
||||
|
||||
In the **Export page → Global Settings → Export File Naming Mode**, selecting "Date Range Mode" (`date-range`) has no effect. The exported files always use the "Classic Mode" (`classic`) naming format without any date range information. The option is completely ignored.
|
||||
|
||||
## Root Cause
|
||||
|
||||
The `fileNamingMode` config value is lost at 4 breakpoints along the data flow from saving (`ExportDefaultsSettingsForm` → `configService.setExportDefaultFileNamingMode()`) to actual usage (Electron side `ExportOrchestrator` → `normalizeFileNamingMode()`):
|
||||
|
||||
### 1. `types.ts` — `ExportOptions` interface missing `fileNamingMode` field
|
||||
|
||||
The frontend type definition lacks this property, so TypeScript cannot track its existence. The data is already lost at the very first step of data flow.
|
||||
|
||||
### 2. `constants.ts` — `createDefaultExportOptions()` missing default value
|
||||
|
||||
No default value is set when creating export options, leaving `fileNamingMode` as `undefined`.
|
||||
|
||||
### 3. `useExportConfig.ts` — Not loaded on init, not persisted in `updateOptions`
|
||||
|
||||
- Initial load does not call `getExportDefaultFileNamingMode()`
|
||||
- Changes via `updateOptions` are not persisted to storage via `setExportDefaultFileNamingMode()`
|
||||
|
||||
### 4. `ExportPage.tsx` — `handleExportDefaultsChanged` drops the `fileNamingMode` patch
|
||||
|
||||
The callback fired when closing the global settings modal only passes `format` and `avatars` to `updateOptions`, completely ignoring `fileNamingMode`.
|
||||
|
||||
## Fix
|
||||
|
||||
Bridged each gap in the data flow so the config value flows end-to-end: save → load → propagate → use.
|
||||
|
||||
## Changes
|
||||
|
||||
| File | Change Type | Description |
|
||||
|------|-------------|-------------|
|
||||
| `src/pages/Export/types.ts` | New field | Added `fileNamingMode: 'classic' \| 'date-range'` to `ExportOptions` interface |
|
||||
| `src/pages/Export/constants.ts` | New default | Added `fileNamingMode: 'classic'` default in `createDefaultExportOptions()` |
|
||||
| `src/pages/Export/hooks/useExportConfig.ts` | Load + persist | Added `getExportDefaultFileNamingMode()` to initial `Promise.all`; assign loaded value to `newOptions.fileNamingMode`; added `setExportDefaultFileNamingMode()` persistence in `updateOptions` |
|
||||
| `src/pages/Export/ExportPage.tsx` | Propagate + fix key | Propagate `fileNamingMode` in `handleExportDefaultsChanged`; fixed incorrect key name `defaultFormat` → `format` |
|
||||
|
||||
## Verification
|
||||
|
||||
- Tested on Windows desktop client: selecting "Date Range Mode" produces correct filenames with date range tokens (e.g. `Private_ZhangSan_20250101-20250331.json`)
|
||||
- TypeScript type check passes, build succeeds with no errors
|
||||
@@ -0,0 +1,44 @@
|
||||
# 修复:导出文件命名方式中"时间范围模式"选项不生效
|
||||
|
||||
## 问题描述
|
||||
|
||||
在导出页面的**全局配置 → 导出文件命名方式**中,选择"时间范围模式"(date-range)后,实际导出的文件名仍然使用"简洁模式"(classic),不包含时间范围信息。该选项完全不生效。
|
||||
|
||||
## 根因分析
|
||||
|
||||
`fileNamingMode` 配置在保存(`ExportDefaultsSettingsForm` → `configService.setExportDefaultFileNamingMode()`)到实际使用(Electron 端 `ExportOrchestrator` → `normalizeFileNamingMode()`)之间的数据流中存在 4 处断裂:
|
||||
|
||||
### 1. `types.ts` — `ExportOptions` 接口缺少 `fileNamingMode` 字段
|
||||
|
||||
前端类型定义中没有该属性,导致 TypeScript 类型系统无法感知这个选项的存在,数据传递的第一步就已丢失。
|
||||
|
||||
### 2. `constants.ts` — `createDefaultExportOptions()` 缺少默认值
|
||||
|
||||
创建默认选项时未设置 `fileNamingMode`,值始终为 `undefined`。
|
||||
|
||||
### 3. `useExportConfig.ts` — 初始加载未读取、`updateOptions` 未持久化
|
||||
|
||||
- 从 config 初始化时未调用 `getExportDefaultFileNamingMode()`
|
||||
- 在 `updateOptions` 中修改时未调用 `setExportDefaultFileNamingMode()` 持久化到存储
|
||||
|
||||
### 4. `ExportPage.tsx` — `handleExportDefaultsChanged` 丢弃了 `fileNamingMode` patch
|
||||
|
||||
全局配置弹窗关闭时触发的回调中,只传递了 `format` 和 `avatars` 给 `updateOptions`,`fileNamingMode` 被完全忽略。
|
||||
|
||||
## 修复方案
|
||||
|
||||
逐层打通数据流,使配置从保存 → 加载 → 传递 → 使用形成完整闭环。
|
||||
|
||||
## 变更列表
|
||||
|
||||
| 文件 | 改动类型 | 说明 |
|
||||
|------|---------|------|
|
||||
| `src/pages/Export/types.ts` | 新增字段 | 在 `ExportOptions` 接口中新增 `fileNamingMode: 'classic' \| 'date-range'` |
|
||||
| `src/pages/Export/constants.ts` | 新增默认值 | 在 `createDefaultExportOptions()` 中新增 `fileNamingMode: 'classic'` 默认值 |
|
||||
| `src/pages/Export/hooks/useExportConfig.ts` | 新增加载+持久化 | `Promise.all` 中添加 `getExportDefaultFileNamingMode()`;加载后赋值给 `newOptions.fileNamingMode`;`updateOptions` 中添加 `setExportDefaultFileNamingMode()` 持久化 |
|
||||
| `src/pages/Export/ExportPage.tsx` | 补充传递 + 修复 key | `handleExportDefaultsChanged` 中添加 `fileNamingMode` 传递;同时修复了 `format` key 名错误(`defaultFormat` → `format`) |
|
||||
|
||||
## 验证
|
||||
|
||||
- 在 Windows 桌面客户端上测试通过:选择"时间范围模式"后导出,文件名正确包含日期范围(示例:`私聊_张三_20250101-20250331.json`)
|
||||
- TypeScript 类型检查通过,编译无错误
|
||||
Reference in new issue
Block a user