🐛 Fixed data migration issues
This commit is contained in:
@@ -14,14 +14,6 @@ import {Call as $Call, Create as $Create} from "@wailsio/runtime";
|
||||
// @ts-ignore: Unused imports
|
||||
import * as application$0 from "../../../github.com/wailsapp/wails/v3/pkg/application/models.js";
|
||||
|
||||
/**
|
||||
* OnDataPathChanged handles data path changes
|
||||
*/
|
||||
export function OnDataPathChanged(): Promise<void> & { cancel(): void } {
|
||||
let $resultPromise = $Call.ByID(3652863491) as any;
|
||||
return $resultPromise;
|
||||
}
|
||||
|
||||
/**
|
||||
* RegisterModel 注册模型与表的映射关系
|
||||
*/
|
||||
|
||||
2529
frontend/package-lock.json
generated
2529
frontend/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -64,14 +64,16 @@
|
||||
"colors-named-hex": "^1.0.2",
|
||||
"groovy-beautify": "^0.0.17",
|
||||
"hsl-matcher": "^1.2.4",
|
||||
"i": "^0.3.7",
|
||||
"java-parser": "^3.0.1",
|
||||
"jsox": "^1.2.123",
|
||||
"linguist-languages": "^9.1.0",
|
||||
"markdown-exit": "^1.0.0-beta.6",
|
||||
"npm": "^11.6.2",
|
||||
"php-parser": "^3.2.5",
|
||||
"pinia": "^3.0.4",
|
||||
"pinia-plugin-persistedstate": "^4.7.1",
|
||||
"prettier": "^3.6.2",
|
||||
"remarkable": "^2.0.1",
|
||||
"sass": "^1.94.0",
|
||||
"vue": "^3.5.24",
|
||||
"vue-i18n": "^11.1.12",
|
||||
@@ -82,7 +84,6 @@
|
||||
"@eslint/js": "^9.39.1",
|
||||
"@lezer/generator": "^1.8.0",
|
||||
"@types/node": "^24.9.2",
|
||||
"@types/remarkable": "^2.0.8",
|
||||
"@vitejs/plugin-vue": "^6.0.1",
|
||||
"@wailsio/runtime": "latest",
|
||||
"cross-env": "^10.1.0",
|
||||
@@ -99,4 +100,4 @@
|
||||
"vue-eslint-parser": "^10.2.0",
|
||||
"vue-tsc": "^3.1.3"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,6 +133,12 @@ export {
|
||||
type CreateBlockOptions,
|
||||
} from './types';
|
||||
|
||||
// 导出解析器函数
|
||||
export {
|
||||
getActiveBlock,
|
||||
getBlockFromPos
|
||||
} from './parser';
|
||||
|
||||
// 状态管理
|
||||
export {
|
||||
blockState,
|
||||
|
||||
@@ -6,18 +6,19 @@ import { useUpdateStore } from '@/stores/updateStore';
|
||||
import SettingSection from '../components/SettingSection.vue';
|
||||
import SettingItem from '../components/SettingItem.vue';
|
||||
import ToggleSwitch from '../components/ToggleSwitch.vue';
|
||||
import { Remarkable } from 'remarkable';
|
||||
import { createMarkdownExit } from 'markdown-exit'
|
||||
|
||||
const { t } = useI18n();
|
||||
const configStore = useConfigStore();
|
||||
const updateStore = useUpdateStore();
|
||||
|
||||
// 初始化Remarkable实例并配置
|
||||
const md = new Remarkable({
|
||||
const md = createMarkdownExit({
|
||||
html: true, // 允许HTML
|
||||
xhtmlOut: false, // 不使用'/'闭合单标签
|
||||
breaks: true, // 将'\n'转换为<br>
|
||||
typographer: true // 启用排版增强
|
||||
linkify: false, // 不解析链接
|
||||
typographer: true, // 开启智能引号
|
||||
xhtmlOut: true, // 使用xhtml语法输出
|
||||
breaks: true, // 允许换行
|
||||
});
|
||||
|
||||
// 计算属性
|
||||
|
||||
@@ -117,11 +117,24 @@ func (ms *MigrationService) MigrateDirectory(srcPath, dstPath string) error {
|
||||
ms.logger.Error("Failed to close database connection", "error", err)
|
||||
}
|
||||
}
|
||||
|
||||
// 执行原子迁移
|
||||
if err := ms.atomicMove(ctx, srcPath, dstPath); err != nil {
|
||||
return ms.failWithError(err)
|
||||
}
|
||||
|
||||
// 迁移完成后重新连接数据库
|
||||
ms.updateProgress(MigrationProgress{
|
||||
Status: MigrationStatusMigrating,
|
||||
Progress: 95,
|
||||
})
|
||||
|
||||
if ms.dbService != nil {
|
||||
if err := ms.dbService.initDatabase(); err != nil {
|
||||
return ms.failWithError(fmt.Errorf("failed to reconnect database: %v", err))
|
||||
}
|
||||
}
|
||||
|
||||
// 迁移完成
|
||||
ms.updateProgress(MigrationProgress{
|
||||
Status: MigrationStatusCompleted,
|
||||
@@ -132,29 +132,9 @@ func (ds *DatabaseService) registerAllModels() {
|
||||
// ServiceStartup initializes the service when the application starts
|
||||
func (ds *DatabaseService) ServiceStartup(ctx context.Context, options application.ServiceOptions) error {
|
||||
ds.ctx = ctx
|
||||
|
||||
ds.cancelObserver = ds.configService.Watch("general.dataPath", ds.onDataPathChange)
|
||||
|
||||
return ds.initDatabase()
|
||||
}
|
||||
|
||||
// onDataPathChange 数据路径配置变更回调
|
||||
func (ds *DatabaseService) onDataPathChange(oldValue, newValue interface{}) {
|
||||
oldPath := ""
|
||||
newPath := ""
|
||||
|
||||
if oldValue != nil {
|
||||
oldPath = fmt.Sprintf("%v", oldValue)
|
||||
}
|
||||
if newValue != nil {
|
||||
newPath = fmt.Sprintf("%v", newValue)
|
||||
}
|
||||
|
||||
if oldPath != newPath {
|
||||
_ = ds.OnDataPathChanged()
|
||||
}
|
||||
}
|
||||
|
||||
// initDatabase initializes the SQLite database
|
||||
func (ds *DatabaseService) initDatabase() error {
|
||||
dbPath, err := ds.getDatabasePath()
|
||||
@@ -399,16 +379,3 @@ func (ds *DatabaseService) ServiceShutdown() error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// OnDataPathChanged handles data path changes
|
||||
func (ds *DatabaseService) OnDataPathChanged() error {
|
||||
// 关闭当前连接
|
||||
if ds.db != nil {
|
||||
if err := ds.db.Close(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// 用新路径重新初始化
|
||||
return ds.initDatabase()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user