mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-22 16:43:35 +00:00
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:
@@ -1,5 +1,6 @@
|
||||
import { defineConfig, loadEnv } from 'vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import checker from 'vite-plugin-checker'
|
||||
import AutoImport from 'unplugin-auto-import/vite'
|
||||
import Components from 'unplugin-vue-components/vite'
|
||||
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
|
||||
@@ -12,14 +13,14 @@ export default defineConfig(({ mode }) => {
|
||||
const httpProxy = env.VITE_HTTP_PROXY || env.HTTP_PROXY || env.http_proxy
|
||||
// 使用环境变量配置基础路径,如果未设置则使用默认值
|
||||
const basePath = env.VITE_APP_BASE_URL || (mode === 'development' ? '/admin/' : '/admin-next/')
|
||||
|
||||
|
||||
// 创建代理配置
|
||||
const proxyConfig = {
|
||||
target: apiTarget,
|
||||
changeOrigin: true,
|
||||
secure: false
|
||||
}
|
||||
|
||||
|
||||
// 如果设置了代理,动态导入并配置 agent(仅在开发模式下)
|
||||
if (httpProxy && mode === 'development') {
|
||||
console.log(`Using HTTP proxy: ${httpProxy}`)
|
||||
@@ -28,77 +29,99 @@ export default defineConfig(({ mode }) => {
|
||||
process.env.HTTP_PROXY = httpProxy
|
||||
process.env.HTTPS_PROXY = httpProxy
|
||||
}
|
||||
|
||||
console.log(`${mode === 'development' ? 'Starting dev server' : 'Building'} with base path: ${basePath}`)
|
||||
|
||||
|
||||
console.log(
|
||||
`${mode === 'development' ? 'Starting dev server' : 'Building'} with base path: ${basePath}`
|
||||
)
|
||||
|
||||
return {
|
||||
base: basePath,
|
||||
plugins: [
|
||||
vue(),
|
||||
AutoImport({
|
||||
resolvers: [ElementPlusResolver()],
|
||||
imports: ['vue', 'vue-router', 'pinia']
|
||||
}),
|
||||
Components({
|
||||
resolvers: [ElementPlusResolver()]
|
||||
})
|
||||
],
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': fileURLToPath(new URL('./src', import.meta.url))
|
||||
}
|
||||
},
|
||||
server: {
|
||||
port: 3001,
|
||||
host: true,
|
||||
open: true,
|
||||
proxy: {
|
||||
// 统一的 API 代理规则 - 开发环境所有 API 请求都加 /webapi 前缀
|
||||
'/webapi': {
|
||||
...proxyConfig,
|
||||
rewrite: (path) => path.replace(/^\/webapi/, ''), // 转发时去掉 /webapi 前缀
|
||||
configure: (proxy, options) => {
|
||||
proxy.on('proxyReq', (proxyReq, req, res) => {
|
||||
console.log('Proxying:', req.method, req.url, '->', options.target + req.url.replace(/^\/webapi/, ''))
|
||||
})
|
||||
proxy.on('error', (err, req, res) => {
|
||||
console.log('Proxy error:', err)
|
||||
})
|
||||
base: basePath,
|
||||
plugins: [
|
||||
vue(),
|
||||
checker({
|
||||
eslint: {
|
||||
lintCommand: 'eslint "./src/**/*.{js,vue}" --cache=false',
|
||||
dev: {
|
||||
logLevel: ['error', 'warning']
|
||||
}
|
||||
}
|
||||
},
|
||||
// API Stats 专用代理规则
|
||||
'/apiStats': {
|
||||
...proxyConfig,
|
||||
configure: (proxy, options) => {
|
||||
proxy.on('proxyReq', (proxyReq, req, res) => {
|
||||
console.log('API Stats Proxying:', req.method, req.url, '->', options.target + req.url)
|
||||
})
|
||||
}),
|
||||
AutoImport({
|
||||
resolvers: [ElementPlusResolver()],
|
||||
imports: ['vue', 'vue-router', 'pinia']
|
||||
}),
|
||||
Components({
|
||||
resolvers: [ElementPlusResolver()]
|
||||
})
|
||||
],
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': fileURLToPath(new URL('./src', import.meta.url))
|
||||
}
|
||||
},
|
||||
server: {
|
||||
port: 3001,
|
||||
host: true,
|
||||
open: true,
|
||||
proxy: {
|
||||
// 统一的 API 代理规则 - 开发环境所有 API 请求都加 /webapi 前缀
|
||||
'/webapi': {
|
||||
...proxyConfig,
|
||||
rewrite: (path) => path.replace(/^\/webapi/, ''), // 转发时去掉 /webapi 前缀
|
||||
configure: (proxy, options) => {
|
||||
proxy.on('proxyReq', (proxyReq, req) => {
|
||||
console.log(
|
||||
'Proxying:',
|
||||
req.method,
|
||||
req.url,
|
||||
'->',
|
||||
options.target + req.url.replace(/^\/webapi/, '')
|
||||
)
|
||||
})
|
||||
proxy.on('error', (err) => {
|
||||
console.log('Proxy error:', err)
|
||||
})
|
||||
}
|
||||
},
|
||||
// API Stats 专用代理规则
|
||||
'/apiStats': {
|
||||
...proxyConfig,
|
||||
configure: (proxy, options) => {
|
||||
proxy.on('proxyReq', (proxyReq, req) => {
|
||||
console.log(
|
||||
'API Stats Proxying:',
|
||||
req.method,
|
||||
req.url,
|
||||
'->',
|
||||
options.target + req.url
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
build: {
|
||||
outDir: 'dist',
|
||||
assetsDir: 'assets',
|
||||
rollupOptions: {
|
||||
output: {
|
||||
manualChunks(id) {
|
||||
// 将 vue 相关的库打包到一起
|
||||
if (id.includes('node_modules')) {
|
||||
if (id.includes('element-plus')) {
|
||||
return 'element-plus'
|
||||
},
|
||||
build: {
|
||||
outDir: 'dist',
|
||||
assetsDir: 'assets',
|
||||
rollupOptions: {
|
||||
output: {
|
||||
manualChunks(id) {
|
||||
// 将 vue 相关的库打包到一起
|
||||
if (id.includes('node_modules')) {
|
||||
if (id.includes('element-plus')) {
|
||||
return 'element-plus'
|
||||
}
|
||||
if (id.includes('chart.js')) {
|
||||
return 'chart'
|
||||
}
|
||||
if (id.includes('vue') || id.includes('pinia') || id.includes('vue-router')) {
|
||||
return 'vue-vendor'
|
||||
}
|
||||
return 'vendor'
|
||||
}
|
||||
if (id.includes('chart.js')) {
|
||||
return 'chart'
|
||||
}
|
||||
if (id.includes('vue') || id.includes('pinia') || id.includes('vue-router')) {
|
||||
return 'vue-vendor'
|
||||
}
|
||||
return 'vendor'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user