@@ -3,6 +3,7 @@ import type { DropdownMenuItem } from "@nuxt/ui";
33import type { UnlistenFn } from " @tauri-apps/api/event" ;
44import type { LangType , ThemeType , UserData } from " ~/types/index" ;
55
6+ import { LogicalPosition } from " @tauri-apps/api/dpi" ;
67import { useSettingManager } from " ~/composables/useSettingManager" ;
78import { useUserInfoStore } from " ~/store/modules/userInfo" ;
89import RecentSites from " ./recentSites.vue" ;
@@ -29,6 +30,7 @@ const userInfoStore = useUserInfoStore();
2930
3031const { t, locales, locale } = useI18n ();
3132const { loggedIn, currentSite, userMap, currentUser } = storeToRefs (userInfoStore );
33+ const { isMacOS } = usePlatform ();
3234
3335const {
3436 setLang,
@@ -181,6 +183,21 @@ const appearanceChildren = computed<DropdownMenuItem[][]>(() => [
181183 }))
182184]);
183185
186+ const toolChildren = computed <DropdownMenuItem [][]>(() => [
187+ [
188+ {
189+ label: t (" Menu.Player" ),
190+ icon: " lucide:clapperboard" ,
191+ onClick : () => openToolWindow (" videoplayer" , t (" Menu.Player" ), " /videoplayer" , 1480 , 920 , 1320 , 860 )
192+ },
193+ {
194+ label: t (" Menu.Transcode" ),
195+ icon: " lucide:repeat-2" ,
196+ onClick : () => openToolWindow (" transcode" , t (" Menu.Transcode" ), " /transcode" , 1180 , 760 , 960 , 640 )
197+ }
198+ ]
199+ ]);
200+
184201const profileMenuItems = computed <DropdownMenuItem [][]>(() => [
185202 [
186203 {
@@ -198,6 +215,11 @@ const profileMenuItems = computed<DropdownMenuItem[][]>(() => [
198215 icon: " solar:palette-linear" ,
199216 children: appearanceChildren .value
200217 },
218+ {
219+ label: t (" Menu.Tool" ),
220+ icon: " lucide:wrench" ,
221+ children: toolChildren .value
222+ },
201223 {
202224 label: t (" Common.Language" ),
203225 icon: " solar:global-outline" ,
@@ -245,6 +267,54 @@ function handleLanguageChange(code: LangType) {
245267 selectedLanguage .value = code ;
246268}
247269
270+ async function openToolWindow(
271+ label : string ,
272+ title : string ,
273+ path : string ,
274+ width : number ,
275+ height : number ,
276+ minWidth : number ,
277+ minHeight : number
278+ ) {
279+ const url = localePath ({ path });
280+
281+ try {
282+ const existing = await useTauriWebviewWindowWebviewWindow .getByLabel (label );
283+
284+ if (existing ) {
285+ if (await existing .isMinimized ()) {
286+ await existing .unminimize ();
287+ }
288+
289+ if (! (await existing .isVisible ())) {
290+ await existing .show ();
291+ }
292+
293+ await existing .setFocus ();
294+ return ;
295+ }
296+
297+ const isMac = isMacOS .value ;
298+
299+ // eslint-disable-next-line no-new
300+ new useTauriWebviewWindowWebviewWindow (label , {
301+ title ,
302+ url ,
303+ width ,
304+ height ,
305+ minWidth ,
306+ minHeight ,
307+ hiddenTitle: true ,
308+ titleBarStyle: " overlay" ,
309+ trafficLightPosition: new LogicalPosition (10 , 22 ),
310+ decorations: isMac ,
311+ shadow: isMac
312+ });
313+ } catch {
314+ await navigateTo (url );
315+ }
316+ }
317+
248318/**
249319 * @description 标准化站点输入:去除首尾空格 + 去除末尾斜杠
250320 * @param value 站点输入
0 commit comments