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

feature: 可配置 启动软件时是否打开窗口 #345

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
1 change: 1 addition & 0 deletions packages/core/src/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ module.exports = {
// 个人远程配置地址
personalUrl: ''
},
startOpenWindow: true, // 启动时是否打开窗口:true=打开窗口, false=隐藏窗口
theme: 'dark', // 主题:light=亮色, dark=暗色
autoChecked: true, // 是否自动检查更新
skipPreRelease: true, // 是否忽略预发布版本
Expand Down
25 changes: 16 additions & 9 deletions packages/gui/src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ function setTray () {
// 系统托盘图标目录
label: 'DevTools',
click: () => {
win.webContents.openDevTools()
try {
win.webContents.openDevTools()
} catch (e) {
log.error('win.webContents.openDevTools() error:', e)
}
}
},
{
Expand Down Expand Up @@ -234,17 +238,20 @@ function setDock () {
app.disableHardwareAcceleration() // 禁用gpu

// 开启后是否默认隐藏window
let startHideWindow = false
if (process.argv) {
let startHideWindow = !DevSidecar.api.config.get().app.startOpenWindow
if (app.getLoginItemSettings().wasOpenedAsHidden) {
startHideWindow = true
} else if (process.argv) {
const args = minimist(process.argv)
if (args.hideWindow) {
log.info('start args:', args)

// 通过启动参数,判断是否隐藏窗口
const hideWindowArg = args.hideWindow + ''
if (hideWindowArg === 'true' || hideWindowArg === '1') {
startHideWindow = true
} else if (hideWindowArg === 'false' || hideWindowArg === '0') {
startHideWindow = false
}

log.info('start args:', args)
}
if (app.getLoginItemSettings().wasOpenedAsHidden) {
startHideWindow = true
}
log.info('start hide window:', startHideWindow, app.getLoginItemSettings())

Expand Down
13 changes: 13 additions & 0 deletions packages/gui/src/view/pages/setting.vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,19 @@
点击窗口右上角关闭按钮的效果
</div>
</a-form-item>
<a-form-item label="启动时打开窗口" :label-col="labelCol" :wrapper-col="wrapperCol">
<a-radio-group v-model="config.app.startOpenWindow" default-value="true" button-style="solid">
<a-radio-button :value="true">
打开窗口
</a-radio-button>
<a-radio-button :value="false">
隐藏窗口
</a-radio-button>
</a-radio-group>
<div class="form-help">
启动软件时,是否打开窗口。提示:如果设置为隐藏窗口,可点击系统托盘小图标打开窗口。
</div>
</a-form-item>
<hr/>
<a-form-item label="自动检查更新" :label-col="labelCol" :wrapper-col="wrapperCol">
<a-radio-group v-model="config.app.autoChecked" default-value="light" button-style="solid">
Expand Down