mirror of
https://github.com/kunkunsh/kunkun.git
synced 2025-04-11 17:29:44 +00:00
feat(desktop): add autostart (#137)
* feat(desktop): add Tauri autostart plugin and update launch at login settings * chore(ci): update beta build workflow defaults and matrix generation
This commit is contained in:
parent
513cf16d72
commit
71b88e0a22
12
.github/workflows/beta-build.yml
vendored
12
.github/workflows/beta-build.yml
vendored
@ -12,27 +12,27 @@ on:
|
|||||||
description: "Enable updater?"
|
description: "Enable updater?"
|
||||||
required: true
|
required: true
|
||||||
type: boolean
|
type: boolean
|
||||||
default: true
|
default: false
|
||||||
platform_windows:
|
platform_windows:
|
||||||
description: "windows"
|
description: "windows"
|
||||||
required: true
|
required: true
|
||||||
type: boolean
|
type: boolean
|
||||||
default: true
|
default: false
|
||||||
platform_linux:
|
platform_linux:
|
||||||
description: "linux"
|
description: "linux"
|
||||||
required: true
|
required: true
|
||||||
type: boolean
|
type: boolean
|
||||||
default: true
|
default: false
|
||||||
platform_macos_aarch64:
|
platform_macos_aarch64:
|
||||||
description: "macos-aarch64"
|
description: "macos-aarch64"
|
||||||
required: true
|
required: true
|
||||||
type: boolean
|
type: boolean
|
||||||
default: true
|
default: false
|
||||||
platform_macos_x86_64:
|
platform_macos_x86_64:
|
||||||
description: "macos-x86_64"
|
description: "macos-x86_64"
|
||||||
required: true
|
required: true
|
||||||
type: boolean
|
type: boolean
|
||||||
default: true
|
default: false
|
||||||
isDebug:
|
isDebug:
|
||||||
description: "is debug?"
|
description: "is debug?"
|
||||||
required: true
|
required: true
|
||||||
@ -93,7 +93,7 @@ jobs:
|
|||||||
id: setting
|
id: setting
|
||||||
run: |
|
run: |
|
||||||
matrix=""
|
matrix=""
|
||||||
if [ "${{ github.event_name }}" == "schedule" ]; then
|
if [ "${{ github.event_name }}" == "schedule" ] || [ "${{ github.event_name }}" == "pull_request" ]; then
|
||||||
matrix="\"windows-latest\",\"ubuntu-22.04\",\"macos-14\",\"macos-13\""
|
matrix="\"windows-latest\",\"ubuntu-22.04\",\"macos-14\",\"macos-13\""
|
||||||
build_mode=""
|
build_mode=""
|
||||||
build_path="release"
|
build_path="release"
|
||||||
|
35
Cargo.lock
generated
35
Cargo.lock
generated
@ -481,6 +481,17 @@ version = "1.1.2"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
|
checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "auto-launch"
|
||||||
|
version = "0.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1f012b8cc0c850f34117ec8252a44418f2e34a2cf501de89e29b241ae5f79471"
|
||||||
|
dependencies = [
|
||||||
|
"dirs 4.0.0",
|
||||||
|
"thiserror 1.0.66",
|
||||||
|
"winreg 0.10.1",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "autocfg"
|
name = "autocfg"
|
||||||
version = "1.4.0"
|
version = "1.4.0"
|
||||||
@ -3789,6 +3800,7 @@ dependencies = [
|
|||||||
"serde_json",
|
"serde_json",
|
||||||
"tauri",
|
"tauri",
|
||||||
"tauri-build",
|
"tauri-build",
|
||||||
|
"tauri-plugin-autostart",
|
||||||
"tauri-plugin-cli",
|
"tauri-plugin-cli",
|
||||||
"tauri-plugin-clipboard",
|
"tauri-plugin-clipboard",
|
||||||
"tauri-plugin-deep-link",
|
"tauri-plugin-deep-link",
|
||||||
@ -7367,6 +7379,20 @@ dependencies = [
|
|||||||
"walkdir",
|
"walkdir",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "tauri-plugin-autostart"
|
||||||
|
version = "2.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a9c13f843e5e5df3eed270fc42b02923cc1a6b5c7e56b0f3ac1d858ab2c8b5fb"
|
||||||
|
dependencies = [
|
||||||
|
"auto-launch",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
"tauri",
|
||||||
|
"tauri-plugin",
|
||||||
|
"thiserror 2.0.3",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tauri-plugin-cli"
|
name = "tauri-plugin-cli"
|
||||||
version = "2.0.1"
|
version = "2.0.1"
|
||||||
@ -9481,6 +9507,15 @@ dependencies = [
|
|||||||
"memchr",
|
"memchr",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winreg"
|
||||||
|
version = "0.10.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d"
|
||||||
|
dependencies = [
|
||||||
|
"winapi",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winreg"
|
name = "winreg"
|
||||||
version = "0.50.0"
|
version = "0.50.0"
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
"@supabase/supabase-js": "^2.48.0",
|
"@supabase/supabase-js": "^2.48.0",
|
||||||
"@tanstack/table-core": "^8.20.5",
|
"@tanstack/table-core": "^8.20.5",
|
||||||
"@tauri-apps/api": "^2.1.1",
|
"@tauri-apps/api": "^2.1.1",
|
||||||
|
"@tauri-apps/plugin-autostart": "^2.2.0",
|
||||||
"@tauri-apps/plugin-shell": "^2.2.0",
|
"@tauri-apps/plugin-shell": "^2.2.0",
|
||||||
"@tauri-apps/plugin-stronghold": "^2.2.0",
|
"@tauri-apps/plugin-stronghold": "^2.2.0",
|
||||||
"dompurify": "^3.2.3",
|
"dompurify": "^3.2.3",
|
||||||
|
@ -66,6 +66,7 @@ objc = "0.2.7"
|
|||||||
|
|
||||||
|
|
||||||
[target."cfg(not(any(target_os = \"android\", target_os = \"ios\")))".dependencies]
|
[target."cfg(not(any(target_os = \"android\", target_os = \"ios\")))".dependencies]
|
||||||
|
tauri-plugin-autostart = "2"
|
||||||
tauri-plugin-cli = "2"
|
tauri-plugin-cli = "2"
|
||||||
tauri-plugin-global-shortcut = "2.0.1"
|
tauri-plugin-global-shortcut = "2.0.1"
|
||||||
tauri-plugin-single-instance = { version = "2", features = ["deep-link"] }
|
tauri-plugin-single-instance = { version = "2", features = ["deep-link"] }
|
||||||
|
@ -164,6 +164,9 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"deep-link:default"
|
"deep-link:default",
|
||||||
|
"autostart:allow-enable",
|
||||||
|
"autostart:allow-disable",
|
||||||
|
"autostart:allow-is-enabled"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -7,12 +7,16 @@ use log;
|
|||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
use tauri::ActivationPolicy;
|
use tauri::ActivationPolicy;
|
||||||
use tauri::Manager;
|
use tauri::Manager;
|
||||||
|
use tauri_plugin_autostart::MacosLauncher;
|
||||||
use tauri_plugin_deep_link::DeepLinkExt;
|
use tauri_plugin_deep_link::DeepLinkExt;
|
||||||
use tauri_plugin_jarvis::{
|
use tauri_plugin_jarvis::{
|
||||||
constants::KUNKUN_PUBLISH, db::JarvisDB, server::Protocol, utils::{
|
constants::KUNKUN_PUBLISH,
|
||||||
|
db::JarvisDB,
|
||||||
|
server::Protocol,
|
||||||
|
utils::{
|
||||||
path::{get_default_extensions_dir, get_kunkun_db_path},
|
path::{get_default_extensions_dir, get_kunkun_db_path},
|
||||||
settings::AppSettings,
|
settings::AppSettings,
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
use tauri_plugin_keyring::KeyringExt;
|
use tauri_plugin_keyring::KeyringExt;
|
||||||
pub use tauri_plugin_log::fern::colors::ColoredLevelConfig;
|
pub use tauri_plugin_log::fern::colors::ColoredLevelConfig;
|
||||||
@ -97,6 +101,10 @@ pub fn run() {
|
|||||||
.plugin(tauri_plugin_shell::init())
|
.plugin(tauri_plugin_shell::init())
|
||||||
.plugin(tauri_plugin_os::init())
|
.plugin(tauri_plugin_os::init())
|
||||||
.plugin(tauri_plugin_process::init())
|
.plugin(tauri_plugin_process::init())
|
||||||
|
.plugin(tauri_plugin_autostart::init(
|
||||||
|
MacosLauncher::LaunchAgent,
|
||||||
|
Some(vec![]),
|
||||||
|
))
|
||||||
.plugin(tauri_plugin_upload::init())
|
.plugin(tauri_plugin_upload::init())
|
||||||
.plugin(tauri_plugin_store::Builder::default().build())
|
.plugin(tauri_plugin_store::Builder::default().build())
|
||||||
.plugin(tauri_plugin_global_shortcut::Builder::new().build())
|
.plugin(tauri_plugin_global_shortcut::Builder::new().build())
|
||||||
|
@ -11,21 +11,42 @@
|
|||||||
} from "@/paraglide/runtime"
|
} from "@/paraglide/runtime"
|
||||||
import { appConfig } from "@/stores"
|
import { appConfig } from "@/stores"
|
||||||
import { Select, Switch } from "@kksh/svelte5"
|
import { Select, Switch } from "@kksh/svelte5"
|
||||||
|
import * as autoStart from "@tauri-apps/plugin-autostart"
|
||||||
|
import { onMount } from "svelte"
|
||||||
|
import { toast } from "svelte-sonner"
|
||||||
|
|
||||||
const languages = availableLanguageTags.map((lang) => ({
|
const languages = availableLanguageTags.map((lang) => ({
|
||||||
value: lang,
|
value: lang,
|
||||||
label: LanguageMap[lang] ?? lang
|
label: LanguageMap[lang] ?? lang
|
||||||
}))
|
}))
|
||||||
|
let launchAtLogin = $state(false)
|
||||||
let value = $state(languageTag())
|
let language = $state(languageTag())
|
||||||
|
onMount(() => {
|
||||||
const triggerContent = $derived(languages.find((f) => f.value === value)?.label ?? "Language")
|
autoStart.isEnabled().then((enabled) => {
|
||||||
|
launchAtLogin = enabled
|
||||||
|
})
|
||||||
|
})
|
||||||
|
const triggerContent = $derived(languages.find((f) => f.value === language)?.label ?? "Language")
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<ul class="rounded-lg border">
|
<ul class="rounded-lg border">
|
||||||
<li>
|
<li>
|
||||||
<span>{m.settings_general_launch_at_login()}</span>
|
<span>{m.settings_general_launch_at_login()}</span>
|
||||||
<Switch bind:checked={$appConfig.launchAtLogin} />
|
<Switch
|
||||||
|
bind:checked={launchAtLogin}
|
||||||
|
onCheckedChange={(checked) => {
|
||||||
|
const action = checked ? autoStart.enable : autoStart.disable
|
||||||
|
action()
|
||||||
|
.then(() => {
|
||||||
|
toast.success(checked ? "Enabled" : "Disabled")
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
toast.error(checked ? "Failed to enable" : "Failed to disable", {
|
||||||
|
description: err.message
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
/>
|
||||||
</li>
|
</li>
|
||||||
<li class="">
|
<li class="">
|
||||||
<span>{m.settings_general_hotkey()}</span>
|
<span>{m.settings_general_hotkey()}</span>
|
||||||
@ -59,7 +80,7 @@
|
|||||||
<li>
|
<li>
|
||||||
<span>{m.settings_general_language()}</span>
|
<span>{m.settings_general_language()}</span>
|
||||||
|
|
||||||
<Select.Root type="single" name="language" bind:value>
|
<Select.Root type="single" name="language" bind:value={language}>
|
||||||
<Select.Trigger class="w-fit">
|
<Select.Trigger class="w-fit">
|
||||||
{triggerContent}
|
{triggerContent}
|
||||||
</Select.Trigger>
|
</Select.Trigger>
|
||||||
|
@ -19,7 +19,6 @@ export const defaultAppConfig: AppConfig = {
|
|||||||
lightMode: "auto"
|
lightMode: "auto"
|
||||||
},
|
},
|
||||||
triggerHotkey: null,
|
triggerHotkey: null,
|
||||||
launchAtLogin: true,
|
|
||||||
showInTray: true,
|
showInTray: true,
|
||||||
devExtensionPath: null,
|
devExtensionPath: null,
|
||||||
extensionsInstallDir: undefined,
|
extensionsInstallDir: undefined,
|
||||||
|
@ -52,8 +52,6 @@
|
|||||||
unlisteners.forEach((unlistener) => unlistener())
|
unlisteners.forEach((unlistener) => unlistener())
|
||||||
})
|
})
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
console.log("root layout onMount")
|
|
||||||
|
|
||||||
attachConsole().then((unlistener) => unlisteners.push(unlistener))
|
attachConsole().then((unlistener) => unlisteners.push(unlistener))
|
||||||
initDeeplink().then((unlistener) => unlisteners.push(unlistener))
|
initDeeplink().then((unlistener) => unlisteners.push(unlistener))
|
||||||
shellx
|
shellx
|
||||||
|
@ -9,7 +9,6 @@ export const PersistedAppConfig = v.object({
|
|||||||
lightMode: LightMode
|
lightMode: LightMode
|
||||||
}),
|
}),
|
||||||
triggerHotkey: v.nullable(v.array(v.string())),
|
triggerHotkey: v.nullable(v.array(v.string())),
|
||||||
launchAtLogin: v.boolean(),
|
|
||||||
showInTray: v.boolean(),
|
showInTray: v.boolean(),
|
||||||
language: v.string(),
|
language: v.string(),
|
||||||
devExtensionPath: v.nullable(v.string()),
|
devExtensionPath: v.nullable(v.string()),
|
||||||
|
10
pnpm-lock.yaml
generated
10
pnpm-lock.yaml
generated
@ -236,6 +236,9 @@ importers:
|
|||||||
'@tauri-apps/api':
|
'@tauri-apps/api':
|
||||||
specifier: ^2.1.1
|
specifier: ^2.1.1
|
||||||
version: 2.1.1
|
version: 2.1.1
|
||||||
|
'@tauri-apps/plugin-autostart':
|
||||||
|
specifier: ^2.2.0
|
||||||
|
version: 2.2.0
|
||||||
'@tauri-apps/plugin-shell':
|
'@tauri-apps/plugin-shell':
|
||||||
specifier: ^2.2.0
|
specifier: ^2.2.0
|
||||||
version: 2.2.0
|
version: 2.2.0
|
||||||
@ -5005,6 +5008,9 @@ packages:
|
|||||||
engines: {node: '>= 10'}
|
engines: {node: '>= 10'}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
|
|
||||||
|
'@tauri-apps/plugin-autostart@2.2.0':
|
||||||
|
resolution: {integrity: sha512-TzVcDZdOvdot0avkpstUWJKKEl4cyxLpFB9DZZRW5zH8k+Bv8IVJmO0zyYuw+7oKlGdHOINbD/7Je7GHMViw5w==}
|
||||||
|
|
||||||
'@tauri-apps/plugin-deep-link@2.2.0':
|
'@tauri-apps/plugin-deep-link@2.2.0':
|
||||||
resolution: {integrity: sha512-H6mkxr2KZ3XJcKL44tiq6cOjCw9DL8OgU1xjn3j26Qsn+H/roPFiyhR7CHuB8Ar+sQFj4YVlfmJwtBajK2FETQ==}
|
resolution: {integrity: sha512-H6mkxr2KZ3XJcKL44tiq6cOjCw9DL8OgU1xjn3j26Qsn+H/roPFiyhR7CHuB8Ar+sQFj4YVlfmJwtBajK2FETQ==}
|
||||||
|
|
||||||
@ -16475,6 +16481,10 @@ snapshots:
|
|||||||
'@tauri-apps/cli-win32-ia32-msvc': 2.2.7
|
'@tauri-apps/cli-win32-ia32-msvc': 2.2.7
|
||||||
'@tauri-apps/cli-win32-x64-msvc': 2.2.7
|
'@tauri-apps/cli-win32-x64-msvc': 2.2.7
|
||||||
|
|
||||||
|
'@tauri-apps/plugin-autostart@2.2.0':
|
||||||
|
dependencies:
|
||||||
|
'@tauri-apps/api': 2.2.0
|
||||||
|
|
||||||
'@tauri-apps/plugin-deep-link@2.2.0':
|
'@tauri-apps/plugin-deep-link@2.2.0':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@tauri-apps/api': 2.2.0
|
'@tauri-apps/api': 2.2.0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user