diff --git a/frontend/bindings/voidraft/internal/models/models.ts b/frontend/bindings/voidraft/internal/models/models.ts index 3f8a0c0..8c1e4b6 100644 --- a/frontend/bindings/voidraft/internal/models/models.ts +++ b/frontend/bindings/voidraft/internal/models/models.ts @@ -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 = {}) { @@ -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); } diff --git a/frontend/bindings/voidraft/internal/services/documentservice.ts b/frontend/bindings/voidraft/internal/services/documentservice.ts index 10fafd5..55e766c 100644 --- a/frontend/bindings/voidraft/internal/services/documentservice.ts +++ b/frontend/bindings/voidraft/internal/services/documentservice.ts @@ -27,7 +27,7 @@ export function CreateDocument(title: string): Promise } /** - * 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 & { cancel(): void } { let $resultPromise = $Call.ByID(412287269, id) as any; @@ -47,7 +47,7 @@ export function GetDocumentByID(id: number): Promise & } /** - * 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 & { cancel(): void } { let $resultPromise = $Call.ByID(2970773833) as any; @@ -55,7 +55,7 @@ export function GetFirstDocumentID(): Promise & { 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 & { cancel(): void } { return $resultPromise; } +/** + * RestoreDocument restores a deleted document + */ +export function RestoreDocument(id: number): Promise & { cancel(): void } { + let $resultPromise = $Call.ByID(784200778, id) as any; + return $resultPromise; +} + /** * UpdateDocumentContent updates the content of a document */ diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 3c4ed1e..ebac803 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -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": { diff --git a/frontend/package.json b/frontend/package.json index 911e530..e6ad64e 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -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" diff --git a/frontend/src/components/toolbar/Toolbar.vue b/frontend/src/components/toolbar/Toolbar.vue index fa71554..2d57339 100644 --- a/frontend/src/components/toolbar/Toolbar.vue +++ b/frontend/src/components/toolbar/Toolbar.vue @@ -35,10 +35,7 @@ const toggleAlwaysOnTop = async () => { // 跳转到设置页面 const goToSettings = () => { - router.push({ - path: '/settings', - query: { documentId: documentStore.currentDocumentId || undefined } - }); + router.push('/settings'); }; // 执行格式化 diff --git a/frontend/src/main.ts b/frontend/src/main.ts index 77b2e1b..4f73a34 100644 --- a/frontend/src/main.ts +++ b/frontend/src/main.ts @@ -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); diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts index 837c24e..3103773 100644 --- a/frontend/src/router/index.ts +++ b/frontend/src/router/index.ts @@ -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', diff --git a/frontend/src/stores/documentStore.ts b/frontend/src/stores/documentStore.ts index 0494eb9..ca9c1d4 100644 --- a/frontend/src/stores/documentStore.ts +++ b/frontend/src/stores/documentStore.ts @@ -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'] + } }); \ No newline at end of file diff --git a/frontend/src/views/editor/Editor.vue b/frontend/src/views/editor/Editor.vue index f913520..2c66251 100644 --- a/frontend/src/views/editor/Editor.vue +++ b/frontend/src/views/editor/Editor.vue @@ -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 });