diff --git a/app/src/config/appearance.ts b/app/src/config/appearance.ts index a0fb4493b..6d979c1f2 100644 --- a/app/src/config/appearance.ts +++ b/app/src/config/appearance.ts @@ -244,7 +244,7 @@ export const appearance = { }); }); }, - onSetappearance(data: IAppearance) { + onSetappearance(data: Config.IAppearance) { if (data.lang !== window.siyuan.config.appearance.lang) { exportLayout({ cb() { diff --git a/app/src/config/editor.ts b/app/src/config/editor.ts index 0c0ac0b09..d5e2ffe9e 100644 --- a/app/src/config/editor.ts +++ b/app/src/config/editor.ts @@ -349,7 +349,7 @@ export const editor = { }); }); }, - _onSetEditor: (editorData: IEditor) => { + _onSetEditor: (editorData: Config.IEditor) => { const changeReadonly = editorData.readOnly !== window.siyuan.config.editor.readOnly; if (changeReadonly) { editor.setReadonly(editorData.readOnly); diff --git a/app/src/config/exportConfig.ts b/app/src/config/exportConfig.ts index 392a355f0..f25b5e895 100644 --- a/app/src/config/exportConfig.ts +++ b/app/src/config/exportConfig.ts @@ -254,7 +254,7 @@ export const exportConfig = { }); /// #endif }, - onSetexport: (data: IExport) => { + onSetexport: (data: Config.IExport) => { window.siyuan.config.export = data; } }; diff --git a/app/src/config/fileTree.ts b/app/src/config/fileTree.ts index edfc1065a..4a93810e4 100644 --- a/app/src/config/fileTree.ts +++ b/app/src/config/fileTree.ts @@ -121,7 +121,7 @@ export const fileTree = { }); }); }, - onSetfiletree: (fileTree: IFileTree) => { + onSetfiletree: (fileTree: Config.IFileTree) => { window.siyuan.config.fileTree = fileTree; } }; diff --git a/app/src/config/keymap.ts b/app/src/config/keymap.ts index c7b54e200..277aa97bd 100644 --- a/app/src/config/keymap.ts +++ b/app/src/config/keymap.ts @@ -185,7 +185,7 @@ export const keymap = { `; }, _setkeymap(app: App) { - const data: IKeymap = JSON.parse(JSON.stringify(Constants.SIYUAN_KEYMAP)); + const data: Config.IKeymap = JSON.parse(JSON.stringify(Constants.SIYUAN_KEYMAP)); keymap.element.querySelectorAll("label.b3-list-item input").forEach((item) => { const keys = item.getAttribute("data-key").split(Constants.ZWSP); const newHotkey = item.getAttribute("data-value"); diff --git a/app/src/constants.ts b/app/src/constants.ts index 3b2bc981e..929dbe839 100644 --- a/app/src/constants.ts +++ b/app/src/constants.ts @@ -286,7 +286,7 @@ export abstract class Constants { // "⌘", "⇧", "⌥", "⌃" // "⌘A", "⌘X", "⌘C", "⌘V", "⌘-", "⌘=", "⌘0", "⇧⌘V", "⌘/", "⇧↑", "⇧↓", "⇧→", "⇧←", "⇧⇥", "⌃D", "⇧⌘→", "⇧⌘←", // "⌘Home", "⌘End", "⇧↩", "↩", "PageUp", "PageDown", "⌫", "⌦", "Escape" 不可自定义 - public static readonly SIYUAN_KEYMAP: IKeymap = { + public static readonly SIYUAN_KEYMAP: Config.IKeymap = { general: { mainMenu: {default: "⌥\\", custom: "⌥\\"}, commandPanel: {default: "⌥⇧P", custom: "⌥⇧P"}, diff --git a/app/src/types/config.d.ts b/app/src/types/config.d.ts index 27dfd36ae..7d6169a5c 100644 --- a/app/src/types/config.d.ts +++ b/app/src/types/config.d.ts @@ -1,16 +1,16 @@ /** * Copyright (C) 2023 SiYuan Community - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. - * + * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ @@ -65,6 +65,7 @@ declare namespace Config { openHelp: boolean; /** * Whether it is running in read-only mode + * 全局只读 */ readonly: boolean; repo: IRepo; @@ -133,6 +134,7 @@ declare namespace Config { apiModel: TOpenAIModel; /** * API Provider + * OpenAI, Azure */ apiProvider: APIProvider; /** @@ -1191,8 +1193,8 @@ declare namespace Config { /** * Cloud storage service provider * - `0`: SiYuan official cloud storage service - * - `1`: Object storage service compatible with S3 protocol - * - `2`: Network storage service using WebDAV protocol + * - `2`: Object storage service compatible with S3 protocol + * - `3`: Network storage service using WebDAV protocol */ provider: number; s3: ISyncS3; diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.ts index e5f1e2aa5..83eef2c13 100644 --- a/app/src/types/index.d.ts +++ b/app/src/types/index.d.ts @@ -607,61 +607,6 @@ interface ITab { callback?: (tab: import("../layout/Tab").Tab) => void } -interface IExport { - fileAnnotationRefMode: number - blockRefMode: number - blockEmbedMode: number - blockRefTextLeft: string - blockRefTextRight: string - tagOpenMarker: string - tagCloseMarker: string - pandocBin: string - paragraphBeginningSpace: boolean; - addTitle: boolean; - markdownYFM: boolean; - pdfFooter: string; - pdfWatermarkStr: string; - pdfWatermarkDesc: string; - imageWatermarkStr: string; - imageWatermarkDesc: string; - docxTemplate: string; -} - -interface IEditor { - justify: boolean; - fontSizeScrollZoom: boolean; - rtl: boolean; - readOnly: boolean; - listLogicalOutdent: boolean; - listItemDotNumberClickFocus: boolean; - spellcheck: boolean; - onlySearchForDoc: boolean; - katexMacros: string; - fullWidth: boolean; - floatWindowMode: number; - dynamicLoadBlocks: number; - fontSize: number; - generateHistoryInterval: number; - historyRetentionDays: number; - codeLineWrap: boolean; - displayBookmarkIcon: boolean; - displayNetImgMark: boolean; - codeSyntaxHighlightLineNum: boolean; - embedBlockBreadcrumb: boolean; - plantUMLServePath: string; - codeLigatures: boolean; - codeTabSpaces: number; - fontFamily: string; - virtualBlockRef: boolean; - virtualBlockRefExclude: string; - virtualBlockRefInclude: string; - blockRefDynamicAnchorTextMaxLen: number; - backlinkExpandCount: number; - backmentionExpandCount: number; - - emoji: string[]; -} - interface IWebSocketData { cmd?: string callback?: string @@ -671,194 +616,6 @@ interface IWebSocketData { sid?: string } -interface IAppearance { - modeOS: boolean, - hideStatusBar: boolean, - themeJS: boolean, - mode: number, // 1 暗黑;0 明亮 - icon: string, - closeButtonBehavior: number // 0:退出,1:最小化到托盘 - codeBlockThemeDark: string - codeBlockThemeLight: string - themeDark: string - themeLight: string - icons: string[] - lang: string - iconVer: string - themeVer: string - lightThemes: string[] - darkThemes: string[] -} - -interface IFileTree { - closeTabsOnStart: boolean - alwaysSelectOpenedFile: boolean - openFilesUseCurrentTab: boolean - removeDocWithoutConfirm: boolean - useSingleLineSave: boolean - allowCreateDeeper: boolean - refCreateSavePath: string - docCreateSavePath: string - sort: number - maxOpenTabCount: number - maxListCount: number -} - -interface IAccount { - displayTitle: boolean - displayVIP: boolean -} - -interface IConfig { - snippet: { - enabledCSS: boolean - enabledJS: boolean - } - cloudRegion: number - bazaar: { - trust: boolean - petalDisabled: boolean - } - repo: { - key: string - }, - flashcard: { - newCardLimit: number - reviewCardLimit: number - mark: boolean - list: boolean - superBlock: boolean - heading: boolean - deck: boolean - reviewMode: number - requestRetention: number - maximumInterval: number - weights: string - } - ai: { - openAI: { - apiProvider: string // OpenAI, Azure - apiUserAgent: string - apiBaseURL: string - apiVersion: string - apiKey: string - apiModel: string - apiMaxTokens: number - apiTemperature: number - apiMaxContexts: number - apiProxy: string - apiTimeout: number - }, - } - sync: { - generateConflictDoc: boolean - enabled: boolean - perception: boolean - mode: number - synced: number - stat: string - interval: number - cloudName: string - provider: number // 0 官方同步, 2 S3, 3 WebDAV - s3: { - endpoint: string - pathStyle: boolean - accessKey: string - secretKey: string - bucket: string - region: string - skipTlsVerify: boolean - timeout: number - } - webdav: { - endpoint: string - username: string - password: string - skipTlsVerify: boolean - timeout: number - } - }, - lang: string - api: { - token: string - } - openHelp: boolean - system: { - lockScreenMode: number // 0:手动,1:手动+跟随系统 - networkProxy: { - host: string - port: string - scheme: string - } - name: string - kernelVersion: string - isInsider: boolean - appDir: string - workspaceDir: string - confDir: string - dataDir: string - container: "std" | "android" | "docker" | "ios" - isMicrosoftStore: boolean - os: "windows" | "linux" | "darwin" - osPlatform: string - homeDir: string - xanadu: boolean - udanax: boolean - uploadErrLog: boolean - disableGoogleAnalytics: boolean - downloadInstallPkg: boolean - networkServe: boolean - fixedPort: boolean - autoLaunch: boolean - } - localIPs: string[] - readonly: boolean // 全局只读 - uiLayout: Record - langs: { - label: string, - name: string - }[] - appearance: IAppearance - editor: IEditor, - fileTree: IFileTree - graph: IGraph - keymap: IKeymap - export: IExport - accessAuthCode: string - account: IAccount - tag: { - sort: number - } - search: ISearchType & { - name: boolean - alias: boolean - memo: boolean - indexAssetPath: boolean - ial: boolean - limit: number - caseSensitive: boolean - backlinkMentionName: boolean - backlinkMentionAlias: boolean - backlinkMentionAnchor: boolean - backlinkMentionDoc: boolean - backlinkMentionKeywordsLimit: boolean - virtualRefName: boolean - virtualRefAlias: boolean - virtualRefAnchor: boolean - virtualRefDoc: boolean - }, - stat: { - treeCount: number - cTreeCount: number - blockCount: number - cBlockCount: number - dataSize: number - cDataSize: number - assetsSize: number - cAssetsSize: number - } -} - interface IGraphCommon { d3: { centerStrength: number @@ -884,44 +641,6 @@ interface IGraphCommon { } } -interface IGraph { - global: { - minRefs: number - dailyNote: boolean - } & IGraphCommon - local: { - dailyNote: boolean - } & IGraphCommon -} - -interface IKeymap { - plugin: { - [key: string]: { - [key: string]: IKeymapItem - } - } - general: { - [key: string]: IKeymapItem - } - editor: { - general: { - [key: string]: IKeymapItem - } - insert: { - [key: string]: IKeymapItem - } - heading: { - [key: string]: IKeymapItem - } - list: { - [key: string]: IKeymapItem - } - table: { - [key: string]: IKeymapItem - } - } -} - interface IKeymapItem { default: string, custom: string diff --git a/app/src/util/assets.ts b/app/src/util/assets.ts index cf1ca75b8..dd11c36bd 100644 --- a/app/src/util/assets.ts +++ b/app/src/util/assets.ts @@ -9,7 +9,7 @@ import {fetchPost} from "./fetch"; import {appearance} from "../config/appearance"; import {isInAndroid, isInIOS} from "../protyle/util/compatibility"; -const loadThirdIcon = (iconURL: string, data: IAppearance) => { +const loadThirdIcon = (iconURL: string, data: Config.IAppearance) => { addScript(iconURL, "iconDefaultScript").then(() => { if (!["ant", "material"].includes(data.icon)) { const iconScriptElement = document.getElementById("iconScript"); @@ -21,7 +21,7 @@ const loadThirdIcon = (iconURL: string, data: IAppearance) => { }); }; -export const loadAssets = (data: IAppearance) => { +export const loadAssets = (data: Config.IAppearance) => { const htmlElement = document.getElementsByTagName("html")[0]; htmlElement.setAttribute("lang", window.siyuan.config.appearance.lang); htmlElement.setAttribute("data-theme-mode", getThemeMode());