Vanessa 2025-10-25 21:14:03 +08:00
parent c0fd1f06b8
commit f89ef1b9c5
3 changed files with 10 additions and 6 deletions

View file

@ -3,7 +3,7 @@ import {unicode2Emoji} from "../emoji";
import {Constants} from "../constants"; import {Constants} from "../constants";
import {escapeHtml} from "../util/escape"; import {escapeHtml} from "../util/escape";
import {isWindow} from "../util/functions"; import {isWindow} from "../util/functions";
import {updateHotkeyTip} from "../protyle/util/compatibility"; import {setStorageVal, updateHotkeyTip} from "../protyle/util/compatibility";
import {getAllDocks} from "../layout/getAll"; import {getAllDocks} from "../layout/getAll";
import {Dialog} from "../dialog"; import {Dialog} from "../dialog";
import {focusByRange} from "../protyle/util/selection"; import {focusByRange} from "../protyle/util/selection";
@ -110,10 +110,10 @@ export const openRecentDocs = () => {
<span class="fn__space"></span> <span class="fn__space"></span>
<div class="fn__flex-center"> <div class="fn__flex-center">
<select class="b3-select" id="recentDocsSort"> <select class="b3-select" id="recentDocsSort">
<option value="viewedAt">${window.siyuan.languages.recentViewed}</option> <option value="viewedAt"${window.siyuan.storage[Constants.LOCAL_RECENT_DOCS].type === "viewedAt" ? " selected" : ""}>${window.siyuan.languages.recentViewed}</option>
<option value="updated">${window.siyuan.languages.recentModified}</option> <option value="updated"${window.siyuan.storage[Constants.LOCAL_RECENT_DOCS].type === "updated" ? " selected" : ""}>${window.siyuan.languages.recentModified}</option>
<option value="openAt">${window.siyuan.languages.recentOpened}</option> <option value="openAt"${window.siyuan.storage[Constants.LOCAL_RECENT_DOCS].type === "openAt" ? " selected" : ""}>${window.siyuan.languages.recentOpened}</option>
<option value="closedAt">${window.siyuan.languages.recentClosed}</option> <option value="closedAt"${window.siyuan.storage[Constants.LOCAL_RECENT_DOCS].type === "closedAt" ? " selected" : ""}>${window.siyuan.languages.recentClosed}</option>
</select> </select>
</div> </div>
</div>`, </div>`,
@ -187,6 +187,8 @@ export const openRecentDocs = () => {
getHTML(newResponse.data, dialog.element, searchElement.value, sortSelect.value as TRecentDocsSort); getHTML(newResponse.data, dialog.element, searchElement.value, sortSelect.value as TRecentDocsSort);
}); });
} }
window.siyuan.storage[Constants.LOCAL_RECENT_DOCS].type = sortSelect.value;
setStorageVal(Constants.LOCAL_RECENT_DOCS, window.siyuan.storage[Constants.LOCAL_RECENT_DOCS]);
}); });
getHTML(response.data, dialog.element); getHTML(response.data, dialog.element);

View file

@ -165,6 +165,7 @@ export abstract class Constants {
public static readonly LOCAL_IMAGES = "local-images"; public static readonly LOCAL_IMAGES = "local-images";
public static readonly LOCAL_EMOJIS = "local-emojis"; public static readonly LOCAL_EMOJIS = "local-emojis";
public static readonly LOCAL_MOVE_PATH = "local-move-path"; public static readonly LOCAL_MOVE_PATH = "local-move-path";
public static readonly LOCAL_RECENT_DOCS = "local-recent-docs";
// dialog // dialog
public static readonly DIALOG_CONFIRM = "dialog-confirm"; public static readonly DIALOG_CONFIRM = "dialog-confirm";

View file

@ -485,6 +485,7 @@ export const getLocalStorage = (cb: () => void) => {
}; };
defaultStorage[Constants.LOCAL_ZOOM] = 1; defaultStorage[Constants.LOCAL_ZOOM] = 1;
defaultStorage[Constants.LOCAL_MOVE_PATH] = {keys: [], k: ""}; defaultStorage[Constants.LOCAL_MOVE_PATH] = {keys: [], k: ""};
defaultStorage[Constants.LOCAL_RECENT_DOCS] = {type: "viewedAt"}; // TRecentDocsSort
[Constants.LOCAL_EXPORTIMG, Constants.LOCAL_SEARCHKEYS, Constants.LOCAL_PDFTHEME, Constants.LOCAL_BAZAAR, [Constants.LOCAL_EXPORTIMG, Constants.LOCAL_SEARCHKEYS, Constants.LOCAL_PDFTHEME, Constants.LOCAL_BAZAAR,
Constants.LOCAL_EXPORTWORD, Constants.LOCAL_EXPORTPDF, Constants.LOCAL_DOCINFO, Constants.LOCAL_FONTSTYLES, Constants.LOCAL_EXPORTWORD, Constants.LOCAL_EXPORTPDF, Constants.LOCAL_DOCINFO, Constants.LOCAL_FONTSTYLES,
@ -492,7 +493,7 @@ export const getLocalStorage = (cb: () => void) => {
Constants.LOCAL_PLUGINTOPUNPIN, Constants.LOCAL_SEARCHASSET, Constants.LOCAL_FLASHCARD, Constants.LOCAL_PLUGINTOPUNPIN, Constants.LOCAL_SEARCHASSET, Constants.LOCAL_FLASHCARD,
Constants.LOCAL_DIALOGPOSITION, Constants.LOCAL_SEARCHUNREF, Constants.LOCAL_HISTORY, Constants.LOCAL_DIALOGPOSITION, Constants.LOCAL_SEARCHUNREF, Constants.LOCAL_HISTORY,
Constants.LOCAL_OUTLINE, Constants.LOCAL_FILEPOSITION, Constants.LOCAL_FILESPATHS, Constants.LOCAL_IMAGES, Constants.LOCAL_OUTLINE, Constants.LOCAL_FILEPOSITION, Constants.LOCAL_FILESPATHS, Constants.LOCAL_IMAGES,
Constants.LOCAL_PLUGIN_DOCKS, Constants.LOCAL_EMOJIS, Constants.LOCAL_MOVE_PATH].forEach((key) => { Constants.LOCAL_PLUGIN_DOCKS, Constants.LOCAL_EMOJIS, Constants.LOCAL_MOVE_PATH, Constants.LOCAL_RECENT_DOCS].forEach((key) => {
if (typeof response.data[key] === "string") { if (typeof response.data[key] === "string") {
try { try {
const parseData = JSON.parse(response.data[key]); const parseData = JSON.parse(response.data[key]);