From 16216796b6aaf8a00bad40bbe13473e7be18d710 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Fri, 2 Jun 2023 19:49:44 +0800 Subject: [PATCH] :art: mobile test --- app/src/layout/Model.ts | 8 +++++-- app/src/types/index.d.ts | 52 ++++++++++++++++++++-------------------- 2 files changed, 32 insertions(+), 28 deletions(-) diff --git a/app/src/layout/Model.ts b/app/src/layout/Model.ts index 401ecee63..b0cd5cfa2 100644 --- a/app/src/layout/Model.ts +++ b/app/src/layout/Model.ts @@ -46,7 +46,7 @@ export class Model { if (logElement) { // 内核中断后无法 catch fetch 请求错误,重连会导致无法执行 transactionsTimeout reloadSync(this.app, {upsertRootIDs: [], removeRootIDs: []}); - window.siyuan.dialogs.find(item =>{ + window.siyuan.dialogs.find(item => { if (item.element.id === "errorLog") { item.destroy(); return true; @@ -61,6 +61,10 @@ export class Model { } }; ws.onclose = (ev) => { + if (!window.errorStack) { + window.errorStack = [] + } + window.errorStack.push({onclose: ev}) if (0 <= ev.reason.indexOf("unauthenticated")) { return; } @@ -80,7 +84,7 @@ export class Model { if (!window.errorStack) { window.errorStack = [] } - window.errorStack.push(err) + window.errorStack.push({"onerror": err}) if (err.target.url.endsWith("&type=main") && err.target.readyState === 3) { kernelError(); } diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.ts index 1eb5ee777..5ddd63ae0 100644 --- a/app/src/types/index.d.ts +++ b/app/src/types/index.d.ts @@ -28,7 +28,7 @@ type TEventBus = "ws-main" | "click-blockicon" | "click-editorcontent" | "click- declare module "blueimp-md5" interface Window { - errorStack: any[] + errorStack: any dataLayer: any[] siyuan: ISiyuan webkit: any @@ -278,7 +278,7 @@ interface IObject { [key: string]: string; } -declare interface ILayoutJSON extends ILayoutOptions { +interface ILayoutJSON extends ILayoutOptions { scrollAttr?: IScrollAttr, instance?: string, width?: string, @@ -299,7 +299,7 @@ declare interface ILayoutJSON extends ILayoutOptions { children?: ILayoutJSON[] | ILayoutJSON } -declare interface IDockTab { +interface IDockTab { type: string; size: { width: number, height: number } show: boolean @@ -309,7 +309,7 @@ declare interface IDockTab { hotkeyLangId?: string // 常量中无法存变量 } -declare interface ICommand { +interface ICommand { langKey: string, // 多语言 key hotkey: string, customHotkey?: string, @@ -319,14 +319,14 @@ declare interface ICommand { dockCallback?: (element: HTMLElement) => void } -declare interface IPluginData { +interface IPluginData { name: string, js: string, css: string, i18n: IObject } -declare interface IPluginDockTab { +interface IPluginDockTab { position: TPluginDockPosition, size: { width: number, height: number }, icon: string, @@ -336,7 +336,7 @@ declare interface IPluginDockTab { show?: boolean } -declare interface IOpenFileOptions { +interface IOpenFileOptions { app: import("../index").App, searchData?: ISearchOption, // 搜索必填 // card 和自定义页签 必填 @@ -365,7 +365,7 @@ declare interface IOpenFileOptions { afterOpen?: () => void // 打开后回调 } -declare interface ILayoutOptions { +interface ILayoutOptions { direction?: TDirection; size?: string resize?: TDirection @@ -373,7 +373,7 @@ declare interface ILayoutOptions { element?: HTMLElement } -declare interface ITab { +interface ITab { icon?: string docIcon?: string title?: string @@ -381,7 +381,7 @@ declare interface ITab { callback?: (tab: import("../layout/Tab").Tab) => void } -declare interface IExport { +interface IExport { fileAnnotationRefMode: number blockRefMode: number blockEmbedMode: number @@ -396,7 +396,7 @@ declare interface IExport { pdfFooter: string; } -declare interface IEditor { +interface IEditor { justify: boolean; fontSizeScrollZoom: boolean; rtl: boolean; @@ -430,7 +430,7 @@ declare interface IEditor { emoji: string[]; } -declare interface IWebSocketData { +interface IWebSocketData { cmd?: string callback?: string data?: any @@ -439,7 +439,7 @@ declare interface IWebSocketData { sid?: string } -declare interface IAppearance { +interface IAppearance { modeOS: boolean, hideStatusBar: boolean, themeJS: boolean, @@ -458,7 +458,7 @@ declare interface IAppearance { darkThemes: string[] } -declare interface IFileTree { +interface IFileTree { closeTabsOnStart: boolean alwaysSelectOpenedFile: boolean openFilesUseCurrentTab: boolean @@ -471,12 +471,12 @@ declare interface IFileTree { maxListCount: number } -declare interface IAccount { +interface IAccount { displayTitle: boolean displayVIP: boolean } -declare interface IConfig { +interface IConfig { bazaar: { trust: boolean } @@ -616,7 +616,7 @@ declare interface IConfig { } } -declare interface IGraphCommon { +interface IGraphCommon { d3: { centerStrength: number collideRadius: number @@ -641,7 +641,7 @@ declare interface IGraphCommon { } } -declare interface IGraph { +interface IGraph { global: { minRefs: number dailyNote: boolean @@ -651,7 +651,7 @@ declare interface IGraph { } & IGraphCommon } -declare interface IKeymap { +interface IKeymap { plugin: { [key: string]: { [key: string]: IKeymapItem @@ -667,12 +667,12 @@ declare interface IKeymap { } } -declare interface IKeymapItem { +interface IKeymapItem { default: string, custom: string } -declare interface IFile { +interface IFile { icon: string; name1: string; alias: string; @@ -691,7 +691,7 @@ declare interface IFile { subFileCount: number; } -declare interface IBlockTree { +interface IBlockTree { box: string, nodeType: string, hPath: string, @@ -707,7 +707,7 @@ declare interface IBlockTree { children?: IBlockTree[] } -declare interface IBlock { +interface IBlock { riffCardReps?: number // 闪卡复习次数 depth?: number, box?: string; @@ -730,7 +730,7 @@ declare interface IBlock { ial: IObject } -declare interface IModels { +interface IModels { editor: import("../editor").Editor [], graph: import("../layout/dock/Graph").Graph[], outline: import("../layout/dock/Outline").Outline[] @@ -744,7 +744,7 @@ declare interface IModels { custom: import("../layout/dock/Custom").Custom[] } -declare interface IMenu { +interface IMenu { label?: string, click?: (element: HTMLElement) => void, type?: "separator" | "submenu" | "readonly", @@ -761,7 +761,7 @@ declare interface IMenu { element?: HTMLElement } -declare interface IBazaarItem { +interface IBazaarItem { incompatible?: boolean // 仅 plugin enabled: boolean preferredName: string