feat: Add Tauri support and enhance client functionality

- Introduced Tauri as a new EventFetcherType in api-models.
- Enhanced ClientFetcher.vue to support forced mode switching for Danmaku client.
- Updated ClientLayout.vue to restrict usage outside Tauri environment with appropriate alerts.
- Improved ClientSettings.vue to fetch and display the current version of the application.
- Modified initialization logic in initialize.ts to handle minimized startup for Tauri.
- Updated QueryBiliAPI function to conditionally use cookies based on a new parameter.
- Added bootAsMinimized setting to useSettings store for better user experience.
- Refactored logging in useWebFetcher to use console instead of logError/logInfo for clarity.
- Created a new LabelItem component for better label handling in forms.
- Enhanced EventFetcherStatusCard.vue to display version information based on EventFetcherType.
This commit is contained in:
2025-04-07 19:14:39 +08:00
parent 277497420c
commit 0195e7b01a
14 changed files with 536 additions and 328 deletions

View File

@@ -7,7 +7,7 @@ import { getBuvid, getRoomKey } from "./utils";
import { initInfo } from "./info";
import { TrayIcon, TrayIconOptions } from '@tauri-apps/api/tray';
import { Menu } from "@tauri-apps/api/menu";
import { getCurrentWindow } from "@tauri-apps/api/window";
import { getCurrentWindow, PhysicalSize } from "@tauri-apps/api/window";
import {
isPermissionGranted,
onAction,
@@ -15,7 +15,7 @@ import {
sendNotification,
} from '@tauri-apps/plugin-notification';
import { openUrl } from "@tauri-apps/plugin-opener";
import { CN_HOST } from "@/data/constants";
import { CN_HOST, isDev } from "@/data/constants";
import { invoke } from "@tauri-apps/api/core";
import { check } from '@tauri-apps/plugin-updater';
import { relaunch } from '@tauri-apps/plugin-process';
@@ -24,10 +24,17 @@ const accountInfo = useAccount();
export const clientInited = ref(false);
let tray: TrayIcon;
export async function initAll() {
export async function initAll(isOnBoot: boolean) {
const setting = useSettings();
if (clientInited.value) {
return;
}
if (isOnBoot) {
if (setting.settings.bootAsMinimized && !isDev) {
const appWindow = getCurrentWindow();
appWindow.hide();
}
}
let permissionGranted = await isPermissionGranted();
checkUpdate();
@@ -96,16 +103,16 @@ export async function initAll() {
case 'DoubleClick':
appWindow.show();
break;
case 'Click':
case 'Click':
appWindow.show();
break;
}
}
}
};
tray = await TrayIcon.new(options);
appWindow.setMinSize(new PhysicalSize(720, 480));
clientInited.value = true;
}
export function OnClientUnmounted() {
@@ -209,7 +216,7 @@ export async function initOpenLive() {
}
return reuslt;
}
function initNotificationHandler(){
function initNotificationHandler() {
onAction((event) => {
if (event.extra?.type === 'question-box') {
openUrl(CN_HOST + '/manage/question-box');