Skip to content

Commit 831ba47

Browse files
committed
perf: update tools
1 parent 8e6de68 commit 831ba47

4 files changed

Lines changed: 228 additions & 95 deletions

File tree

ui/components/SideBar/profile.vue

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { DropdownMenuItem } from "@nuxt/ui";
33
import type { UnlistenFn } from "@tauri-apps/api/event";
44
import type { LangType, ThemeType, UserData } from "~/types/index";
55
6+
import { LogicalPosition } from "@tauri-apps/api/dpi";
67
import { useSettingManager } from "~/composables/useSettingManager";
78
import { useUserInfoStore } from "~/store/modules/userInfo";
89
import RecentSites from "./recentSites.vue";
@@ -29,6 +30,7 @@ const userInfoStore = useUserInfoStore();
2930
3031
const { t, locales, locale } = useI18n();
3132
const { loggedIn, currentSite, userMap, currentUser } = storeToRefs(userInfoStore);
33+
const { isMacOS } = usePlatform();
3234
3335
const {
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+
184201
const 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 站点输入

ui/components/SideBar/sideBar.vue

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,6 @@ const sideBarItems = computed<NavigationMenuItem[]>(() => {
3535
to: localePath("windows"),
3636
disabled: isLoading.value
3737
},
38-
{
39-
label: t("Menu.Other"),
40-
icon: "lucide:boxes",
41-
to: localePath("other"),
42-
disabled: isLoading.value
43-
},
4438
{
4539
label: t("Menu.Database"),
4640
icon: "gravity-ui:database",
@@ -60,25 +54,15 @@ const sideBarItems = computed<NavigationMenuItem[]>(() => {
6054
disabled: isLoading.value
6155
},
6256
{
63-
label: t("Menu.Favorite"),
64-
icon: "gravity-ui:star",
65-
to: localePath("favorite"),
66-
disabled: isLoading.value
67-
},
68-
{
69-
label: t("Menu.Tool"),
70-
type: "label"
71-
},
72-
{
73-
label: t("Menu.Player"),
74-
icon: "lucide:clapperboard",
75-
to: localePath("videoplayer"),
57+
label: t("Menu.Other"),
58+
icon: "lucide:boxes",
59+
to: localePath("other"),
7660
disabled: isLoading.value
7761
},
7862
{
79-
label: t("Menu.Transcode"),
80-
icon: "lucide:repeat-2",
81-
to: localePath({ path: "/transcode" }),
63+
label: t("Menu.Favorite"),
64+
icon: "gravity-ui:star",
65+
to: localePath("favorite"),
8266
disabled: isLoading.value
8367
}
8468
];

0 commit comments

Comments
 (0)