mirror of
https://github.com/algerkong/AlgerMusicPlayer.git
synced 2026-05-17 02:07:29 +08:00
refactor: 更新 eslint 和 prettier 配置 格式化代码
This commit is contained in:
@@ -34,7 +34,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, watch, defineProps, defineEmits } from 'vue';
|
||||
import { defineEmits, defineProps, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
const props = defineProps({
|
||||
@@ -113,4 +113,4 @@ const handleCancel = () => {
|
||||
selectedTypes.value = [];
|
||||
visible.value = false;
|
||||
};
|
||||
</script>
|
||||
</script>
|
||||
|
||||
@@ -34,7 +34,10 @@
|
||||
</div>
|
||||
|
||||
<!-- GD音乐台设置 -->
|
||||
<div v-if="selectedSources.includes('gdmusic')" class="mt-4 border-t pt-4 border-gray-200 dark:border-gray-700">
|
||||
<div
|
||||
v-if="selectedSources.includes('gdmusic')"
|
||||
class="mt-4 border-t pt-4 border-gray-200 dark:border-gray-700"
|
||||
>
|
||||
<h3 class="text-base font-medium mb-2">GD音乐台(music.gdstudio.xyz)设置</h3>
|
||||
<p class="text-sm text-gray-500 dark:text-gray-400 mb-2">
|
||||
GD音乐台将自动尝试多个音乐平台进行解析,无需额外配置。优先级高于其他解析方式,但是请求可能较慢。感谢(music.gdstudio.xyz)
|
||||
@@ -45,8 +48,9 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, watch, defineProps, defineEmits } from 'vue';
|
||||
import { defineEmits, defineProps, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import { type Platform } from '@/types/music';
|
||||
|
||||
const props = defineProps({
|
||||
@@ -102,10 +106,9 @@ watch(
|
||||
const handleConfirm = () => {
|
||||
// 确保至少选择一个音源
|
||||
const defaultPlatforms = ['migu', 'kugou', 'pyncmd', 'bilibili'];
|
||||
const valuesToEmit = selectedSources.value.length > 0
|
||||
? [...new Set(selectedSources.value)]
|
||||
: defaultPlatforms;
|
||||
|
||||
const valuesToEmit =
|
||||
selectedSources.value.length > 0 ? [...new Set(selectedSources.value)] : defaultPlatforms;
|
||||
|
||||
emit('update:sources', valuesToEmit);
|
||||
visible.value = false;
|
||||
};
|
||||
@@ -115,4 +118,4 @@ const handleCancel = () => {
|
||||
selectedSources.value = [...props.sources];
|
||||
visible.value = false;
|
||||
};
|
||||
</script>
|
||||
</script>
|
||||
|
||||
@@ -46,10 +46,10 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, watch, defineProps, defineEmits } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useMessage } from 'naive-ui';
|
||||
import type { FormRules } from 'naive-ui';
|
||||
import { useMessage } from 'naive-ui';
|
||||
import { defineEmits, defineProps, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
const props = defineProps({
|
||||
show: {
|
||||
@@ -92,7 +92,8 @@ const proxyRules: FormRules = {
|
||||
validator: (_rule, value) => {
|
||||
if (!value) return false;
|
||||
// 简单的IP或域名验证
|
||||
const ipRegex = /^(\d{1,3}\.){3}\d{1,3}$|^localhost$|^[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+$/;
|
||||
const ipRegex =
|
||||
/^(\d{1,3}\.){3}\d{1,3}$|^localhost$|^[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+$/;
|
||||
return ipRegex.test(value);
|
||||
}
|
||||
},
|
||||
@@ -142,6 +143,7 @@ const handleProxyConfirm = async () => {
|
||||
visible.value = false;
|
||||
message.success(t('settings.network.messages.proxySuccess'));
|
||||
} catch (err) {
|
||||
console.error('代理设置验证失败:', err);
|
||||
message.error(t('settings.network.messages.proxyError'));
|
||||
}
|
||||
};
|
||||
@@ -149,4 +151,4 @@ const handleProxyConfirm = async () => {
|
||||
const handleCancel = () => {
|
||||
visible.value = false;
|
||||
};
|
||||
</script>
|
||||
</script>
|
||||
|
||||
@@ -24,13 +24,20 @@
|
||||
|
||||
<n-form-item :label="t('settings.remoteControl.allowedIps')">
|
||||
<div class="allowed-ips-container">
|
||||
<div v-for="(_, index) in remoteControlConfig.allowedIps" :key="index" class="ip-item">
|
||||
<n-input v-model:value="remoteControlConfig.allowedIps[index]" :disabled="!remoteControlConfig.enabled" />
|
||||
<n-button
|
||||
quaternary
|
||||
circle
|
||||
type="error"
|
||||
:disabled="!remoteControlConfig.enabled"
|
||||
<div
|
||||
v-for="(_, index) in remoteControlConfig.allowedIps"
|
||||
:key="index"
|
||||
class="ip-item"
|
||||
>
|
||||
<n-input
|
||||
v-model:value="remoteControlConfig.allowedIps[index]"
|
||||
:disabled="!remoteControlConfig.enabled"
|
||||
/>
|
||||
<n-button
|
||||
quaternary
|
||||
circle
|
||||
type="error"
|
||||
:disabled="!remoteControlConfig.enabled"
|
||||
@click="removeIp(index)"
|
||||
>
|
||||
<template #icon>
|
||||
@@ -38,10 +45,10 @@
|
||||
</template>
|
||||
</n-button>
|
||||
</div>
|
||||
<n-button
|
||||
secondary
|
||||
size="small"
|
||||
:disabled="!remoteControlConfig.enabled"
|
||||
<n-button
|
||||
secondary
|
||||
size="small"
|
||||
:disabled="!remoteControlConfig.enabled"
|
||||
@click="addIp"
|
||||
>
|
||||
<template #icon>
|
||||
@@ -57,11 +64,7 @@
|
||||
|
||||
<n-form-item>
|
||||
<n-space>
|
||||
<n-button
|
||||
type="primary"
|
||||
:disabled="!remoteControlConfig.enabled"
|
||||
@click="saveConfig"
|
||||
>
|
||||
<n-button type="primary" :disabled="!remoteControlConfig.enabled" @click="saveConfig">
|
||||
{{ t('common.save') }}
|
||||
</n-button>
|
||||
<n-button @click="resetConfig">
|
||||
@@ -78,15 +81,11 @@
|
||||
</template>
|
||||
<p>{{ t('settings.remoteControl.accessInfo') }}</p>
|
||||
<div class="access-url">
|
||||
<n-tag type="success">
|
||||
http://localhost:{{ remoteControlConfig.port }}/
|
||||
</n-tag>
|
||||
<n-tag type="success"> http://localhost:{{ remoteControlConfig.port }}/ </n-tag>
|
||||
</div>
|
||||
<div v-if="localIpAddresses.length" class="local-ips">
|
||||
<div v-for="ip in localIpAddresses" :key="ip" class="ip-address">
|
||||
<n-tag type="info">
|
||||
http://{{ ip }}:{{ remoteControlConfig.port }}/
|
||||
</n-tag>
|
||||
<n-tag type="info"> http://{{ ip }}:{{ remoteControlConfig.port }}/ </n-tag>
|
||||
</div>
|
||||
</div>
|
||||
</n-alert>
|
||||
@@ -99,10 +98,10 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { cloneDeep } from 'lodash';
|
||||
import { useMessage } from 'naive-ui';
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useMessage } from 'naive-ui';
|
||||
import { cloneDeep } from 'lodash';
|
||||
|
||||
const { t } = useI18n();
|
||||
const message = useMessage();
|
||||
@@ -111,10 +110,10 @@ const message = useMessage();
|
||||
const visible = defineModel('visible', { default: false });
|
||||
|
||||
// 默认配置
|
||||
const defaultConfig:{
|
||||
enabled: boolean,
|
||||
port: number,
|
||||
allowedIps: string[]
|
||||
const defaultConfig: {
|
||||
enabled: boolean;
|
||||
port: number;
|
||||
allowedIps: string[];
|
||||
} = {
|
||||
enabled: false,
|
||||
port: 31888,
|
||||
@@ -122,7 +121,7 @@ const defaultConfig:{
|
||||
};
|
||||
|
||||
// 远程控制配置
|
||||
const remoteControlConfig = ref({...defaultConfig});
|
||||
const remoteControlConfig = ref({ ...defaultConfig });
|
||||
|
||||
// 本地IP地址列表
|
||||
const localIpAddresses = ref<string[]>([]);
|
||||
@@ -149,10 +148,15 @@ const removeIp = (index: number) => {
|
||||
// 保存配置
|
||||
const saveConfig = () => {
|
||||
// 过滤空IP
|
||||
remoteControlConfig.value.allowedIps = remoteControlConfig.value.allowedIps.filter(ip => ip.trim() !== '');
|
||||
|
||||
remoteControlConfig.value.allowedIps = remoteControlConfig.value.allowedIps.filter(
|
||||
(ip) => ip.trim() !== ''
|
||||
);
|
||||
|
||||
if (window.electron) {
|
||||
window.electron.ipcRenderer.send('update-remote-control-config', cloneDeep(remoteControlConfig.value));
|
||||
window.electron.ipcRenderer.send(
|
||||
'update-remote-control-config',
|
||||
cloneDeep(remoteControlConfig.value)
|
||||
);
|
||||
message.success(t('settings.remoteControl.saveSuccess'));
|
||||
}
|
||||
};
|
||||
@@ -211,11 +215,11 @@ onMounted(async () => {
|
||||
|
||||
.remote-info {
|
||||
margin-top: 16px;
|
||||
|
||||
|
||||
.access-url {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
|
||||
.local-ips {
|
||||
margin-top: 10px;
|
||||
display: flex;
|
||||
@@ -223,4 +227,4 @@ onMounted(async () => {
|
||||
gap: 5px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user