mirror of
https://github.com/algerkong/AlgerMusicPlayer.git
synced 2026-07-13 22:07:29 +08:00
🦄 refactor: 重构代码将 Vuex替换为 Pinia
集成 Pinia 状态管理
This commit is contained in:
@@ -55,13 +55,13 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useStore } from 'vuex';
|
||||
|
||||
import { useSettingsStore } from '@/store/modules/settings';
|
||||
import { isElectron } from '@/utils';
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const store = useStore();
|
||||
const settingsStore = useSettingsStore();
|
||||
const showCloseModal = ref(false);
|
||||
const rememberChoice = ref(false);
|
||||
|
||||
@@ -80,38 +80,30 @@ const minimize = () => {
|
||||
|
||||
const handleAction = (action: 'minimize' | 'close') => {
|
||||
if (rememberChoice.value) {
|
||||
store.commit('setSetData', {
|
||||
...store.state.setData,
|
||||
settingsStore.setSettings({
|
||||
...settingsStore.setData,
|
||||
closeAction: action
|
||||
});
|
||||
}
|
||||
|
||||
if (action === 'minimize') {
|
||||
window.api.miniTray();
|
||||
window.api.minimize();
|
||||
} else {
|
||||
window.api.close();
|
||||
}
|
||||
showCloseModal.value = false;
|
||||
};
|
||||
|
||||
const close = () => {
|
||||
if (!isElectron) {
|
||||
return;
|
||||
}
|
||||
|
||||
const { closeAction } = store.state.setData;
|
||||
const handleClose = () => {
|
||||
const { closeAction } = settingsStore.setData;
|
||||
|
||||
if (closeAction === 'minimize') {
|
||||
window.api.miniTray();
|
||||
return;
|
||||
}
|
||||
|
||||
if (closeAction === 'close') {
|
||||
window.api.minimize();
|
||||
} else if (closeAction === 'close') {
|
||||
window.api.close();
|
||||
return;
|
||||
} else {
|
||||
showCloseModal.value = true;
|
||||
}
|
||||
|
||||
showCloseModal.value = true;
|
||||
};
|
||||
|
||||
const drag = (event: MouseEvent) => {
|
||||
@@ -120,6 +112,10 @@ const drag = (event: MouseEvent) => {
|
||||
}
|
||||
window.api.dragStart(event as unknown as string);
|
||||
};
|
||||
|
||||
const handleThemeChange = () => {
|
||||
settingsStore.toggleTheme();
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
Reference in New Issue
Block a user