Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(window): 增加记忆化窗口 #513

Merged
merged 1 commit into from
Jun 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 23 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"dateformat": "^5.0.3",
"electron-localshortcut": "^3.2.1",
"electron-store": "^8.1.0",
"electron-window-state": "^5.0.3",
"ficus": "^0.0.4",
"force-graph": "1.35.1",
"html2canvas": "^1.4.1",
Expand Down Expand Up @@ -132,33 +133,31 @@
"mac": {
"icon": "build/icon.png",
"fileAssociations": [
{
"ext": [
"md"
]
}
],
"extendInfo": {
"CFBundleDocumentTypes": [
{
"CFBundleTypeName": "Markdown Document",
"CFBundleTypeRole": "Editor",
"LSHandlerRank": "Owner",
"LSItemContentTypes":
[
"com.apple.dt.document.markdown"
]
},
{
"CFBundleTypeName": "Folder",
"CFBundleTypeRole": "Viewer",
"LSHandlerRank": "None",
"LSItemContentTypes":
[
"public.folder"
"ext": [
"md"
]
}
]
],
"extendInfo": {
"CFBundleDocumentTypes": [
{
"CFBundleTypeName": "Markdown Document",
"CFBundleTypeRole": "Editor",
"LSHandlerRank": "Owner",
"LSItemContentTypes": [
"com.apple.dt.document.markdown"
]
},
{
"CFBundleTypeName": "Folder",
"CFBundleTypeRole": "Viewer",
"LSHandlerRank": "None",
"LSItemContentTypes": [
"public.folder"
]
}
]
}
}
}
15 changes: 13 additions & 2 deletions src/main/windows/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { createProtocol } from 'vue-cli-plugin-electron-builder/lib'
import path from 'path'
import { isOsx, isDevelopment } from '../config'
import BaseWindow from './base'
import windowStateKeeper from 'electron-window-state'

class WindowsManager {
constructor (preferences, menu, keyBinding) {
Expand Down Expand Up @@ -66,10 +67,17 @@ class WindowsManager {
}

async _createWindow () {
const mainWindowState = windowStateKeeper({
defaultWidth: 1200,
defaultHeight: 800
})
const { x, y, width, height } = mainWindowState
// Create the browser window.
const win = new BrowserWindow({
width: 800,
height: 600,
x,
y,
width,
height,
frame: false,
titleBarStyle: 'hiddenInset',
trafficLightPosition: { x: 5, y: 11 },
Expand All @@ -81,6 +89,7 @@ class WindowsManager {
contextIsolation: !process.env.ELECTRON_NODE_INTEGRATION
}
})

if (process.env.WEBPACK_DEV_SERVER_URL) {
// Load the url of the dev server if in development mode
await win.loadURL(process.env.WEBPACK_DEV_SERVER_URL)
Expand Down Expand Up @@ -139,6 +148,8 @@ class WindowsManager {
}
}
})

mainWindowState.manage(win)
return win
}

Expand Down
16 changes: 12 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6092,6 +6092,14 @@ electron-to-chromium@^1.4.284:
resolved "https://mirrors.cloud.tencent.com/npm/electron-to-chromium/-/electron-to-chromium-1.4.371.tgz#393983ef087268a20c926a89be30e9f0bfc803b0"
integrity sha512-jlBzY4tFcJaiUjzhRTCWAqRvTO/fWzjA3Bls0mykzGZ7zvcMP7h05W6UcgzfT9Ca1SW2xyKDOFRyI0pQeRNZGw==

electron-window-state@^5.0.3:
version "5.0.3"
resolved "https://mirrors.cloud.tencent.com/npm/electron-window-state/-/electron-window-state-5.0.3.tgz#4f36d09e3f953d87aff103bf010f460056050aa8"
integrity sha512-1mNTwCfkolXl3kMf50yW3vE2lZj0y92P/HYWFBrb+v2S/pCka5mdwN3cagKm458A7NjndSwijynXgcLWRodsVg==
dependencies:
jsonfile "^4.0.0"
mkdirp "^0.5.1"

[email protected]:
version "13.6.9"
resolved "https://mirrors.cloud.tencent.com/npm/electron/-/electron-13.6.9.tgz#7bd83cc1662ceaaa09dcd132a7b507cec888b028"
Expand Down Expand Up @@ -6838,10 +6846,10 @@ fflate@^0.4.8:
resolved "https://mirrors.cloud.tencent.com/npm/fflate/-/fflate-0.4.8.tgz#f90b82aefbd8ac174213abb338bd7ef848f0f5ae"
integrity sha512-FJqqoDBR00Mdj9ppamLa/Y7vxm+PRmNWA67N846RvsoYVMKB4q3y/de5PA7gUmRMYK/8CMz2GDZQmCRN1wBcWA==

[email protected].28:
version "1.1.28"
resolved "https://mirrors.cloud.tencent.com/npm/ficus-editor/-/ficus-editor-1.1.28.tgz#30e1a145c93407323bfff8704abf88d6b59b58f7"
integrity sha512-JVMRperz2HmKyKkAwHt/0DZe10/tcM5aGDmB8AmK0E9KnE8ahbTvxNOF1C9fgod70hRK/6fEyWOHvfhJuXodvg==
[email protected].29:
version "1.1.29"
resolved "https://mirrors.cloud.tencent.com/npm/ficus-editor/-/ficus-editor-1.1.29.tgz#34703c5fad542f62ec2154b49b92cd3f717d0ca9"
integrity sha512-nTM/f8Re3eC6lUVhHNaxdJY+omIyukX/fsGFGN6ScIhCxUCko89Qxy3HLreEXsOZyVqYhnx/lEIMH56exPDaTg==
dependencies:
diff-match-patch "^1.0.5"

Expand Down