2023-12-18 19:39:36 +08:00
|
|
|
<template>
|
2024-01-02 22:19:39 +08:00
|
|
|
<div id="title-bar" @mousedown="drag">
|
2023-12-18 19:39:36 +08:00
|
|
|
<div id="title">Alger Music</div>
|
|
|
|
|
<div id="buttons">
|
|
|
|
|
<button @click="minimize">
|
|
|
|
|
<i class="iconfont icon-minisize"></i>
|
|
|
|
|
</button>
|
|
|
|
|
<button @click="close">
|
|
|
|
|
<i class="iconfont icon-close"></i>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
2024-05-16 18:54:30 +08:00
|
|
|
import { useDialog } from 'naive-ui';
|
2023-12-20 10:23:15 +08:00
|
|
|
|
2024-12-14 13:49:32 +08:00
|
|
|
import { isElectron } from '@/hooks/MusicHook';
|
|
|
|
|
|
2024-05-16 18:54:30 +08:00
|
|
|
const dialog = useDialog();
|
|
|
|
|
const windowData = window as any;
|
2023-12-28 10:45:11 +08:00
|
|
|
|
2023-12-18 19:39:36 +08:00
|
|
|
const minimize = () => {
|
2024-12-14 13:49:32 +08:00
|
|
|
if (!isElectron.value) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2024-05-16 18:54:30 +08:00
|
|
|
windowData.electronAPI.minimize();
|
|
|
|
|
};
|
2023-12-18 19:39:36 +08:00
|
|
|
|
|
|
|
|
const close = () => {
|
2024-12-14 13:49:32 +08:00
|
|
|
if (!isElectron.value) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2023-12-20 10:23:15 +08:00
|
|
|
dialog.warning({
|
|
|
|
|
title: '提示',
|
|
|
|
|
content: '确定要退出吗?',
|
|
|
|
|
positiveText: '最小化',
|
|
|
|
|
negativeText: '关闭',
|
|
|
|
|
onPositiveClick: () => {
|
2024-05-16 18:54:30 +08:00
|
|
|
windowData.electronAPI.miniTray();
|
2023-12-20 10:23:15 +08:00
|
|
|
},
|
|
|
|
|
onNegativeClick: () => {
|
2024-05-16 18:54:30 +08:00
|
|
|
windowData.electronAPI.close();
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
};
|
2023-12-18 19:39:36 +08:00
|
|
|
|
2023-12-28 10:45:11 +08:00
|
|
|
const drag = (event: MouseEvent) => {
|
2024-12-14 13:49:32 +08:00
|
|
|
if (!isElectron.value) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2024-05-16 18:54:30 +08:00
|
|
|
windowData.electronAPI.dragStart(event);
|
|
|
|
|
};
|
2023-12-18 19:39:36 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
|
#title-bar {
|
|
|
|
|
-webkit-app-region: drag;
|
2024-12-28 16:43:52 +08:00
|
|
|
@apply flex justify-between px-6 py-2 select-none relative;
|
|
|
|
|
@apply text-dark dark:text-white;
|
2023-12-18 19:39:36 +08:00
|
|
|
z-index: 9999999;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#buttons {
|
|
|
|
|
@apply flex gap-4;
|
|
|
|
|
-webkit-app-region: no-drag;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
button {
|
2024-12-28 16:43:52 +08:00
|
|
|
@apply text-gray-600 dark:text-gray-400 hover:text-green-500;
|
2023-12-18 19:39:36 +08:00
|
|
|
}
|
|
|
|
|
</style>
|