feat: format
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/prettierrc",
|
||||
"semi": false,
|
||||
"singleQuote": true,
|
||||
"semi": true,
|
||||
"singleQuote": false,
|
||||
"tabWidth": 2,
|
||||
"useTabs": false,
|
||||
"printWidth": 100,
|
||||
|
@@ -1,102 +1,102 @@
|
||||
import js from '@eslint/js'
|
||||
import configPrettier from '@vue/eslint-config-prettier'
|
||||
import configTypeScript from '@vue/eslint-config-typescript'
|
||||
import pluginVue from 'eslint-plugin-vue'
|
||||
import js from "@eslint/js";
|
||||
import configPrettier from "@vue/eslint-config-prettier";
|
||||
import configTypeScript from "@vue/eslint-config-typescript";
|
||||
import pluginVue from "eslint-plugin-vue";
|
||||
|
||||
export default [
|
||||
{
|
||||
name: 'app/files-to-lint',
|
||||
files: ['**/*.{js,mjs,ts,mts,tsx,vue}'],
|
||||
name: "app/files-to-lint",
|
||||
files: ["**/*.{js,mjs,ts,mts,tsx,vue}"],
|
||||
},
|
||||
|
||||
{
|
||||
name: 'app/files-to-ignore',
|
||||
ignores: ['**/dist/**', '**/dist-ssr/**', '**/coverage/**', '**/node_modules/**', '**/*.d.ts'],
|
||||
name: "app/files-to-ignore",
|
||||
ignores: ["**/dist/**", "**/dist-ssr/**", "**/coverage/**", "**/node_modules/**", "**/*.d.ts"],
|
||||
},
|
||||
|
||||
// Base configurations
|
||||
js.configs.recommended,
|
||||
...pluginVue.configs['flat/essential'],
|
||||
...pluginVue.configs["flat/essential"],
|
||||
...configTypeScript(),
|
||||
configPrettier,
|
||||
|
||||
{
|
||||
languageOptions: {
|
||||
ecmaVersion: 'latest',
|
||||
sourceType: 'module',
|
||||
ecmaVersion: "latest",
|
||||
sourceType: "module",
|
||||
},
|
||||
rules: {
|
||||
// Vue 规则
|
||||
'vue/multi-word-component-names': 'off', // 允许单词组件名,适应现有代码
|
||||
'vue/no-unused-vars': 'error',
|
||||
'vue/no-unused-components': 'warn',
|
||||
'vue/component-definition-name-casing': ['error', 'PascalCase'],
|
||||
'vue/component-name-in-template-casing': ['warn', 'kebab-case'],
|
||||
'vue/prop-name-casing': ['error', 'camelCase'],
|
||||
'vue/attribute-hyphenation': ['error', 'always'],
|
||||
'vue/v-on-event-hyphenation': ['error', 'always'],
|
||||
'vue/html-self-closing': [
|
||||
'warn',
|
||||
"vue/multi-word-component-names": "off", // 允许单词组件名,适应现有代码
|
||||
"vue/no-unused-vars": "error",
|
||||
"vue/no-unused-components": "warn",
|
||||
"vue/component-definition-name-casing": ["error", "PascalCase"],
|
||||
"vue/component-name-in-template-casing": ["warn", "kebab-case"],
|
||||
"vue/prop-name-casing": ["error", "camelCase"],
|
||||
"vue/attribute-hyphenation": ["error", "always"],
|
||||
"vue/v-on-event-hyphenation": ["error", "always"],
|
||||
"vue/html-self-closing": [
|
||||
"warn",
|
||||
{
|
||||
html: {
|
||||
void: 'never',
|
||||
normal: 'always',
|
||||
component: 'always',
|
||||
void: "never",
|
||||
normal: "always",
|
||||
component: "always",
|
||||
},
|
||||
svg: 'always',
|
||||
math: 'always',
|
||||
svg: "always",
|
||||
math: "always",
|
||||
},
|
||||
],
|
||||
'vue/max-attributes-per-line': 'off',
|
||||
'vue/singleline-html-element-content-newline': 'off',
|
||||
'vue/multiline-html-element-content-newline': 'off',
|
||||
'vue/html-indent': ['error', 2],
|
||||
'vue/script-indent': ['error', 2],
|
||||
"vue/max-attributes-per-line": "off",
|
||||
"vue/singleline-html-element-content-newline": "off",
|
||||
"vue/multiline-html-element-content-newline": "off",
|
||||
"vue/html-indent": ["error", 2],
|
||||
"vue/script-indent": ["error", 2],
|
||||
|
||||
// Vue 3 Composition API 规则
|
||||
'vue/no-setup-props-destructure': 'error',
|
||||
'vue/prefer-import-from-vue': 'error',
|
||||
'vue/no-deprecated-slot-attribute': 'error',
|
||||
'vue/no-deprecated-slot-scope-attribute': 'error',
|
||||
"vue/no-setup-props-destructure": "error",
|
||||
"vue/prefer-import-from-vue": "error",
|
||||
"vue/no-deprecated-slot-attribute": "error",
|
||||
"vue/no-deprecated-slot-scope-attribute": "error",
|
||||
|
||||
// TypeScript 规则
|
||||
'@typescript-eslint/no-unused-vars': [
|
||||
'error',
|
||||
"@typescript-eslint/no-unused-vars": [
|
||||
"error",
|
||||
{
|
||||
argsIgnorePattern: '^_',
|
||||
varsIgnorePattern: '^_',
|
||||
caughtErrorsIgnorePattern: '^_',
|
||||
argsIgnorePattern: "^_",
|
||||
varsIgnorePattern: "^_",
|
||||
caughtErrorsIgnorePattern: "^_",
|
||||
},
|
||||
],
|
||||
'@typescript-eslint/explicit-function-return-type': 'off',
|
||||
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
||||
'@typescript-eslint/no-explicit-any': 'warn',
|
||||
'@typescript-eslint/no-non-null-assertion': 'warn',
|
||||
'@typescript-eslint/no-unused-expressions': 'error',
|
||||
"@typescript-eslint/explicit-function-return-type": "off",
|
||||
"@typescript-eslint/explicit-module-boundary-types": "off",
|
||||
"@typescript-eslint/no-explicit-any": "warn",
|
||||
"@typescript-eslint/no-non-null-assertion": "warn",
|
||||
"@typescript-eslint/no-unused-expressions": "error",
|
||||
|
||||
// 通用 JavaScript/TypeScript 规则
|
||||
'no-console': ['warn', { allow: ['warn', 'error'] }],
|
||||
'no-debugger': 'warn',
|
||||
'prefer-const': 'error',
|
||||
'no-var': 'error',
|
||||
'no-unused-vars': 'off', // 使用 TypeScript 版本
|
||||
eqeqeq: ['error', 'always'],
|
||||
curly: ['error', 'all'],
|
||||
'no-throw-literal': 'error',
|
||||
'prefer-promise-reject-errors': 'error',
|
||||
"no-console": ["warn", { allow: ["warn", "error"] }],
|
||||
"no-debugger": "warn",
|
||||
"prefer-const": "error",
|
||||
"no-var": "error",
|
||||
"no-unused-vars": "off", // 使用 TypeScript 版本
|
||||
eqeqeq: ["error", "always"],
|
||||
curly: ["error", "all"],
|
||||
"no-throw-literal": "error",
|
||||
"prefer-promise-reject-errors": "error",
|
||||
|
||||
// 开源项目最佳实践
|
||||
'no-eval': 'error',
|
||||
'no-implied-eval': 'error',
|
||||
'no-new-func': 'error',
|
||||
'no-script-url': 'error',
|
||||
'no-alert': 'warn',
|
||||
'no-duplicate-imports': 'error',
|
||||
'prefer-template': 'error',
|
||||
'object-shorthand': 'error',
|
||||
'prefer-arrow-callback': 'error',
|
||||
'arrow-spacing': 'error',
|
||||
'no-useless-return': 'error',
|
||||
"no-eval": "error",
|
||||
"no-implied-eval": "error",
|
||||
"no-new-func": "error",
|
||||
"no-script-url": "error",
|
||||
"no-alert": "warn",
|
||||
"no-duplicate-imports": "error",
|
||||
"prefer-template": "error",
|
||||
"object-shorthand": "error",
|
||||
"prefer-arrow-callback": "error",
|
||||
"arrow-spacing": "error",
|
||||
"no-useless-return": "error",
|
||||
},
|
||||
},
|
||||
]
|
||||
];
|
||||
|
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import Layout from '@/components/Layout.vue'
|
||||
import Layout from "@/components/Layout.vue";
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@@ -12,8 +12,8 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import NavBar from '@/components/NavBar.vue'
|
||||
import Logout from '@/components/Logout.vue'
|
||||
import NavBar from "@/components/NavBar.vue";
|
||||
import Logout from "@/components/Logout.vue";
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
@@ -3,19 +3,19 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { MenuOption } from 'naive-ui'
|
||||
import { h, computed } from 'vue'
|
||||
import { RouterLink, useRoute } from 'vue-router'
|
||||
import type { MenuOption } from "naive-ui";
|
||||
import { h, computed } from "vue";
|
||||
import { RouterLink, useRoute } from "vue-router";
|
||||
|
||||
const menuOptions: MenuOption[] = [
|
||||
renderMenuItem('dashboard', '仪表盘'),
|
||||
renderMenuItem('keys', '密钥管理'),
|
||||
renderMenuItem('logs', '日志'),
|
||||
renderMenuItem('settings', '系统设置'),
|
||||
]
|
||||
renderMenuItem("dashboard", "仪表盘"),
|
||||
renderMenuItem("keys", "密钥管理"),
|
||||
renderMenuItem("logs", "日志"),
|
||||
renderMenuItem("settings", "系统设置"),
|
||||
];
|
||||
|
||||
const route = useRoute()
|
||||
const activeMenu = computed(() => route.name)
|
||||
const route = useRoute();
|
||||
const activeMenu = computed(() => route.name);
|
||||
|
||||
function renderMenuItem(key: string, label: string): MenuOption {
|
||||
return {
|
||||
@@ -30,6 +30,6 @@ function renderMenuItem(key: string, label: string): MenuOption {
|
||||
{ default: () => label }
|
||||
),
|
||||
key,
|
||||
}
|
||||
};
|
||||
}
|
||||
</script>
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import naive from 'naive-ui'
|
||||
import { createApp } from 'vue'
|
||||
import App from './App.vue'
|
||||
import './style.css'
|
||||
import router from './utils/router'
|
||||
import naive from "naive-ui";
|
||||
import { createApp } from "vue";
|
||||
import App from "./App.vue";
|
||||
import "./style.css";
|
||||
import router from "./utils/router";
|
||||
|
||||
createApp(App).use(router).use(naive).mount('#app')
|
||||
createApp(App).use(router).use(naive).mount("#app");
|
||||
|
@@ -1,27 +1,27 @@
|
||||
import axios from 'axios'
|
||||
import axios from "axios";
|
||||
|
||||
const http = axios.create({
|
||||
baseURL: import.meta.env.VITE_API_BASE_URL,
|
||||
timeout: 10000,
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
})
|
||||
headers: { "Content-Type": "application/json" },
|
||||
});
|
||||
|
||||
// 请求拦截器
|
||||
http.interceptors.request.use(config => {
|
||||
const token = localStorage.getItem('token')
|
||||
const token = localStorage.getItem("token");
|
||||
if (token) {
|
||||
config.headers.Authorization = `Bearer ${token}`
|
||||
config.headers.Authorization = `Bearer ${token}`;
|
||||
}
|
||||
return config
|
||||
})
|
||||
return config;
|
||||
});
|
||||
|
||||
// 响应拦截器
|
||||
http.interceptors.response.use(
|
||||
response => response.data,
|
||||
error => {
|
||||
console.error('API Error:', error)
|
||||
return Promise.reject(error)
|
||||
console.error("API Error:", error);
|
||||
return Promise.reject(error);
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
export default http
|
||||
export default http;
|
||||
|
@@ -1,31 +1,31 @@
|
||||
import { createRouter, createWebHistory, type RouteRecordRaw } from 'vue-router'
|
||||
import { createRouter, createWebHistory, type RouteRecordRaw } from "vue-router";
|
||||
|
||||
const routes: Array<RouteRecordRaw> = [
|
||||
{
|
||||
path: '/',
|
||||
name: 'dashboard',
|
||||
component: () => import('@/views/Dashboard.vue'),
|
||||
path: "/",
|
||||
name: "dashboard",
|
||||
component: () => import("@/views/Dashboard.vue"),
|
||||
},
|
||||
{
|
||||
path: '/keys',
|
||||
name: 'keys',
|
||||
component: () => import('@/views/Keys.vue'),
|
||||
path: "/keys",
|
||||
name: "keys",
|
||||
component: () => import("@/views/Keys.vue"),
|
||||
},
|
||||
{
|
||||
path: '/logs',
|
||||
name: 'logs',
|
||||
component: () => import('@/views/Logs.vue'),
|
||||
path: "/logs",
|
||||
name: "logs",
|
||||
component: () => import("@/views/Logs.vue"),
|
||||
},
|
||||
{
|
||||
path: '/settings',
|
||||
name: 'settings',
|
||||
component: () => import('@/views/Settings.vue'),
|
||||
path: "/settings",
|
||||
name: "settings",
|
||||
component: () => import("@/views/Settings.vue"),
|
||||
},
|
||||
]
|
||||
];
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(import.meta.env.BASE_URL),
|
||||
routes,
|
||||
})
|
||||
});
|
||||
|
||||
export default router
|
||||
export default router;
|
||||
|
@@ -1,27 +1,27 @@
|
||||
import { isRef, reactive, toRef, type Ref } from 'vue'
|
||||
import { isRef, reactive, toRef, type Ref } from "vue";
|
||||
|
||||
type IntializeFunc<T> = () => T | Ref<T>
|
||||
type InitializeValue<T> = T | Ref<T> | IntializeFunc<T>
|
||||
type IntializeFunc<T> = () => T | Ref<T>;
|
||||
type InitializeValue<T> = T | Ref<T> | IntializeFunc<T>;
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
type GlobalState = Record<string, any>
|
||||
type GlobalState = Record<string, any>;
|
||||
|
||||
const globalState = reactive<GlobalState>({})
|
||||
const globalState = reactive<GlobalState>({});
|
||||
|
||||
export function useState<T>(key: string, init?: InitializeValue<T>): Ref<T> {
|
||||
const state = toRef(globalState, key)
|
||||
const state = toRef(globalState, key);
|
||||
|
||||
if (state.value === undefined && init !== undefined) {
|
||||
const initialValue = init instanceof Function ? init() : init
|
||||
const initialValue = init instanceof Function ? init() : init;
|
||||
|
||||
if (isRef(initialValue)) {
|
||||
// vue will unwrap the ref for us
|
||||
globalState[key] = initialValue
|
||||
globalState[key] = initialValue;
|
||||
|
||||
return initialValue
|
||||
return initialValue;
|
||||
}
|
||||
|
||||
state.value = initialValue
|
||||
state.value = initialValue;
|
||||
}
|
||||
|
||||
return state
|
||||
return state;
|
||||
}
|
||||
|
@@ -4,8 +4,8 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import BaseInfoCard from '@/components/BaseInfoCard.vue'
|
||||
import LineChart from '@/components/LineChart.vue'
|
||||
import BaseInfoCard from "@/components/BaseInfoCard.vue";
|
||||
import LineChart from "@/components/LineChart.vue";
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import path from 'path'
|
||||
import { defineConfig } from 'vite'
|
||||
import vue from "@vitejs/plugin-vue";
|
||||
import path from "path";
|
||||
import { defineConfig } from "vite";
|
||||
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig({
|
||||
@@ -9,23 +9,23 @@ export default defineConfig({
|
||||
resolve: {
|
||||
// 配置路径别名
|
||||
alias: {
|
||||
'@': path.resolve(__dirname, './src'),
|
||||
"@": path.resolve(__dirname, "./src"),
|
||||
},
|
||||
},
|
||||
// 开发服务器配置
|
||||
server: {
|
||||
// 代理配置示例
|
||||
proxy: {
|
||||
'/api': {
|
||||
target: 'http://api.example.com',
|
||||
"/api": {
|
||||
target: "http://api.example.com",
|
||||
changeOrigin: true,
|
||||
rewrite: path => path.replace(/^\/api/, ''),
|
||||
rewrite: path => path.replace(/^\/api/, ""),
|
||||
},
|
||||
},
|
||||
},
|
||||
// 构建配置
|
||||
build: {
|
||||
outDir: '../cmd/gpt-load/dist',
|
||||
assetsDir: 'assets',
|
||||
outDir: "../cmd/gpt-load/dist",
|
||||
assetsDir: "assets",
|
||||
},
|
||||
})
|
||||
});
|
||||
|
Reference in New Issue
Block a user