refactor: migrate frontend todo page

This commit is contained in:
2026-07-19 15:57:50 +08:00
parent 4c02b47620
commit 0402f2d2b7
5 changed files with 192 additions and 5 deletions
+15
View File
@@ -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 `<br />`
* so it can be safely inserted via `v-html`. Port of the legacy jQuery-based
* `LineBreaker2Br` (`$('<div>').text(strl).html().replace(/\n/g, '<br />')`).
* @param strl The raw string to convert.
* @returns The escaped, newline-broken HTML string.
*/
export function lineBreaker2Br(strl: string): string {
return strl
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/\n/g, '<br />');
}