mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-21 03:21:21 +08:00
This commit is contained in:
parent
9a0eedf820
commit
ce877b5822
@ -25,6 +25,7 @@ import {confirmDialog} from "../dialog/confirmDialog";
|
|||||||
import {App} from "../index";
|
import {App} from "../index";
|
||||||
import {isBrowser} from "../util/functions";
|
import {isBrowser} from "../util/functions";
|
||||||
import {openRecentDocs} from "../business/openRecentDocs";
|
import {openRecentDocs} from "../business/openRecentDocs";
|
||||||
|
import * as dayjs from "dayjs";
|
||||||
|
|
||||||
const editLayout = (layoutName?: string) => {
|
const editLayout = (layoutName?: string) => {
|
||||||
const dialog = new Dialog({
|
const dialog = new Dialog({
|
||||||
@ -72,6 +73,7 @@ const editLayout = (layoutName?: string) => {
|
|||||||
window.siyuan.storage[Constants.LOCAL_LAYOUTS].find((layoutItem: ISaveLayout) => {
|
window.siyuan.storage[Constants.LOCAL_LAYOUTS].find((layoutItem: ISaveLayout) => {
|
||||||
if (layoutItem.name === layoutName) {
|
if (layoutItem.name === layoutName) {
|
||||||
layoutItem.name = value;
|
layoutItem.name = value;
|
||||||
|
layoutItem.time = new Date().getTime();
|
||||||
setStorageVal(Constants.LOCAL_LAYOUTS, window.siyuan.storage[Constants.LOCAL_LAYOUTS]);
|
setStorageVal(Constants.LOCAL_LAYOUTS, window.siyuan.storage[Constants.LOCAL_LAYOUTS]);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -88,6 +90,7 @@ const editLayout = (layoutName?: string) => {
|
|||||||
window.siyuan.storage[Constants.LOCAL_LAYOUTS].find((layoutItem: ISaveLayout) => {
|
window.siyuan.storage[Constants.LOCAL_LAYOUTS].find((layoutItem: ISaveLayout) => {
|
||||||
if (layoutItem.name === layoutName) {
|
if (layoutItem.name === layoutName) {
|
||||||
layoutItem.name = value;
|
layoutItem.name = value;
|
||||||
|
layoutItem.time = new Date().getTime();
|
||||||
layoutItem.layout = getAllLayout();
|
layoutItem.layout = getAllLayout();
|
||||||
setStorageVal(Constants.LOCAL_LAYOUTS, window.siyuan.storage[Constants.LOCAL_LAYOUTS]);
|
setStorageVal(Constants.LOCAL_LAYOUTS, window.siyuan.storage[Constants.LOCAL_LAYOUTS]);
|
||||||
return true;
|
return true;
|
||||||
@ -99,6 +102,7 @@ const editLayout = (layoutName?: string) => {
|
|||||||
if (item.name === value) {
|
if (item.name === value) {
|
||||||
confirmDialog(window.siyuan.languages.save, window.siyuan.languages.exportTplTip, () => {
|
confirmDialog(window.siyuan.languages.save, window.siyuan.languages.exportTplTip, () => {
|
||||||
item.layout = getAllLayout();
|
item.layout = getAllLayout();
|
||||||
|
item.time = new Date().getTime();
|
||||||
setStorageVal(Constants.LOCAL_LAYOUTS, window.siyuan.storage[Constants.LOCAL_LAYOUTS]);
|
setStorageVal(Constants.LOCAL_LAYOUTS, window.siyuan.storage[Constants.LOCAL_LAYOUTS]);
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
@ -109,6 +113,7 @@ const editLayout = (layoutName?: string) => {
|
|||||||
}
|
}
|
||||||
window.siyuan.storage[Constants.LOCAL_LAYOUTS].push({
|
window.siyuan.storage[Constants.LOCAL_LAYOUTS].push({
|
||||||
name: value,
|
name: value,
|
||||||
|
time: new Date().getTime(),
|
||||||
layout: getAllLayout()
|
layout: getAllLayout()
|
||||||
});
|
});
|
||||||
setStorageVal(Constants.LOCAL_LAYOUTS, window.siyuan.storage[Constants.LOCAL_LAYOUTS]);
|
setStorageVal(Constants.LOCAL_LAYOUTS, window.siyuan.storage[Constants.LOCAL_LAYOUTS]);
|
||||||
@ -325,7 +330,7 @@ export const workspaceMenu = (app: App, rect: DOMRect) => {
|
|||||||
layoutSubMenu.push({
|
layoutSubMenu.push({
|
||||||
iconHTML: "",
|
iconHTML: "",
|
||||||
action: "iconEdit",
|
action: "iconEdit",
|
||||||
label: item.name,
|
label: `${item.name} <span class="ft__smaller ft__on-surface">${item.time ? dayjs(item.time).format("YYYY-MM-DD HH:mm") : ""}</span>`,
|
||||||
bind(menuElement) {
|
bind(menuElement) {
|
||||||
menuElement.addEventListener("click", (event) => {
|
menuElement.addEventListener("click", (event) => {
|
||||||
if (hasClosestByClassName(event.target as Element, "b3-menu__action")) {
|
if (hasClosestByClassName(event.target as Element, "b3-menu__action")) {
|
||||||
|
@ -189,7 +189,7 @@ export const getLocalStorage = (cb: () => void) => {
|
|||||||
dark: "dark",
|
dark: "dark",
|
||||||
annoColor: "var(--b3-pdf-background1)"
|
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_AI] = []; // {name: "", memo: ""}
|
||||||
defaultStorage[Constants.LOCAL_PLUGINTOPUNPIN] = [];
|
defaultStorage[Constants.LOCAL_PLUGINTOPUNPIN] = [];
|
||||||
defaultStorage[Constants.LOCAL_OUTLINE] = {keepExpand: true};
|
defaultStorage[Constants.LOCAL_OUTLINE] = {keepExpand: true};
|
||||||
|
1
app/src/types/index.d.ts
vendored
1
app/src/types/index.d.ts
vendored
@ -199,6 +199,7 @@ interface IPosition {
|
|||||||
interface ISaveLayout {
|
interface ISaveLayout {
|
||||||
name: string,
|
name: string,
|
||||||
layout: IObject
|
layout: IObject
|
||||||
|
time: number
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IWorkspace {
|
interface IWorkspace {
|
||||||
|
Loading…
Reference in New Issue
Block a user