refactor: standardize code formatting and linting configuration

- Replace .eslintrc.js with .eslintrc.cjs for better ES module compatibility
- Add .prettierrc configuration for consistent code formatting
- Update package.json with new lint and format scripts
- Add nodemon.json for development hot reloading configuration
- Standardize code formatting across all JavaScript and Vue files
- Update web admin SPA with improved linting rules and formatting
- Add prettier configuration to web admin SPA

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
千羽
2025-08-07 18:19:31 +09:00
parent 4a0eba117c
commit 8a74bf5afe
124 changed files with 20878 additions and 18757 deletions

View File

@@ -1,117 +1,97 @@
<template>
<div class="space-y-4">
<div class="flex items-center justify-between">
<h4 class="text-sm font-semibold text-gray-700">
代理设置 (可选)
</h4>
<label class="flex items-center cursor-pointer">
<input
v-model="proxy.enabled"
<h4 class="text-sm font-semibold text-gray-700">代理设置 (可选)</h4>
<label class="flex cursor-pointer items-center">
<input
v-model="proxy.enabled"
class="h-4 w-4 rounded border-gray-300 bg-gray-100 text-blue-600 focus:ring-blue-500"
type="checkbox"
class="w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500"
>
/>
<span class="ml-2 text-sm text-gray-700">启用代理</span>
</label>
</div>
<div
v-if="proxy.enabled"
class="bg-gray-50 p-4 rounded-lg border border-gray-200 space-y-4"
>
<div class="flex items-start gap-3 mb-3">
<div class="w-8 h-8 bg-gray-500 rounded-lg flex items-center justify-center flex-shrink-0">
<i class="fas fa-server text-white text-sm" />
<div v-if="proxy.enabled" class="space-y-4 rounded-lg border border-gray-200 bg-gray-50 p-4">
<div class="mb-3 flex items-start gap-3">
<div class="flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-lg bg-gray-500">
<i class="fas fa-server text-sm text-white" />
</div>
<div class="flex-1">
<p class="text-sm text-gray-700">
配置代理以访问受限的网络资源支持 SOCKS5 HTTP 代理
</p>
<p class="text-xs text-gray-500 mt-1">
<p class="mt-1 text-xs text-gray-500">
请确保代理服务器稳定可用否则会影响账户的正常使用
</p>
</div>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">代理类型</label>
<select
v-model="proxy.type"
class="form-input w-full"
>
<option value="socks5">
SOCKS5
</option>
<option value="http">
HTTP
</option>
<option value="https">
HTTPS
</option>
<label class="mb-2 block text-sm font-medium text-gray-700">代理类型</label>
<select v-model="proxy.type" class="form-input w-full">
<option value="socks5">SOCKS5</option>
<option value="http">HTTP</option>
<option value="https">HTTPS</option>
</select>
</div>
<div class="grid grid-cols-2 gap-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">主机地址</label>
<input
v-model="proxy.host"
type="text"
placeholder="例如: 192.168.1.100"
<label class="mb-2 block text-sm font-medium text-gray-700">主机地址</label>
<input
v-model="proxy.host"
class="form-input w-full"
>
placeholder="例如: 192.168.1.100"
type="text"
/>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">端口</label>
<input
v-model="proxy.port"
type="number"
placeholder="例如: 1080"
<label class="mb-2 block text-sm font-medium text-gray-700">端口</label>
<input
v-model="proxy.port"
class="form-input w-full"
>
placeholder="例如: 1080"
type="number"
/>
</div>
</div>
<div class="space-y-4">
<div class="flex items-center">
<input
id="proxyAuth"
<input
id="proxyAuth"
v-model="showAuth"
class="h-4 w-4 rounded border-gray-300 bg-gray-100 text-blue-600 focus:ring-blue-500"
type="checkbox"
class="w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500"
>
<label
for="proxyAuth"
class="ml-2 text-sm text-gray-700 cursor-pointer"
>
/>
<label class="ml-2 cursor-pointer text-sm text-gray-700" for="proxyAuth">
需要身份验证
</label>
</div>
<div
v-if="showAuth"
class="grid grid-cols-2 gap-4"
>
<div v-if="showAuth" class="grid grid-cols-2 gap-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">用户名</label>
<input
v-model="proxy.username"
type="text"
placeholder="代理用户名"
<label class="mb-2 block text-sm font-medium text-gray-700">用户名</label>
<input
v-model="proxy.username"
class="form-input w-full"
>
placeholder="代理用户名"
type="text"
/>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">密码</label>
<label class="mb-2 block text-sm font-medium text-gray-700">密码</label>
<div class="relative">
<input
v-model="proxy.password"
:type="showPassword ? 'text' : 'password'"
placeholder="代理密码"
<input
v-model="proxy.password"
class="form-input w-full pr-10"
>
<button
placeholder="代理密码"
:type="showPassword ? 'text' : 'password'"
/>
<button
class="absolute inset-y-0 right-0 flex items-center pr-3 text-gray-400 hover:text-gray-600"
type="button"
class="absolute inset-y-0 right-0 pr-3 flex items-center text-gray-400 hover:text-gray-600"
@click="showPassword = !showPassword"
>
<i :class="showPassword ? 'fas fa-eye-slash' : 'fas fa-eye'" />
@@ -120,11 +100,12 @@
</div>
</div>
</div>
<div class="bg-blue-50 p-3 rounded-lg border border-blue-200">
<div class="rounded-lg border border-blue-200 bg-blue-50 p-3">
<p class="text-xs text-blue-700">
<i class="fas fa-info-circle mr-1" />
<strong>提示</strong>代理设置将用于所有与此账户相关的API请求请确保代理服务器支持HTTPS流量转发
<strong>提示</strong
>代理设置将用于所有与此账户相关的API请求请确保代理服务器支持HTTPS流量转发
</p>
</div>
</div>
@@ -132,7 +113,7 @@
</template>
<script setup>
import { ref, computed, watch, onUnmounted } from 'vue'
import { ref, watch, onUnmounted } from 'vue'
const props = defineProps({
modelValue: {
@@ -158,38 +139,60 @@ const showAuth = ref(!!(proxy.value.username || proxy.value.password))
const showPassword = ref(false)
// 监听modelValue变化只在真正需要更新时才更新
watch(() => props.modelValue, (newVal) => {
// 只有当值真正不同时才更新,避免循环
if (JSON.stringify(newVal) !== JSON.stringify(proxy.value)) {
proxy.value = { ...newVal }
showAuth.value = !!(newVal.username || newVal.password)
}
}, { deep: true })
watch(
() => props.modelValue,
(newVal) => {
// 只有当值真正不同时才更新,避免循环
if (JSON.stringify(newVal) !== JSON.stringify(proxy.value)) {
proxy.value = { ...newVal }
showAuth.value = !!(newVal.username || newVal.password)
}
},
{ deep: true }
)
// 监听各个字段单独变化,而不是整个对象
watch(() => proxy.value.enabled, (newVal) => {
emitUpdate()
})
watch(
() => proxy.value.enabled,
() => {
emitUpdate()
}
)
watch(() => proxy.value.type, (newVal) => {
emitUpdate()
})
watch(
() => proxy.value.type,
() => {
emitUpdate()
}
)
watch(() => proxy.value.host, (newVal) => {
emitUpdate()
})
watch(
() => proxy.value.host,
() => {
emitUpdate()
}
)
watch(() => proxy.value.port, (newVal) => {
emitUpdate()
})
watch(
() => proxy.value.port,
() => {
emitUpdate()
}
)
watch(() => proxy.value.username, (newVal) => {
emitUpdate()
})
watch(
() => proxy.value.username,
() => {
emitUpdate()
}
)
watch(() => proxy.value.password, (newVal) => {
emitUpdate()
})
watch(
() => proxy.value.password,
() => {
emitUpdate()
}
)
// 监听认证开关
watch(showAuth, (newVal) => {
@@ -207,17 +210,17 @@ function emitUpdate() {
if (updateTimer) {
clearTimeout(updateTimer)
}
// 设置新的定时器,延迟发送更新
updateTimer = setTimeout(() => {
const data = { ...proxy.value }
// 如果不需要认证,清空用户名密码
if (!showAuth.value) {
data.username = ''
data.password = ''
}
emit('update:modelValue', data)
}, 100) // 100ms 延迟
}
@@ -228,4 +231,4 @@ onUnmounted(() => {
clearTimeout(updateTimer)
}
})
</script>
</script>