From 0402f2d2b7616b4c4b0d264d852a48b90240e7a7 Mon Sep 17 00:00:00 2001 From: yyc12345 Date: Sun, 19 Jul 2026 15:57:50 +0800 Subject: [PATCH] refactor: migrate frontend todo page --- frontend/package.json | 1 - frontend/src/components/todo/TodoItem.vue | 80 ++++++++++++++++++ frontend/src/utils/utils.ts | 15 ++++ frontend/src/views/Collection.vue | 2 +- frontend/src/views/Todo.vue | 99 ++++++++++++++++++++++- 5 files changed, 192 insertions(+), 5 deletions(-) create mode 100644 frontend/src/components/todo/TodoItem.vue diff --git a/frontend/package.json b/frontend/package.json index ae7a8c7..9b396f0 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -17,7 +17,6 @@ "@fortawesome/fontawesome-svg-core": "^7.2.0", "@fortawesome/free-solid-svg-icons": "^7.2.0", "@fortawesome/vue-fontawesome": "^3.2.0", - "axios": "1.14.0", "bulma": "0.9.1", "pinia": "^3.0.4", "pinia-plugin-persistedstate": "^4.7.1", diff --git a/frontend/src/components/todo/TodoItem.vue b/frontend/src/components/todo/TodoItem.vue new file mode 100644 index 0000000..e2f5445 --- /dev/null +++ b/frontend/src/components/todo/TodoItem.vue @@ -0,0 +1,80 @@ + + + + + diff --git a/frontend/src/utils/utils.ts b/frontend/src/utils/utils.ts index a323c25..da44cf4 100644 --- a/frontend/src/utils/utils.ts +++ b/frontend/src/utils/utils.ts @@ -38,3 +38,18 @@ export function getWeekday(date: Date): number { if (day == 0) return 6; else return day - 1; } + +/** + * Escape HTML special characters in the string and convert newlines to `
` + * so it can be safely inserted via `v-html`. Port of the legacy jQuery-based + * `LineBreaker2Br` (`$('
').text(strl).html().replace(/\n/g, '
')`). + * @param strl The raw string to convert. + * @returns The escaped, newline-broken HTML string. + */ +export function lineBreaker2Br(strl: string): string { + return strl + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/\n/g, '
'); +} diff --git a/frontend/src/views/Collection.vue b/frontend/src/views/Collection.vue index 6848f08..be4fe5d 100644 --- a/frontend/src/views/Collection.vue +++ b/frontend/src/views/Collection.vue @@ -78,7 +78,7 @@ const addOwnedItem = async () => { const deleteOwnedItem = async (uuid: string) => { const rv = await apiCollectionDeleteOwn(token.currentToken, uuid, ownedItems.value.get(uuid)![2]); - if (rv) { + if (!rv) { messagebox.value?.show("A delete operation failed. It may caused by no matched item. Refreshing page may fix system problem. Before refreshing page, please backup all your unsaved data."); return; } diff --git a/frontend/src/views/Todo.vue b/frontend/src/views/Todo.vue index fcf17de..eae7379 100644 --- a/frontend/src/views/Todo.vue +++ b/frontend/src/views/Todo.vue @@ -1,8 +1,101 @@ - +