mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
🎨 Support minimize the main window after auto launch on Windows/macOS https://github.com/siyuan-note/siyuan/issues/11145
This commit is contained in:
parent
03a6c15d70
commit
b64a9a3ad2
10 changed files with 75 additions and 17 deletions
|
|
@ -1,4 +1,7 @@
|
||||||
{
|
{
|
||||||
|
"autoLaunchMode0": "Do not launch automatically",
|
||||||
|
"autoLaunchMode1": "Auto launch after booting",
|
||||||
|
"autoLaunchMode2": "Auto launch and minimize the interface after booting",
|
||||||
"editorMarkdownInlineSup": "Markdown inline superscript syntax",
|
"editorMarkdownInlineSup": "Markdown inline superscript syntax",
|
||||||
"editorMarkdownInlineSupTip": "After enabling, <code class='fn__code'>^foo^</code> inline superscript syntax input will be supported",
|
"editorMarkdownInlineSupTip": "After enabling, <code class='fn__code'>^foo^</code> inline superscript syntax input will be supported",
|
||||||
"editorMarkdownInlineSub": "Markdown inline subscript syntax",
|
"editorMarkdownInlineSub": "Markdown inline subscript syntax",
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,7 @@
|
||||||
{
|
{
|
||||||
|
"autoLaunchMode0": "No iniciar automáticamente",
|
||||||
|
"autoLaunchMode1": "Inicio automático después del arranque",
|
||||||
|
"autoLaunchMode2": "Iniciar automáticamente y minimizar la interfaz después del arranque",
|
||||||
"editorMarkdownInlineSup": "Sintaxis de superíndice en línea de Markdown",
|
"editorMarkdownInlineSup": "Sintaxis de superíndice en línea de Markdown",
|
||||||
"editorMarkdownInlineSupTip": "Después de habilitar, se admitirá la entrada de sintaxis de superíndice en línea <code class='fn__code'>^foo^</code>",
|
"editorMarkdownInlineSupTip": "Después de habilitar, se admitirá la entrada de sintaxis de superíndice en línea <code class='fn__code'>^foo^</code>",
|
||||||
"editorMarkdownInlineSub": "Sintaxis del subíndice en línea de Markdown",
|
"editorMarkdownInlineSub": "Sintaxis del subíndice en línea de Markdown",
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,7 @@
|
||||||
{
|
{
|
||||||
|
"autoLaunchMode0": "Ne pas lancer automatiquement",
|
||||||
|
"autoLaunchMode1": "Lancement automatique après le démarrage",
|
||||||
|
"autoLaunchMode2": "Lancement automatique et réduction de l'interface après le démarrage",
|
||||||
"editorMarkdownInlineSup": "Syntaxe exposant Markdown en ligne",
|
"editorMarkdownInlineSup": "Syntaxe exposant Markdown en ligne",
|
||||||
"editorMarkdownInlineSupTip": "Après l'activation, la saisie de la syntaxe en exposant <code class='fn__code'>^foo^</code> en ligne sera prise en charge",
|
"editorMarkdownInlineSupTip": "Après l'activation, la saisie de la syntaxe en exposant <code class='fn__code'>^foo^</code> en ligne sera prise en charge",
|
||||||
"editorMarkdownInlineSub": "Syntaxe d'indice en ligne Markdown",
|
"editorMarkdownInlineSub": "Syntaxe d'indice en ligne Markdown",
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,7 @@
|
||||||
{
|
{
|
||||||
|
"autoLaunchMode0": "不自動啟動",
|
||||||
|
"autoLaunchMode1": "開機自動啟動",
|
||||||
|
"autoLaunchMode2": "開機自動啟動並最小化介面",
|
||||||
"editorMarkdownInlineSup": "Markdown 行級上標語法",
|
"editorMarkdownInlineSup": "Markdown 行級上標語法",
|
||||||
"editorMarkdownInlineSupTip": "啟用後將支援 <code class='fn__code'>^foo^</code> 行級上標語法輸入",
|
"editorMarkdownInlineSupTip": "啟用後將支援 <code class='fn__code'>^foo^</code> 行級上標語法輸入",
|
||||||
"editorMarkdownInlineSub": "Markdown 行級下標語法",
|
"editorMarkdownInlineSub": "Markdown 行級下標語法",
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,7 @@
|
||||||
{
|
{
|
||||||
|
"autoLaunchMode0": "不自动启动",
|
||||||
|
"autoLaunchMode1": "开机后自动启动",
|
||||||
|
"autoLaunchMode2": "开机后自动启动并最小化界面",
|
||||||
"editorMarkdownInlineSup": "Markdown 行级上标语法",
|
"editorMarkdownInlineSup": "Markdown 行级上标语法",
|
||||||
"editorMarkdownInlineSupTip": "启用后将支持 <code class='fn__code'>^foo^</code> 行级上标语法输入",
|
"editorMarkdownInlineSupTip": "启用后将支持 <code class='fn__code'>^foo^</code> 行级上标语法输入",
|
||||||
"editorMarkdownInlineSub": "Markdown 行级下标语法",
|
"editorMarkdownInlineSub": "Markdown 行级下标语法",
|
||||||
|
|
|
||||||
|
|
@ -230,7 +230,7 @@ const writeLog = (out) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const boot = () => {
|
const initMainWindow = () => {
|
||||||
let windowStateInitialized = true;
|
let windowStateInitialized = true;
|
||||||
// 恢复主窗体状态
|
// 恢复主窗体状态
|
||||||
let oldWindowState = {};
|
let oldWindowState = {};
|
||||||
|
|
@ -1019,7 +1019,7 @@ app.whenReady().then(() => {
|
||||||
if (!foundWorkspace) {
|
if (!foundWorkspace) {
|
||||||
initKernel(data.workspace, "", "").then((isSucc) => {
|
initKernel(data.workspace, "", "").then((isSucc) => {
|
||||||
if (isSucc) {
|
if (isSucc) {
|
||||||
boot();
|
initMainWindow();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -1149,7 +1149,7 @@ app.whenReady().then(() => {
|
||||||
ipcMain.on("siyuan-first-init", (event, data) => {
|
ipcMain.on("siyuan-first-init", (event, data) => {
|
||||||
initKernel(data.workspace, "", data.lang).then((isSucc) => {
|
initKernel(data.workspace, "", data.lang).then((isSucc) => {
|
||||||
if (isSucc) {
|
if (isSucc) {
|
||||||
boot();
|
initMainWindow();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
firstOpenWindow.destroy();
|
firstOpenWindow.destroy();
|
||||||
|
|
@ -1173,7 +1173,7 @@ app.whenReady().then(() => {
|
||||||
}
|
}
|
||||||
initKernel(workspace, port, "").then((isSucc) => {
|
initKernel(workspace, port, "").then((isSucc) => {
|
||||||
if (isSucc) {
|
if (isSucc) {
|
||||||
boot();
|
initMainWindow();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -1280,7 +1280,7 @@ app.on("second-instance", (event, argv) => {
|
||||||
if (workspace) {
|
if (workspace) {
|
||||||
initKernel(workspace, port, "").then((isSucc) => {
|
initKernel(workspace, port, "").then((isSucc) => {
|
||||||
if (isSucc) {
|
if (isSucc) {
|
||||||
boot();
|
initMainWindow();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
|
|
@ -1306,7 +1306,7 @@ app.on("activate", () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (BrowserWindow.getAllWindows().length === 0) {
|
if (BrowserWindow.getAllWindows().length === 0) {
|
||||||
boot();
|
initMainWindow();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,14 +16,18 @@ import {setKey} from "../sync/syncGuide";
|
||||||
export const about = {
|
export const about = {
|
||||||
element: undefined as Element,
|
element: undefined as Element,
|
||||||
genHTML: () => {
|
genHTML: () => {
|
||||||
return `<label class="fn__flex b3-label${isBrowser() || window.siyuan.config.system.isMicrosoftStore || "std" !== window.siyuan.config.system.container || "linux" === window.siyuan.config.system.os ? " fn__none" : ""}">
|
return `<div class="fn__flex b3-label config__item${isBrowser() || window.siyuan.config.system.isMicrosoftStore || "std" !== window.siyuan.config.system.container || "linux" === window.siyuan.config.system.os ? " fn__none" : ""}">
|
||||||
<div class="fn__flex-1">
|
<div class="fn__flex-1">
|
||||||
${window.siyuan.languages.autoLaunch}
|
${window.siyuan.languages.autoLaunch}
|
||||||
<div class="b3-label__text">${window.siyuan.languages.autoLaunchTip}</div>
|
<div class="b3-label__text">${window.siyuan.languages.autoLaunchTip}</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="fn__space"></div>
|
<span class="fn__space"></span>
|
||||||
<input class="b3-switch fn__flex-center" id="autoLaunch" type="checkbox"${window.siyuan.config.system.autoLaunch ? " checked" : ""}>
|
<select class="b3-select fn__flex-center fn__size200" id="autoLaunch">
|
||||||
</label>
|
<option value="0" ${window.siyuan.config.system.autoLaunch === 0 ? "selected" : ""}>${window.siyuan.languages.autoLaunchMode0}</option>
|
||||||
|
<option value="1" ${window.siyuan.config.system.autoLaunch === 1 ? "selected" : ""}>${window.siyuan.languages.autoLaunchMode1}</option>
|
||||||
|
<option value="2" ${window.siyuan.config.system.autoLaunch === 2 ? "selected" : ""}>${window.siyuan.languages.autoLaunchMode2}</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
<label class="fn__flex b3-label${isBrowser() || window.siyuan.config.system.isMicrosoftStore || window.siyuan.config.system.container !== "std" ? " fn__none" : ""}">
|
<label class="fn__flex b3-label${isBrowser() || window.siyuan.config.system.isMicrosoftStore || window.siyuan.config.system.container !== "std" ? " fn__none" : ""}">
|
||||||
<div class="fn__flex-1">
|
<div class="fn__flex-1">
|
||||||
${window.siyuan.languages.autoDownloadUpdatePkg}
|
${window.siyuan.languages.autoDownloadUpdatePkg}
|
||||||
|
|
@ -348,9 +352,10 @@ export const about = {
|
||||||
/// #if !BROWSER
|
/// #if !BROWSER
|
||||||
const autoLaunchElement = about.element.querySelector("#autoLaunch") as HTMLInputElement;
|
const autoLaunchElement = about.element.querySelector("#autoLaunch") as HTMLInputElement;
|
||||||
autoLaunchElement.addEventListener("change", () => {
|
autoLaunchElement.addEventListener("change", () => {
|
||||||
fetchPost("/api/system/setAutoLaunch", {autoLaunch: autoLaunchElement.checked}, () => {
|
const autoLaunchMode = parseInt(autoLaunchElement.value)
|
||||||
window.siyuan.config.system.autoLaunch = autoLaunchElement.checked;
|
fetchPost("/api/system/setAutoLaunch", {autoLaunch: autoLaunchMode}, () => {
|
||||||
ipcRenderer.send(Constants.SIYUAN_AUTO_LAUNCH, {openAtLogin: autoLaunchElement.checked});
|
window.siyuan.config.system.autoLaunch = autoLaunchMode;
|
||||||
|
ipcRenderer.send(Constants.SIYUAN_AUTO_LAUNCH, {openAtLogin: 0 != autoLaunchMode});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
/// #endif
|
/// #endif
|
||||||
|
|
|
||||||
5
app/src/types/config.d.ts
vendored
5
app/src/types/config.d.ts
vendored
|
|
@ -1351,8 +1351,11 @@ declare namespace Config {
|
||||||
appDir: string;
|
appDir: string;
|
||||||
/**
|
/**
|
||||||
* Boot automatically
|
* Boot automatically
|
||||||
|
* - `0`: Do not boot automatically
|
||||||
|
* - `1`: Boot automatically
|
||||||
|
* - `2`: Boot automatically + Minimize UI
|
||||||
*/
|
*/
|
||||||
autoLaunch: boolean;
|
autoLaunch: number;
|
||||||
/**
|
/**
|
||||||
* The absolute path of the `conf` directory of the current workspace
|
* The absolute path of the `conf` directory of the current workspace
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -421,9 +421,44 @@ func setAutoLaunch(c *gin.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
autoLaunch := arg["autoLaunch"].(bool)
|
autoLaunch := int(arg["autoLaunch"].(float64))
|
||||||
model.Conf.System.AutoLaunch = autoLaunch
|
model.Conf.System.AutoLaunch2 = autoLaunch
|
||||||
model.Conf.Save()
|
model.Conf.Save()
|
||||||
|
|
||||||
|
windowStateConf := filepath.Join(util.ConfDir, "windowState.json")
|
||||||
|
windowState := map[string]interface{}{}
|
||||||
|
if gulu.File.IsExist(windowStateConf) {
|
||||||
|
succ := false
|
||||||
|
const maxRetry = 7
|
||||||
|
for i := 0; i < maxRetry; i++ {
|
||||||
|
data, err := os.ReadFile(windowStateConf)
|
||||||
|
if nil != err {
|
||||||
|
logging.LogErrorf("read [windowState.json] failed [%d/%d]: %s", i, maxRetry, err)
|
||||||
|
time.Sleep(time.Second)
|
||||||
|
} else {
|
||||||
|
if err = gulu.JSON.UnmarshalJSON(data, &windowState); nil != err {
|
||||||
|
logging.LogErrorf("unmarshal [windowState.json] failed: %s", err)
|
||||||
|
} else {
|
||||||
|
succ = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !succ {
|
||||||
|
logging.LogErrorf("read [windowState.json] failed")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
windowState["autoLaunch"] = autoLaunch
|
||||||
|
|
||||||
|
data, err := gulu.JSON.MarshalJSON(windowState)
|
||||||
|
if nil != err {
|
||||||
|
logging.LogErrorf("marshal [windowState.json] failed: %s", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = gulu.File.WriteFileSafer(windowStateConf, data, 0644); nil != err {
|
||||||
|
logging.LogErrorf("create [windowState.json] failed: %s", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func setDownloadInstallPkg(c *gin.Context) {
|
func setDownloadInstallPkg(c *gin.Context) {
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ type System struct {
|
||||||
UploadErrLog bool `json:"uploadErrLog"`
|
UploadErrLog bool `json:"uploadErrLog"`
|
||||||
DisableGoogleAnalytics bool `json:"disableGoogleAnalytics"`
|
DisableGoogleAnalytics bool `json:"disableGoogleAnalytics"`
|
||||||
DownloadInstallPkg bool `json:"downloadInstallPkg"`
|
DownloadInstallPkg bool `json:"downloadInstallPkg"`
|
||||||
AutoLaunch bool `json:"autoLaunch"`
|
AutoLaunch2 int `json:"autoLaunch2"` // 0:不自动启动,1:自动启动,2:自动启动+隐藏主窗口
|
||||||
LockScreenMode int `json:"lockScreenMode"` // 0:手动,1:手动+跟随系统 https://github.com/siyuan-note/siyuan/issues/9087
|
LockScreenMode int `json:"lockScreenMode"` // 0:手动,1:手动+跟随系统 https://github.com/siyuan-note/siyuan/issues/9087
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue