From ce877b5822fde7e4a45015e01db77c66b6a7988f Mon Sep 17 00:00:00 2001 From: Vanessa Date: Wed, 17 Apr 2024 23:37:49 +0800 Subject: [PATCH] :art: fix https://github.com/siyuan-note/siyuan/issues/11065 --- app/src/menus/workspace.ts | 7 ++++++- app/src/protyle/util/compatibility.ts | 2 +- app/src/types/index.d.ts | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/src/menus/workspace.ts b/app/src/menus/workspace.ts index 5aef7578e..e58ea9917 100644 --- a/app/src/menus/workspace.ts +++ b/app/src/menus/workspace.ts @@ -25,6 +25,7 @@ import {confirmDialog} from "../dialog/confirmDialog"; import {App} from "../index"; import {isBrowser} from "../util/functions"; import {openRecentDocs} from "../business/openRecentDocs"; +import * as dayjs from "dayjs"; const editLayout = (layoutName?: string) => { const dialog = new Dialog({ @@ -72,6 +73,7 @@ const editLayout = (layoutName?: string) => { window.siyuan.storage[Constants.LOCAL_LAYOUTS].find((layoutItem: ISaveLayout) => { if (layoutItem.name === layoutName) { layoutItem.name = value; + layoutItem.time = new Date().getTime(); setStorageVal(Constants.LOCAL_LAYOUTS, window.siyuan.storage[Constants.LOCAL_LAYOUTS]); return true; } @@ -88,6 +90,7 @@ const editLayout = (layoutName?: string) => { window.siyuan.storage[Constants.LOCAL_LAYOUTS].find((layoutItem: ISaveLayout) => { if (layoutItem.name === layoutName) { layoutItem.name = value; + layoutItem.time = new Date().getTime(); layoutItem.layout = getAllLayout(); setStorageVal(Constants.LOCAL_LAYOUTS, window.siyuan.storage[Constants.LOCAL_LAYOUTS]); return true; @@ -99,6 +102,7 @@ const editLayout = (layoutName?: string) => { if (item.name === value) { confirmDialog(window.siyuan.languages.save, window.siyuan.languages.exportTplTip, () => { item.layout = getAllLayout(); + item.time = new Date().getTime(); setStorageVal(Constants.LOCAL_LAYOUTS, window.siyuan.storage[Constants.LOCAL_LAYOUTS]); }); return true; @@ -109,6 +113,7 @@ const editLayout = (layoutName?: string) => { } window.siyuan.storage[Constants.LOCAL_LAYOUTS].push({ name: value, + time: new Date().getTime(), layout: getAllLayout() }); setStorageVal(Constants.LOCAL_LAYOUTS, window.siyuan.storage[Constants.LOCAL_LAYOUTS]); @@ -325,7 +330,7 @@ export const workspaceMenu = (app: App, rect: DOMRect) => { layoutSubMenu.push({ iconHTML: "", action: "iconEdit", - label: item.name, + label: `${item.name} ${item.time ? dayjs(item.time).format("YYYY-MM-DD HH:mm") : ""}`, bind(menuElement) { menuElement.addEventListener("click", (event) => { if (hasClosestByClassName(event.target as Element, "b3-menu__action")) { diff --git a/app/src/protyle/util/compatibility.ts b/app/src/protyle/util/compatibility.ts index a3b5f7f22..2c6a54dc8 100644 --- a/app/src/protyle/util/compatibility.ts +++ b/app/src/protyle/util/compatibility.ts @@ -189,7 +189,7 @@ export const getLocalStorage = (cb: () => void) => { dark: "dark", annoColor: "var(--b3-pdf-background1)" }; - defaultStorage[Constants.LOCAL_LAYOUTS] = []; // {name: "", layout:{}} + defaultStorage[Constants.LOCAL_LAYOUTS] = []; // {name: "", layout:{}, time: number} defaultStorage[Constants.LOCAL_AI] = []; // {name: "", memo: ""} defaultStorage[Constants.LOCAL_PLUGINTOPUNPIN] = []; defaultStorage[Constants.LOCAL_OUTLINE] = {keepExpand: true}; diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.ts index cb505f926..6af8a10e5 100644 --- a/app/src/types/index.d.ts +++ b/app/src/types/index.d.ts @@ -199,6 +199,7 @@ interface IPosition { interface ISaveLayout { name: string, layout: IObject + time: number } interface IWorkspace {