🐛 Fixed some issues

This commit is contained in:
2025-07-02 12:10:46 +08:00
parent 25e1a98932
commit 81eb2c94ac
14 changed files with 210 additions and 149 deletions

View File

@@ -159,7 +159,7 @@ export class ConfigMetadata {
}
/**
* Document 表示一个文档(使用自增主键)
* Document represents a document in the system
*/
export class Document {
"id": number;
@@ -167,6 +167,7 @@ export class Document {
"content": string;
"createdAt": time$0.Time;
"updatedAt": time$0.Time;
"is_deleted": boolean;
/** Creates a new Document instance. */
constructor($$source: Partial<Document> = {}) {
@@ -185,6 +186,9 @@ export class Document {
if (!("updatedAt" in $$source)) {
this["updatedAt"] = null;
}
if (!("is_deleted" in $$source)) {
this["is_deleted"] = false;
}
Object.assign(this, $$source);
}

View File

@@ -27,7 +27,7 @@ export function CreateDocument(title: string): Promise<models$0.Document | null>
}
/**
* DeleteDocument deletes a document (not allowed if it's the only document)
* DeleteDocument marks a document as deleted (default document with ID=1 cannot be deleted)
*/
export function DeleteDocument(id: number): Promise<void> & { cancel(): void } {
let $resultPromise = $Call.ByID(412287269, id) as any;
@@ -47,7 +47,7 @@ export function GetDocumentByID(id: number): Promise<models$0.Document | null> &
}
/**
* GetFirstDocumentID gets the first document's ID for frontend initialization
* GetFirstDocumentID gets the first active document's ID for frontend initialization
*/
export function GetFirstDocumentID(): Promise<number> & { cancel(): void } {
let $resultPromise = $Call.ByID(2970773833) as any;
@@ -55,7 +55,7 @@ export function GetFirstDocumentID(): Promise<number> & { cancel(): void } {
}
/**
* ListAllDocumentsMeta lists all document metadata
* ListAllDocumentsMeta lists all active (non-deleted) document metadata
*/
export function ListAllDocumentsMeta(): Promise<(models$0.Document | null)[]> & { cancel(): void } {
let $resultPromise = $Call.ByID(3073950297) as any;
@@ -66,6 +66,18 @@ export function ListAllDocumentsMeta(): Promise<(models$0.Document | null)[]> &
return $typingPromise;
}
/**
* ListDeletedDocumentsMeta lists all deleted document metadata
*/
export function ListDeletedDocumentsMeta(): Promise<(models$0.Document | null)[]> & { cancel(): void } {
let $resultPromise = $Call.ByID(490143787) as any;
let $typingPromise = $resultPromise.then(($result: any) => {
return $$createType2($result);
}) as any;
$typingPromise.cancel = $resultPromise.cancel.bind($resultPromise);
return $typingPromise;
}
/**
* OnDataPathChanged handles data path changes
*/
@@ -74,6 +86,14 @@ export function OnDataPathChanged(): Promise<void> & { cancel(): void } {
return $resultPromise;
}
/**
* RestoreDocument restores a deleted document
*/
export function RestoreDocument(id: number): Promise<void> & { cancel(): void } {
let $resultPromise = $Call.ByID(784200778, id) as any;
return $resultPromise;
}
/**
* UpdateDocumentContent updates the content of a document
*/

View File

@@ -47,9 +47,9 @@
"hsl-matcher": "^1.2.4",
"lezer": "^0.13.5",
"pinia": "^3.0.3",
"pinia-plugin-persistedstate": "^4.4.1",
"prettier": "^3.5.3",
"sass": "^1.89.2",
"uuid": "^11.1.0",
"vue": "^3.5.17",
"vue-i18n": "^11.1.6",
"vue-router": "^4.5.1"
@@ -1457,7 +1457,6 @@
"version": "3.17.4",
"resolved": "https://registry.npmmirror.com/@nuxt/kit/-/kit-3.17.4.tgz",
"integrity": "sha512-l+hY8sy2XFfg3PigZj+PTu6+KIJzmbACTRimn1ew/gtCz+F38f6KTF4sMRTN5CUxiB8TRENgEonASmkAWfpO9Q==",
"dev": true,
"license": "MIT",
"optional": true,
"peer": true,
@@ -1493,7 +1492,6 @@
"version": "7.0.4",
"resolved": "https://registry.npmmirror.com/ignore/-/ignore-7.0.4.tgz",
"integrity": "sha512-gJzzk+PQNznz8ysRrC0aOkBNVRBDtE1n53IqyqEf3PXrYwomFs5q4pGMizBMJF+ykh03insJ27hB8gSrD2Hn8A==",
"dev": true,
"license": "MIT",
"optional": true,
"peer": true,
@@ -2081,7 +2079,7 @@
"version": "1.0.7",
"resolved": "https://registry.npmmirror.com/@types/estree/-/estree-1.0.7.tgz",
"integrity": "sha512-w28IoSUCJpidD/TGviZwwMJckNESJZXFu7NBZ5YJ4mEUnNraUn9Pm8HSZm/jDF1pDWYKspWE7oVphigUPRakIQ==",
"dev": true,
"devOptional": true,
"license": "MIT"
},
"node_modules/@types/json-schema": {
@@ -2607,7 +2605,7 @@
"version": "8.15.0",
"resolved": "https://registry.npmmirror.com/acorn/-/acorn-8.15.0.tgz",
"integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==",
"dev": true,
"devOptional": true,
"license": "MIT",
"bin": {
"acorn": "bin/acorn"
@@ -2751,7 +2749,6 @@
"version": "3.0.4",
"resolved": "https://registry.npmmirror.com/c12/-/c12-3.0.4.tgz",
"integrity": "sha512-t5FaZTYbbCtvxuZq9xxIruYydrAGsJ+8UdP0pZzMiK2xl/gNiSOy0OxhLzHUEEb0m1QXYqfzfvyIFEmz/g9lqg==",
"dev": true,
"license": "MIT",
"optional": true,
"peer": true,
@@ -2824,7 +2821,6 @@
"version": "0.1.6",
"resolved": "https://registry.npmmirror.com/citty/-/citty-0.1.6.tgz",
"integrity": "sha512-tskPPKEs8D2KPafUypv2gxwJP8h/OaJmC82QQGGDQcHvXX43xF2VDACcJVmZ0EuSxkpO9Kc4MlrA3q0+FG58AQ==",
"dev": true,
"license": "MIT",
"optional": true,
"peer": true,
@@ -2911,14 +2907,13 @@
"version": "0.2.2",
"resolved": "https://registry.npmmirror.com/confbox/-/confbox-0.2.2.tgz",
"integrity": "sha512-1NB+BKqhtNipMsov4xI/NnhCKp9XG9NamYp5PVm9klAT0fsrNPjaFICsCFhNhwZJKNh7zB/3q8qXz0E9oaMNtQ==",
"dev": true,
"devOptional": true,
"license": "MIT"
},
"node_modules/consola": {
"version": "3.4.2",
"resolved": "https://registry.npmmirror.com/consola/-/consola-3.4.2.tgz",
"integrity": "sha512-5IKcdX0nnYavi6G7TtOhwkYzyjfJlatbjMjuLSfE2kYT5pMDOilZ4OvMhi637CcDICTmz3wARPoyhqyX1Y+XvA==",
"dev": true,
"license": "MIT",
"optional": true,
"peer": true,
@@ -3013,23 +3008,23 @@
"dev": true,
"license": "MIT"
},
"node_modules/deep-pick-omit": {
"version": "1.2.1",
"resolved": "https://registry.npmmirror.com/deep-pick-omit/-/deep-pick-omit-1.2.1.tgz",
"integrity": "sha512-2J6Kc/m3irCeqVG42T+SaUMesaK7oGWaedGnQQK/+O0gYc+2SP5bKh/KKTE7d7SJ+GCA9UUE1GRzh6oDe0EnGw==",
"license": "MIT"
},
"node_modules/defu": {
"version": "6.1.4",
"resolved": "https://registry.npmmirror.com/defu/-/defu-6.1.4.tgz",
"integrity": "sha512-mEQCMmwJu317oSz8CwdIOdwf3xMif1ttiM8LTufzc3g6kR+9Pe236twL8j3IYT1F7GfRgGcW6MWxzZjLIkuHIg==",
"dev": true,
"license": "MIT",
"optional": true,
"peer": true
"license": "MIT"
},
"node_modules/destr": {
"version": "2.0.5",
"resolved": "https://registry.npmmirror.com/destr/-/destr-2.0.5.tgz",
"integrity": "sha512-ugFTXCtDZunbzasqBxrK93Ik/DRYsO6S/fedkWEMKqt04xZ4csmnmwGDBAb07QWNaGMAmnTIemsYZCksjATwsA==",
"dev": true,
"license": "MIT",
"optional": true,
"peer": true
"license": "MIT"
},
"node_modules/detect-libc": {
"version": "1.0.3",
@@ -3048,7 +3043,6 @@
"version": "16.5.0",
"resolved": "https://registry.npmmirror.com/dotenv/-/dotenv-16.5.0.tgz",
"integrity": "sha512-m/C+AwOAr9/W1UOIZUo232ejMNnJAJtYQjUbHoNTBNTJSvqzzDh7vnrei3o3r3m9blf6ZoDkvcw0VmozNRFJxg==",
"dev": true,
"license": "BSD-2-Clause",
"optional": true,
"peer": true,
@@ -3075,7 +3069,6 @@
"version": "0.1.0",
"resolved": "https://registry.npmmirror.com/errx/-/errx-0.1.0.tgz",
"integrity": "sha512-fZmsRiDNv07K6s2KkKFTiD2aIvECa7++PKyD5NC32tpRw46qZA3sOz+aM+/V9V0GDHxVTKLziveV4JhzBHDp9Q==",
"dev": true,
"license": "MIT",
"optional": true,
"peer": true
@@ -3321,7 +3314,7 @@
"version": "1.0.5",
"resolved": "https://registry.npmmirror.com/exsolve/-/exsolve-1.0.5.tgz",
"integrity": "sha512-pz5dvkYYKQ1AHVrgOzBKWeP4u4FRb3a6DNK2ucr0OoNwYIU4QWsJ+NM36LLzORT+z845MzKHHhpXiUF5nvQoJg==",
"dev": true,
"devOptional": true,
"license": "MIT"
},
"node_modules/fast-deep-equal": {
@@ -3468,7 +3461,6 @@
"version": "2.0.0",
"resolved": "https://registry.npmmirror.com/giget/-/giget-2.0.0.tgz",
"integrity": "sha512-L5bGsVkxJbJgdnwyuheIunkGatUF/zssUoxxjACCseZYAVbaqdh9Tsmmlkl8vYan09H7sbvKt4pS8GqKLBrEzA==",
"dev": true,
"license": "MIT",
"optional": true,
"peer": true,
@@ -3667,7 +3659,6 @@
"version": "2.4.2",
"resolved": "https://registry.npmmirror.com/jiti/-/jiti-2.4.2.tgz",
"integrity": "sha512-rg9zJN+G4n2nfJl5MW3BMygZX56zKPNVEYYqq7adpmMh4Jn2QNEwhvQlFy6jPVdcod7txZtKHWnyZiA3a0zP7A==",
"dev": true,
"license": "MIT",
"optional": true,
"peer": true,
@@ -3679,7 +3670,6 @@
"version": "9.0.1",
"resolved": "https://registry.npmmirror.com/js-tokens/-/js-tokens-9.0.1.tgz",
"integrity": "sha512-mxa9E9ITFOt0ban3j6L5MpjwegGz6lBQmM1IJkWeBZGcMxto50+eWdjC/52xDbS2vy0k7vIMK0Fe2wfL9OQSpQ==",
"dev": true,
"license": "MIT",
"optional": true,
"peer": true
@@ -3732,7 +3722,6 @@
"version": "2.0.6",
"resolved": "https://registry.npmmirror.com/klona/-/klona-2.0.6.tgz",
"integrity": "sha512-dhG34DXATL5hSxJbIexCft8FChFXtmskoZYnoPWjXQuebWYCNkVeV3KkGegCK9CP1oswI/vQibS2GY7Em/sJJA==",
"dev": true,
"license": "MIT",
"optional": true,
"peer": true,
@@ -3744,7 +3733,6 @@
"version": "1.2.0",
"resolved": "https://registry.npmmirror.com/knitwork/-/knitwork-1.2.0.tgz",
"integrity": "sha512-xYSH7AvuQ6nXkq42x0v5S8/Iry+cfulBz/DJQzhIyESdLD7425jXsPy4vn5cCXU+HhRN2kVw51Vd1K6/By4BQg==",
"dev": true,
"license": "MIT",
"optional": true,
"peer": true
@@ -3793,7 +3781,7 @@
"version": "1.1.1",
"resolved": "https://registry.npmmirror.com/local-pkg/-/local-pkg-1.1.1.tgz",
"integrity": "sha512-WunYko2W1NcdfAFpuLUoucsgULmgDBRkdxHxWQ7mK0cQqwPiy8E1enjuRBrhLtZkB5iScJ1XIPdhVEFK8aOLSg==",
"dev": true,
"devOptional": true,
"license": "MIT",
"dependencies": {
"mlly": "^1.7.4",
@@ -3893,7 +3881,7 @@
"version": "1.7.4",
"resolved": "https://registry.npmmirror.com/mlly/-/mlly-1.7.4.tgz",
"integrity": "sha512-qmdSIPC4bDJXgZTCR7XosJiNKySV7O215tsPtDN9iEO/7q/76b/ijtgRu/+epFXSJhijtTCCGp3DWS549P3xKw==",
"dev": true,
"devOptional": true,
"license": "MIT",
"dependencies": {
"acorn": "^8.14.0",
@@ -3906,14 +3894,14 @@
"version": "0.1.8",
"resolved": "https://registry.npmmirror.com/confbox/-/confbox-0.1.8.tgz",
"integrity": "sha512-RMtmw0iFkeR4YV+fUOSucriAQNb9g8zFR52MWCtl+cCZOFRNL6zeB395vPzFhEjjn4fMxXudmELnl/KF/WrK6w==",
"dev": true,
"devOptional": true,
"license": "MIT"
},
"node_modules/mlly/node_modules/pkg-types": {
"version": "1.3.1",
"resolved": "https://registry.npmmirror.com/pkg-types/-/pkg-types-1.3.1.tgz",
"integrity": "sha512-/Jm5M4RvtBFVkKWRu2BLUTNP8/M2a+UwuAX+ae4770q1qVGtfjG+WTCupoZixokjmHiry8uI+dlY8KXYV5HVVQ==",
"dev": true,
"devOptional": true,
"license": "MIT",
"dependencies": {
"confbox": "^0.1.8",
@@ -3971,7 +3959,6 @@
"version": "1.6.6",
"resolved": "https://registry.npmmirror.com/node-fetch-native/-/node-fetch-native-1.6.6.tgz",
"integrity": "sha512-8Mc2HhqPdlIfedsuZoc3yioPuzp6b+L5jRCRY1QzuWZh2EGJVQrGppC6V6cF0bLdbW0+O2YpqCA25aF/1lvipQ==",
"dev": true,
"license": "MIT",
"optional": true,
"peer": true
@@ -4003,7 +3990,6 @@
"version": "0.6.0",
"resolved": "https://registry.npmmirror.com/nypm/-/nypm-0.6.0.tgz",
"integrity": "sha512-mn8wBFV9G9+UFHIrq+pZ2r2zL4aPau/by3kJb3cM7+5tQHMt6HGQB8FDIeKFYp8o0D2pnH6nVsO88N4AmUxIWg==",
"dev": true,
"license": "MIT",
"optional": true,
"peer": true,
@@ -4025,7 +4011,6 @@
"version": "2.0.11",
"resolved": "https://registry.npmmirror.com/ohash/-/ohash-2.0.11.tgz",
"integrity": "sha512-RdR9FQrFwNBNXAr4GixM8YaRZRJ5PUWbKYbE5eOsrwAjJW0q2REGcf79oYPsLyskQCZG1PLN+S/K1V00joZAoQ==",
"dev": true,
"license": "MIT",
"optional": true,
"peer": true
@@ -4124,7 +4109,7 @@
"version": "2.0.3",
"resolved": "https://registry.npmmirror.com/pathe/-/pathe-2.0.3.tgz",
"integrity": "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==",
"dev": true,
"devOptional": true,
"license": "MIT"
},
"node_modules/perfect-debounce": {
@@ -4173,11 +4158,38 @@
}
}
},
"node_modules/pinia-plugin-persistedstate": {
"version": "4.4.1",
"resolved": "https://registry.npmmirror.com/pinia-plugin-persistedstate/-/pinia-plugin-persistedstate-4.4.1.tgz",
"integrity": "sha512-lmuMPpXla2zJKjxEq34e1E9P9jxkWEhcVwwioCCE0izG45kkTOvQfCzvwhW3i38cvnaWC7T1eRdkd15Re59ldw==",
"license": "MIT",
"dependencies": {
"deep-pick-omit": "^1.2.1",
"defu": "^6.1.4",
"destr": "^2.0.5"
},
"peerDependencies": {
"@nuxt/kit": ">=3.0.0",
"@pinia/nuxt": ">=0.10.0",
"pinia": ">=3.0.0"
},
"peerDependenciesMeta": {
"@nuxt/kit": {
"optional": true
},
"@pinia/nuxt": {
"optional": true
},
"pinia": {
"optional": true
}
}
},
"node_modules/pkg-types": {
"version": "2.1.0",
"resolved": "https://registry.npmmirror.com/pkg-types/-/pkg-types-2.1.0.tgz",
"integrity": "sha512-wmJwA+8ihJixSoHKxZJRBQG1oY8Yr9pGLzRmSsNms0iNWyHHAlZCa7mmKiFR10YPZuz/2k169JiS/inOjBCZ2A==",
"dev": true,
"devOptional": true,
"license": "MIT",
"dependencies": {
"confbox": "^0.2.1",
@@ -4266,7 +4278,7 @@
"version": "0.2.10",
"resolved": "https://registry.npmmirror.com/quansync/-/quansync-0.2.10.tgz",
"integrity": "sha512-t41VRkMYbkHyCYmOvx/6URnN80H7k4X0lLdBMGsz+maAwrJQYB1djpV6vHrQIBE0WBSGqhtEHrK9U3DWWH8v7A==",
"dev": true,
"devOptional": true,
"funding": [
{
"type": "individual",
@@ -4304,7 +4316,6 @@
"version": "2.1.2",
"resolved": "https://registry.npmmirror.com/rc9/-/rc9-2.1.2.tgz",
"integrity": "sha512-btXCnMmRIBINM2LDZoEmOogIZU7Qe7zn4BpomSKZ/ykbLObuBdvG+mFq11DL6fjH1DRwHhrlgtYWG96bJiC7Cg==",
"dev": true,
"license": "MIT",
"optional": true,
"peer": true,
@@ -4441,7 +4452,6 @@
"version": "1.3.0",
"resolved": "https://registry.npmmirror.com/scule/-/scule-1.3.0.tgz",
"integrity": "sha512-6FtHJEvt+pVMIB9IBY+IcCJ6Z5f1iQnytgyfKMhDKgmzYG+TeH/wx1y3l27rshSbLiSanrR9ffZDrEsmjlQF2g==",
"dev": true,
"license": "MIT",
"optional": true,
"peer": true
@@ -4450,7 +4460,7 @@
"version": "7.7.2",
"resolved": "https://registry.npmmirror.com/semver/-/semver-7.7.2.tgz",
"integrity": "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==",
"dev": true,
"devOptional": true,
"license": "ISC",
"bin": {
"semver": "bin/semver.js"
@@ -4504,7 +4514,6 @@
"version": "3.9.0",
"resolved": "https://registry.npmmirror.com/std-env/-/std-env-3.9.0.tgz",
"integrity": "sha512-UGvjygr6F6tpH7o2qyqR6QYpwraIjKSdtzyBdyytFOHmPZY917kwdwLG0RbOjWOnKmnm3PeHjaoLLMie7kPLQw==",
"dev": true,
"license": "MIT",
"optional": true,
"peer": true
@@ -4526,7 +4535,6 @@
"version": "3.0.0",
"resolved": "https://registry.npmmirror.com/strip-literal/-/strip-literal-3.0.0.tgz",
"integrity": "sha512-TcccoMhJOM3OebGhSBEmp3UZ2SfDMZUEBdRA/9ynfLi8yYajyWX3JiXArcJt4Umh4vISpspkQIY8ZZoCqjbviA==",
"dev": true,
"license": "MIT",
"optional": true,
"peer": true,
@@ -4572,7 +4580,6 @@
"version": "0.3.2",
"resolved": "https://registry.npmmirror.com/tinyexec/-/tinyexec-0.3.2.tgz",
"integrity": "sha512-KQQR9yN7R5+OSwaK0XQoj22pwHoTlgYqmUscPYoknOoWCWfj/5/ABTMRi69FrKU5ffPVh5QcFikpWJI/P1ocHA==",
"dev": true,
"license": "MIT",
"optional": true,
"peer": true
@@ -4581,7 +4588,7 @@
"version": "0.2.14",
"resolved": "https://registry.npmmirror.com/tinyglobby/-/tinyglobby-0.2.14.tgz",
"integrity": "sha512-tX5e7OM1HnYr2+a2C/4V0htOcSQcoSTH9KgJnVvNm5zm/cyEWKJ7j7YutsH9CxMdtOkkLFy2AHrMci9IM8IPZQ==",
"dev": true,
"devOptional": true,
"license": "MIT",
"dependencies": {
"fdir": "^6.4.4",
@@ -4598,7 +4605,7 @@
"version": "6.4.4",
"resolved": "https://registry.npmmirror.com/fdir/-/fdir-6.4.4.tgz",
"integrity": "sha512-1NZP+GK4GfuAv3PqKvxQRDMjdSRZjnkq7KfhlNrCNNlZ0ygQFpebfrnfnq/W7fpUnAv9aGWmY1zKx7FYL3gwhg==",
"dev": true,
"devOptional": true,
"license": "MIT",
"peerDependencies": {
"picomatch": "^3 || ^4"
@@ -4613,7 +4620,7 @@
"version": "4.0.2",
"resolved": "https://registry.npmmirror.com/picomatch/-/picomatch-4.0.2.tgz",
"integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==",
"dev": true,
"devOptional": true,
"license": "MIT",
"engines": {
"node": ">=12"
@@ -4702,14 +4709,13 @@
"version": "1.6.1",
"resolved": "https://registry.npmmirror.com/ufo/-/ufo-1.6.1.tgz",
"integrity": "sha512-9a4/uxlTWJ4+a5i0ooc1rU7C7YOw3wT+UGqdeNNHWnOF9qcMBgLRS+4IYUqbczewFx4mLEig6gawh7X6mFlEkA==",
"dev": true,
"devOptional": true,
"license": "MIT"
},
"node_modules/unctx": {
"version": "2.4.1",
"resolved": "https://registry.npmmirror.com/unctx/-/unctx-2.4.1.tgz",
"integrity": "sha512-AbaYw0Nm4mK4qjhns67C+kgxR2YWiwlDBPzxrN8h8C6VtAdCgditAY5Dezu3IJy4XVqAnbrXt9oQJvsn3fyozg==",
"dev": true,
"license": "MIT",
"optional": true,
"peer": true,
@@ -4724,7 +4730,6 @@
"version": "3.0.3",
"resolved": "https://registry.npmmirror.com/estree-walker/-/estree-walker-3.0.3.tgz",
"integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==",
"dev": true,
"license": "MIT",
"optional": true,
"peer": true,
@@ -4743,7 +4748,6 @@
"version": "5.0.1",
"resolved": "https://registry.npmmirror.com/unimport/-/unimport-5.0.1.tgz",
"integrity": "sha512-1YWzPj6wYhtwHE+9LxRlyqP4DiRrhGfJxdtH475im8ktyZXO3jHj/3PZ97zDdvkYoovFdi0K4SKl3a7l92v3sQ==",
"dev": true,
"license": "MIT",
"optional": true,
"peer": true,
@@ -4771,7 +4775,6 @@
"version": "5.0.0",
"resolved": "https://registry.npmmirror.com/escape-string-regexp/-/escape-string-regexp-5.0.0.tgz",
"integrity": "sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw==",
"dev": true,
"license": "MIT",
"optional": true,
"peer": true,
@@ -4786,7 +4789,6 @@
"version": "3.0.3",
"resolved": "https://registry.npmmirror.com/estree-walker/-/estree-walker-3.0.3.tgz",
"integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==",
"dev": true,
"license": "MIT",
"optional": true,
"peer": true,
@@ -4798,7 +4800,6 @@
"version": "4.0.2",
"resolved": "https://registry.npmmirror.com/picomatch/-/picomatch-4.0.2.tgz",
"integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==",
"dev": true,
"license": "MIT",
"optional": true,
"peer": true,
@@ -4813,7 +4814,7 @@
"version": "2.3.5",
"resolved": "https://registry.npmmirror.com/unplugin/-/unplugin-2.3.5.tgz",
"integrity": "sha512-RyWSb5AHmGtjjNQ6gIlA67sHOsWpsbWpwDokLwTcejVdOjEkJZh7QKu14J00gDDVSh8kGH4KYC/TNBceXFZhtw==",
"dev": true,
"devOptional": true,
"license": "MIT",
"dependencies": {
"acorn": "^8.14.1",
@@ -4828,7 +4829,7 @@
"version": "0.2.4",
"resolved": "https://registry.npmmirror.com/unplugin-utils/-/unplugin-utils-0.2.4.tgz",
"integrity": "sha512-8U/MtpkPkkk3Atewj1+RcKIjb5WBimZ/WSLhhR3w6SsIj8XJuKTacSP8g+2JhfSGw0Cb125Y+2zA/IzJZDVbhA==",
"dev": true,
"devOptional": true,
"license": "MIT",
"dependencies": {
"pathe": "^2.0.2",
@@ -4845,7 +4846,7 @@
"version": "4.0.2",
"resolved": "https://registry.npmmirror.com/picomatch/-/picomatch-4.0.2.tgz",
"integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==",
"dev": true,
"devOptional": true,
"license": "MIT",
"engines": {
"node": ">=12"
@@ -4945,7 +4946,7 @@
"version": "4.0.2",
"resolved": "https://registry.npmmirror.com/picomatch/-/picomatch-4.0.2.tgz",
"integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==",
"dev": true,
"devOptional": true,
"license": "MIT",
"engines": {
"node": ">=12"
@@ -4958,7 +4959,6 @@
"version": "2.0.0",
"resolved": "https://registry.npmmirror.com/untyped/-/untyped-2.0.0.tgz",
"integrity": "sha512-nwNCjxJTjNuLCgFr42fEak5OcLuB3ecca+9ksPFNvtfYSLpjf+iJqSIaSnIile6ZPbKYxI5k2AfXqeopGudK/g==",
"dev": true,
"license": "MIT",
"optional": true,
"peer": true,
@@ -4990,19 +4990,6 @@
"dev": true,
"license": "MIT"
},
"node_modules/uuid": {
"version": "11.1.0",
"resolved": "https://registry.npmmirror.com/uuid/-/uuid-11.1.0.tgz",
"integrity": "sha512-0/A9rDy9P7cJ+8w1c9WD9V//9Wj15Ce2MPz8Ri6032usz+NfePxx5AcN3bN+r6ZL6jEo066/yNYB3tn4pQEx+A==",
"funding": [
"https://github.com/sponsors/broofa",
"https://github.com/sponsors/ctavan"
],
"license": "MIT",
"bin": {
"uuid": "dist/esm/bin/uuid"
}
},
"node_modules/vite": {
"version": "6.3.5",
"resolved": "https://registry.npmmirror.com/vite/-/vite-6.3.5.tgz",
@@ -5233,7 +5220,7 @@
"version": "0.6.2",
"resolved": "https://registry.npmmirror.com/webpack-virtual-modules/-/webpack-virtual-modules-0.6.2.tgz",
"integrity": "sha512-66/V2i5hQanC51vBQKPH4aI8NMAcBW59FVBs+rC7eGHupMyfn34q7rZIE+ETlJ+XTevqfUhVVBgSUNSW2flEUQ==",
"dev": true,
"devOptional": true,
"license": "MIT"
},
"node_modules/which": {

View File

@@ -51,9 +51,9 @@
"hsl-matcher": "^1.2.4",
"lezer": "^0.13.5",
"pinia": "^3.0.3",
"pinia-plugin-persistedstate": "^4.4.1",
"prettier": "^3.5.3",
"sass": "^1.89.2",
"uuid": "^11.1.0",
"vue": "^3.5.17",
"vue-i18n": "^11.1.6",
"vue-router": "^4.5.1"

View File

@@ -35,10 +35,7 @@ const toggleAlwaysOnTop = async () => {
// 跳转到设置页面
const goToSettings = () => {
router.push({
path: '/settings',
query: { documentId: documentStore.currentDocumentId || undefined }
});
router.push('/settings');
};
// 执行格式化

View File

@@ -4,7 +4,10 @@ import '@/assets/styles/index.css';
import {createPinia} from 'pinia';
import i18n from './i18n';
import router from './router';
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
const pinia = createPinia()
pinia.use(piniaPluginPersistedstate)
const app = createApp(App);
app.use(pinia)
app.use(i18n);

View File

@@ -12,15 +12,13 @@ const routes: RouteRecordRaw[] = [
{
path: '/',
name: 'Editor',
component: Editor,
props: route => ({ documentId: route.query.documentId ? Number(route.query.documentId) : null })
component: Editor
},
{
path: '/settings',
name: 'Settings',
redirect: '/settings/general',
component: Settings,
props: route => ({ returnDocumentId: route.query.documentId ? Number(route.query.documentId) : null }),
children: [
{
path: 'general',

View File

@@ -190,10 +190,15 @@ export const useDocumentStore = defineStore('document', () => {
try {
await updateDocuments();
// 获取第一个文档ID并打开
const firstDocId = await DocumentService.GetFirstDocumentID();
if (firstDocId && documents.value[firstDocId]) {
await openDocument(firstDocId);
// 如果存在持久化的文档ID尝试打开该文档
if (currentDocumentId.value && documents.value[currentDocumentId.value]) {
await openDocument(currentDocumentId.value);
} else {
// 否则获取第一个文档ID并打开
const firstDocId = await DocumentService.GetFirstDocumentID();
if (firstDocId && documents.value[firstDocId]) {
await openDocument(firstDocId);
}
}
} catch (error) {
console.error('Failed to initialize document store:', error);
@@ -221,4 +226,10 @@ export const useDocumentStore = defineStore('document', () => {
closeDialog,
initialize,
};
}, {
persist: {
key: 'voidraft-document',
storage: localStorage,
pick: ['currentDocumentId']
}
});

View File

@@ -6,11 +6,6 @@ import {useConfigStore} from '@/stores/configStore';
import {createWheelZoomHandler} from './basic/wheelZoomExtension';
import Toolbar from '@/components/toolbar/Toolbar.vue';
// 接收路由传入的文档ID
const props = defineProps<{
documentId?: number | null
}>();
const editorStore = useEditorStore();
const documentStore = useDocumentStore();
const configStore = useConfigStore();
@@ -26,13 +21,9 @@ const wheelHandler = createWheelZoomHandler(
onMounted(async () => {
if (!editorElement.value) return;
// 初始化文档存储会自动使用持久化的文档ID
await documentStore.initialize();
// 如果有指定文档ID则打开该文档
if (props.documentId) {
await documentStore.openDocument(props.documentId);
}
// 设置编辑器容器
editorStore.setEditorContainer(editorElement.value);
@@ -46,13 +37,6 @@ onBeforeUnmount(() => {
editorElement.value.removeEventListener('wheel', wheelHandler);
}
});
// 监听文档ID变化
watch(() => props.documentId, async (newDocId) => {
if (newDocId && documentStore.currentDocumentId !== newDocId) {
await documentStore.openDocument(newDocId);
}
}, { immediate: true });
</script>
<template>

View File

@@ -8,11 +8,6 @@ const { t } = useI18n();
const router = useRouter();
const route = useRoute();
// 接收路由传入的参数
const props = defineProps<{
returnDocumentId?: number | null
}>();
// 导航配置
const navItems = [
{ id: 'general', icon: '⚙️', route: '/settings/general' },
@@ -33,15 +28,7 @@ const handleNavClick = (item: typeof navItems[0]) => {
// 返回编辑器
const goBackToEditor = async () => {
// 如果有返回文档ID则传递参数
if (props.returnDocumentId) {
await router.push({
path: '/',
query: { documentId: props.returnDocumentId }
});
} else {
await router.push('/');
}
await router.push('/');
};
</script>

View File

@@ -106,7 +106,7 @@ type ConfigMetadata struct {
// NewDefaultAppConfig 创建默认应用配置
func NewDefaultAppConfig() *AppConfig {
currentDir, _ := os.UserConfigDir()
currentDir, _ := os.UserHomeDir()
dataDir := filepath.Join(currentDir, ".voidraft", "data")
return &AppConfig{

View File

@@ -4,13 +4,14 @@ import (
"time"
)
// Document 表示一个文档(使用自增主键)
// Document represents a document in the system
type Document struct {
ID int64 `json:"id" db:"id"`
Title string `json:"title" db:"title"`
Content string `json:"content" db:"content"`
CreatedAt time.Time `json:"createdAt" db:"created_at"`
UpdatedAt time.Time `json:"updatedAt" db:"updated_at"`
IsDeleted bool `json:"is_deleted"`
}
// NewDocument 创建新文档不需要传ID由数据库自增
@@ -21,6 +22,7 @@ func NewDocument(title, content string) *Document {
Content: content,
CreatedAt: now,
UpdatedAt: now,
IsDeleted: false,
}
}

View File

@@ -5,6 +5,7 @@ import (
"database/sql"
"errors"
"fmt"
"os"
"path/filepath"
"sync"
"time"
@@ -25,12 +26,14 @@ CREATE TABLE IF NOT EXISTS documents (
title TEXT NOT NULL,
content TEXT DEFAULT '∞∞∞text-a',
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
is_deleted INTEGER DEFAULT 0
)`
// Performance optimization indexes
sqlCreateIndexUpdatedAt = `CREATE INDEX IF NOT EXISTS idx_documents_updated_at ON documents(updated_at DESC)`
sqlCreateIndexTitle = `CREATE INDEX IF NOT EXISTS idx_documents_title ON documents(title)`
sqlCreateIndexIsDeleted = `CREATE INDEX IF NOT EXISTS idx_documents_is_deleted ON documents(is_deleted)`
// SQLite performance optimization settings
sqlOptimizationSettings = `
@@ -42,18 +45,13 @@ PRAGMA foreign_keys = ON;`
// Document operations
sqlGetDocumentByID = `
SELECT id, title, content, created_at, updated_at
SELECT id, title, content, created_at, updated_at, is_deleted
FROM documents
WHERE id = ?`
sqlInsertDocument = `
INSERT INTO documents (title, content, created_at, updated_at)
VALUES (?, ?, ?, ?)`
sqlUpdateDocument = `
UPDATE documents
SET title = ?, content = ?, updated_at = ?
WHERE id = ?`
INSERT INTO documents (title, content, created_at, updated_at, is_deleted)
VALUES (?, ?, ?, ?, 0)`
sqlUpdateDocumentContent = `
UPDATE documents
@@ -65,16 +63,34 @@ UPDATE documents
SET title = ?, updated_at = ?
WHERE id = ?`
sqlDeleteDocument = `
DELETE FROM documents WHERE id = ?`
sqlMarkDocumentAsDeleted = `
UPDATE documents
SET is_deleted = 1, updated_at = ?
WHERE id = ?`
sqlRestoreDocument = `
UPDATE documents
SET is_deleted = 0, updated_at = ?
WHERE id = ?`
sqlListAllDocumentsMeta = `
SELECT id, title, created_at, updated_at
FROM documents
WHERE is_deleted = 0
ORDER BY updated_at DESC`
sqlListDeletedDocumentsMeta = `
SELECT id, title, created_at, updated_at
FROM documents
WHERE is_deleted = 1
ORDER BY updated_at DESC`
sqlGetFirstDocumentID = `
SELECT id FROM documents ORDER BY id LIMIT 1`
SELECT id FROM documents WHERE is_deleted = 0 ORDER BY id LIMIT 1`
sqlCountDocuments = `SELECT COUNT(*) FROM documents WHERE is_deleted = 0`
sqlDefaultDocumentID = 1 // 默认文档的ID
)
// DocumentService provides document management functionality
@@ -111,6 +127,23 @@ func (ds *DocumentService) initDatabase() error {
return fmt.Errorf("failed to get database path: %w", err)
}
// 确保数据库目录存在
dbDir := filepath.Dir(dbPath)
if err := os.MkdirAll(dbDir, 0755); err != nil {
return fmt.Errorf("failed to create database directory: %w", err)
}
// 检查数据库文件是否存在,如果不存在则创建
if _, err := os.Stat(dbPath); os.IsNotExist(err) {
ds.logger.Info("Database file does not exist, creating empty file", "path", dbPath)
// 创建空文件
file, err := os.Create(dbPath)
if err != nil {
return fmt.Errorf("failed to create database file: %w", err)
}
file.Close()
}
db, err := sql.Open("sqlite", dbPath)
if err != nil {
return fmt.Errorf("failed to open database: %w", err)
@@ -155,6 +188,7 @@ func (ds *DocumentService) createIndexes() error {
indexes := []string{
sqlCreateIndexUpdatedAt,
sqlCreateIndexTitle,
sqlCreateIndexIsDeleted,
}
for _, index := range indexes {
@@ -169,7 +203,7 @@ func (ds *DocumentService) createIndexes() error {
func (ds *DocumentService) ensureDefaultDocument() error {
// Check if any document exists
var count int
err := ds.db.QueryRow("SELECT COUNT(*) FROM documents").Scan(&count)
err := ds.db.QueryRow(sqlCountDocuments).Scan(&count)
if err != nil {
return err
}
@@ -189,14 +223,16 @@ func (ds *DocumentService) GetDocumentByID(id int64) (*models.Document, error) {
defer ds.mu.RUnlock()
var doc models.Document
var isDeletedInt int
row := ds.db.QueryRow(sqlGetDocumentByID, id)
err := row.Scan(&doc.ID, &doc.Title, &doc.Content, &doc.CreatedAt, &doc.UpdatedAt)
err := row.Scan(&doc.ID, &doc.Title, &doc.Content, &doc.CreatedAt, &doc.UpdatedAt, &isDeletedInt)
if err != nil {
if errors.Is(err, sql.ErrNoRows) {
return nil, nil
}
return nil, fmt.Errorf("failed to get document by ID: %w", err)
}
doc.IsDeleted = isDeletedInt == 1
return &doc, nil
}
@@ -213,6 +249,7 @@ func (ds *DocumentService) CreateDocument(title string) (*models.Document, error
Content: "∞∞∞text-a\n",
CreatedAt: now,
UpdatedAt: now,
IsDeleted: false,
}
result, err := ds.db.Exec(sqlInsertDocument, doc.Title, doc.Content, doc.CreatedAt, doc.UpdatedAt)
@@ -255,31 +292,36 @@ func (ds *DocumentService) UpdateDocumentTitle(id int64, title string) error {
return nil
}
// DeleteDocument deletes a document (not allowed if it's the only document)
// DeleteDocument marks a document as deleted (default document with ID=1 cannot be deleted)
func (ds *DocumentService) DeleteDocument(id int64) error {
ds.mu.Lock()
defer ds.mu.Unlock()
// Check if this is the only document
var count int
err := ds.db.QueryRow("SELECT COUNT(*) FROM documents").Scan(&count)
if err != nil {
return fmt.Errorf("failed to count documents: %w", err)
// 不允许删除默认文档
if id == sqlDefaultDocumentID {
return fmt.Errorf("cannot delete the default document")
}
// Don't allow deletion if this is the only document
if count <= 1 {
return fmt.Errorf("cannot delete the last document")
}
_, err = ds.db.Exec(sqlDeleteDocument, id)
_, err := ds.db.Exec(sqlMarkDocumentAsDeleted, time.Now(), id)
if err != nil {
return fmt.Errorf("failed to delete document: %w", err)
return fmt.Errorf("failed to mark document as deleted: %w", err)
}
return nil
}
// ListAllDocumentsMeta lists all document metadata
// RestoreDocument restores a deleted document
func (ds *DocumentService) RestoreDocument(id int64) error {
ds.mu.Lock()
defer ds.mu.Unlock()
_, err := ds.db.Exec(sqlRestoreDocument, time.Now(), id)
if err != nil {
return fmt.Errorf("failed to restore document: %w", err)
}
return nil
}
// ListAllDocumentsMeta lists all active (non-deleted) document metadata
func (ds *DocumentService) ListAllDocumentsMeta() ([]*models.Document, error) {
ds.mu.RLock()
defer ds.mu.RUnlock()
@@ -297,13 +339,39 @@ func (ds *DocumentService) ListAllDocumentsMeta() ([]*models.Document, error) {
if err != nil {
return nil, fmt.Errorf("failed to scan document meta: %w", err)
}
doc.IsDeleted = false
documents = append(documents, &doc)
}
return documents, nil
}
// GetFirstDocumentID gets the first document's ID for frontend initialization
// ListDeletedDocumentsMeta lists all deleted document metadata
func (ds *DocumentService) ListDeletedDocumentsMeta() ([]*models.Document, error) {
ds.mu.RLock()
defer ds.mu.RUnlock()
rows, err := ds.db.Query(sqlListDeletedDocumentsMeta)
if err != nil {
return nil, fmt.Errorf("failed to list deleted document meta: %w", err)
}
defer rows.Close()
var documents []*models.Document
for rows.Next() {
var doc models.Document
err := rows.Scan(&doc.ID, &doc.Title, &doc.CreatedAt, &doc.UpdatedAt)
if err != nil {
return nil, fmt.Errorf("failed to scan deleted document meta: %w", err)
}
doc.IsDeleted = true
documents = append(documents, &doc)
}
return documents, nil
}
// GetFirstDocumentID gets the first active document's ID for frontend initialization
func (ds *DocumentService) GetFirstDocumentID() (int64, error) {
ds.mu.RLock()
defer ds.mu.RUnlock()

View File

@@ -16,7 +16,7 @@ type PathManager struct {
// NewPathManager 创建新的路径管理器
func NewPathManager() *PathManager {
// 获取用户配置目录
userConfigDir, err := os.UserConfigDir()
userConfigDir, err := os.UserHomeDir()
if err != nil {
// 如果获取失败,使用当前目录
userConfigDir, _ = os.Getwd()