diff --git a/app/.eslintrc.js b/app/.eslintrc.js index 9743aefdb..48cf5feab 100644 --- a/app/.eslintrc.js +++ b/app/.eslintrc.js @@ -9,11 +9,12 @@ module.exports = { 'plugin:@typescript-eslint/recommended', ], rules: { - semi:[2, "always"], - quotes:[2, "double", { "avoidEscape": true }], - 'no-prototype-builtins': "off", - 'no-useless-escape': "off", - 'no-irregular-whitespace': "off", + semi: [2, 'always'], + quotes: [2, 'double', {'avoidEscape': true}], + 'no-prototype-builtins': 'off', + 'no-useless-escape': 'off', + 'no-irregular-whitespace': 'off', + '@typescript-eslint/no-this-alia': 'off', '@typescript-eslint/ban-ts-comment': 'off', '@typescript-eslint/no-var-requires': 'off', '@typescript-eslint/explicit-function-return-type': 'off', diff --git a/app/electron/main.js b/app/electron/main.js index 1c82199d9..3525a5289 100644 --- a/app/electron/main.js +++ b/app/electron/main.js @@ -805,7 +805,7 @@ app.whenReady().then(() => { }) ipcMain.on('siyuan-lock-screen', () => { - workspaces.forEach(item => { + BrowserWindow.getAllWindows().forEach(item => { item.browserWindow.webContents.send('siyuan-lock-screen') }) }) diff --git a/app/src/assets/scss/_reset.scss b/app/src/assets/scss/_reset.scss index 053260050..c0687c61e 100644 --- a/app/src/assets/scss/_reset.scss +++ b/app/src/assets/scss/_reset.scss @@ -67,17 +67,23 @@ body { } } - &.body--window.body--win32 .fullscreen { - & > .protyle-breadcrumb, - & > .block__icons { - padding-right: 126px; + &.body--window { + .fullscreen { + & > .protyle-breadcrumb, + & > .block__icons { + height: 42px; + } } - } - &.body--window .fullscreen { - & > .protyle-breadcrumb, - & > .block__icons { - height: 42px; + &.body--win32 .fullscreen { + & > .protyle-breadcrumb, + & > .block__icons { + padding-right: 126px; + } + } + + &.body--blur .layout-tab-bar { + background-color: var(--b3-toolbar-blur-background); } } } diff --git a/app/src/layout/Wnd.ts b/app/src/layout/Wnd.ts index e63ab4ada..bd30bdaa0 100644 --- a/app/src/layout/Wnd.ts +++ b/app/src/layout/Wnd.ts @@ -146,7 +146,8 @@ export class Wnd { it.style.opacity = ".1"; return; } - if (!event.dataTransfer.types.includes(Constants.SIYUAN_DROP_TAB) || !window.siyuan.dragElement) { + // 不能使用 !window.siyuan.dragElement,因为移动页签到新窗口后,再把主窗口页签拖拽新窗口页签上时,该值为空 + if (!event.dataTransfer.types.includes(Constants.SIYUAN_DROP_TAB)) { return; } event.preventDefault(); @@ -160,10 +161,10 @@ export class Wnd { return true; } }); - if (!newTabHeaderElement && !oldTabHeaderElement.classList.contains("item--pin")) { + if (!newTabHeaderElement && oldTabHeaderElement && !oldTabHeaderElement.classList.contains("item--pin")) { it.classList.add("layout-tab-bar--drag"); } - if (!exitDrag) { + if (!exitDrag && oldTabHeaderElement) { if (oldTabHeaderElement.classList.contains("item--pin")) { return; } @@ -171,6 +172,12 @@ export class Wnd { oldTabHeaderElement.setAttribute("data-clone", "true"); it.append(oldTabHeaderElement); return; + } else if (!exitDrag && !oldTabHeaderElement) { // 拖拽到新窗口 + oldTabHeaderElement = document.createElement("li") + oldTabHeaderElement.style.opacity = "0.1" + oldTabHeaderElement.innerHTML = '' + oldTabHeaderElement.setAttribute("data-clone", "true"); + it.append(oldTabHeaderElement); } if (!newTabHeaderElement) { return; @@ -199,6 +206,7 @@ export class Wnd { }); it.style.opacity = ""; }); + const that = this; this.headersElement.addEventListener("drop", function (event: DragEvent & { target: HTMLElement }) { const it = this as HTMLElement; if (event.dataTransfer.types.includes(Constants.SIYUAN_DROP_FILE)) { @@ -216,7 +224,20 @@ export class Wnd { it.style.opacity = ""; return; } - const oldTab = getInstanceById(event.dataTransfer.getData(Constants.SIYUAN_DROP_TAB)) as Tab; + const tabId = event.dataTransfer.getData(Constants.SIYUAN_DROP_TAB) + let oldTab = getInstanceById(tabId) as Tab; + /// #if !BROWSER + if (!oldTab) { // 从主窗口拖拽到页签新窗口 + JSONToCenter(JSON.parse(event.dataTransfer.getData(Constants.SIYUAN_DROP_TABTOWINDOW)), that); + oldTab = that.children[that.children.length - 1]; + ipcRenderer.send(Constants.SIYUAN_CLOSETAB, tabId); + it.querySelector("li[data-clone='true']").remove(); + that.switchTab(oldTab.headElement); + } + /// #endif + if (!oldTab) { + return; + } it.classList.remove("layout-tab-bar--drag"); const nextTabHeaderElement = (Array.from(it.childNodes).find((item: HTMLElement) => {