mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-20 08:30:12 +01:00
🎨 Windows/macOS 桌面端支持开机启动 https://github.com/siyuan-note/siyuan/issues/6833
This commit is contained in:
parent
ad1924890b
commit
5a4b64464d
9 changed files with 43 additions and 2 deletions
|
|
@ -1,4 +1,6 @@
|
|||
{
|
||||
"autoLaunch": "Automatic launch at boot",
|
||||
"autoLaunchTip": "After enabling, the application will be automatically launched after logging into the operating system",
|
||||
"sortByRankDesc": "Relevance DESC",
|
||||
"sortByRankAsc": "Relevance ASC",
|
||||
"saveCriterion": "Save named criterion",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
{
|
||||
"autoLaunch": "Inicio automático al arrancar",
|
||||
"autoLaunchTip": "Después de habilitar, la aplicación se iniciará automáticamente después de iniciar sesión en el sistema operativo",
|
||||
"sortByRankDesc": "Relevancia DESC",
|
||||
"sortByRankAsc": "Relevancia ASC",
|
||||
"saveCriterion": "Guardar criterio nombrado",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
{
|
||||
"autoLaunch": "Lancement automatique au démarrage",
|
||||
"autoLaunchTip": "Après l'activation, l'application sera automatiquement lancée après la connexion au système d'exploitation",
|
||||
"sortByRankDesc": "DESC de pertinence",
|
||||
"sortByRankAsc": "ASC de pertinence",
|
||||
"saveCriterion": "Enregistrer le critère nommé",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
{
|
||||
"autoLaunch": "開機自動啟動",
|
||||
"autoLaunchTip": "啟用後會在登錄操作系統後自動啟動應用",
|
||||
"sortByRankDesc": "按相關度降序",
|
||||
"sortByRankAsc": "按相關度升序",
|
||||
"saveCriterion": "保存命名查詢",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
{
|
||||
"autoLaunch": "开机自动启动",
|
||||
"autoLaunchTip": "启用后会在登录操作系统后自动启动应用",
|
||||
"sortByRankDesc": "按相关度降序",
|
||||
"sortByRankAsc": "按相关度升序",
|
||||
"saveCriterion": "保存命名查询",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import {Constants} from "../constants";
|
||||
/// #if !BROWSER
|
||||
import {shell} from "electron";
|
||||
import {app, shell} from "electron";
|
||||
import {dialog} from "@electron/remote";
|
||||
/// #endif
|
||||
import {isBrowser} from "../util/functions";
|
||||
|
|
@ -17,7 +17,15 @@ import {setProxy} from "../util/onGetConfig";
|
|||
export const about = {
|
||||
element: undefined as Element,
|
||||
genHTML: () => {
|
||||
return `<label class="fn__flex b3-label${isBrowser() || window.siyuan.config.system.isMicrosoftStore ? " fn__none" : ""}">
|
||||
return `<label class="fn__flex b3-label${isBrowser() || "std" !== window.siyuan.config.system.container || "linux" === window.siyuan.config.system.os ? " fn__none" : ""}">
|
||||
<div class="fn__flex-1">
|
||||
${window.siyuan.languages.autoLaunch}
|
||||
<div class="b3-label__text">${window.siyuan.languages.autoLaunchTip}</div>
|
||||
</div>
|
||||
<div class="fn__space"></div>
|
||||
<input class="b3-switch fn__flex-center" id="autoLaunch" type="checkbox"${window.siyuan.config.system.autoLaunch ? " checked" : ""}>
|
||||
</label>
|
||||
<label class="fn__flex b3-label${isBrowser() || window.siyuan.config.system.isMicrosoftStore ? " fn__none" : ""}">
|
||||
<div class="fn__flex-1">
|
||||
${window.siyuan.languages.autoDownloadUpdatePkg}
|
||||
<div class="b3-label__text">${window.siyuan.languages.autoDownloadUpdatePkgTip}</div>
|
||||
|
|
@ -389,6 +397,13 @@ export const about = {
|
|||
window.siyuan.config.system.downloadInstallPkg = downloadInstallPkgElement.checked;
|
||||
});
|
||||
});
|
||||
const autoLaunchElement = about.element.querySelector("#autoLaunch") as HTMLInputElement;
|
||||
autoLaunchElement.addEventListener("change", () => {
|
||||
fetchPost("/api/system/setAutoLaunch", {autoLaunch: autoLaunchElement.checked}, () => {
|
||||
window.siyuan.config.system.autoLaunch = autoLaunchElement.checked;
|
||||
app.setLoginItemSettings({openAtLogin: autoLaunchElement.checked});
|
||||
});
|
||||
});
|
||||
about.element.querySelector("#aboutConfirm").addEventListener("click", () => {
|
||||
const scheme = (about.element.querySelector("#aboutScheme") as HTMLInputElement).value;
|
||||
const host = (about.element.querySelector("#aboutHost") as HTMLInputElement).value;
|
||||
|
|
|
|||
1
app/src/types/index.d.ts
vendored
1
app/src/types/index.d.ts
vendored
|
|
@ -410,6 +410,7 @@ declare interface IConfig {
|
|||
downloadInstallPkg: boolean
|
||||
networkServe: boolean
|
||||
fixedPort: boolean
|
||||
autoLaunch: boolean
|
||||
}
|
||||
localIPs: string[]
|
||||
readonly: boolean
|
||||
|
|
|
|||
|
|
@ -333,6 +333,20 @@ func setUploadErrLog(c *gin.Context) {
|
|||
time.Sleep(time.Second * 3)
|
||||
}
|
||||
|
||||
func setAutoLaunch(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(http.StatusOK, ret)
|
||||
|
||||
arg, ok := util.JsonArg(c, ret)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
autoLaunch := arg["autoLaunch"].(bool)
|
||||
model.Conf.System.AutoLaunch = autoLaunch
|
||||
model.Conf.Save()
|
||||
}
|
||||
|
||||
func setDownloadInstallPkg(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(http.StatusOK, ret)
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ type System struct {
|
|||
UploadErrLog bool `json:"uploadErrLog"`
|
||||
DisableGoogleAnalytics bool `json:"disableGoogleAnalytics"`
|
||||
DownloadInstallPkg bool `json:"downloadInstallPkg"`
|
||||
AutoLaunch bool `json:"autoLaunch"`
|
||||
}
|
||||
|
||||
func NewSystem() *System {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue