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