diff --git a/astrbot/dashboard/server.py b/astrbot/dashboard/server.py index 2b6040aa3..c7e7be3c0 100644 --- a/astrbot/dashboard/server.py +++ b/astrbot/dashboard/server.py @@ -151,7 +151,7 @@ class AstrBotDashboard: @self.app.route("/") async def index(): if not self.enable_webui: - return "WebUI is disabled." + return "Buildin WebUI is disabled." try: return await self.app.send_static_file("index.html") except werkzeug.exceptions.NotFound: @@ -161,7 +161,7 @@ class AstrBotDashboard: @self.app.errorhandler(404) async def not_found(e): if not self.enable_webui: - return "WebUI is disabled." + return "Buildin WebUI is disabled." if request.path.startswith("/api/"): return jsonify(Response().error("Not Found").to_json()), 404 try: diff --git a/dashboard/.eslintignore b/dashboard/.eslintignore new file mode 100644 index 000000000..3e7871a3a --- /dev/null +++ b/dashboard/.eslintignore @@ -0,0 +1,29 @@ +# ESLint ignore file for AstrBot dashboard +# Skip dependency directories and build artifacts + +node_modules/ +dist/ +build/ +public/ +coverage/ +.vite/ +.cache/ +*.min.js +*.bundle.js +*.map + +# Dashboard-specific artifacts (when lint is run from repo root using --prefix) +dashboard/dist/ +dashboard/node_modules/ + +# Generated TypeScript declaration used by environment - can cause parser issues in some setups +env.d.ts + +# Scripts and tooling files (often use newer syntax or are run in node env) +scripts/**/*.mjs +scripts/**/*.cjs + +# Misc +*.log +.idea/ +.vscode/ diff --git a/dashboard/.eslintrc.cjs b/dashboard/.eslintrc.cjs new file mode 100644 index 000000000..28944a0f4 --- /dev/null +++ b/dashboard/.eslintrc.cjs @@ -0,0 +1,149 @@ +module.exports = { + root: true, + env: { + browser: true, + node: true, + es2021: true, + }, + + // Use vue-eslint-parser so .vue SFCs are parsed correctly. + parser: "vue-eslint-parser", + + parserOptions: { + // vue-eslint-parser will forward the script content to this parser + parser: "@typescript-eslint/parser", + ecmaVersion: "latest", + sourceType: "module", + extraFileExtensions: [".vue"], + ecmaFeatures: { + jsx: true, + }, + // NOTE: Intentionally NO `project` here to avoid requiring type-aware linting. + // This keeps eslint fast and avoids the TSConfig inclusion errors. + }, + + plugins: ["vue", "@typescript-eslint"], + + extends: [ + "eslint:recommended", + "plugin:vue/vue3-recommended", + "plugin:@typescript-eslint/recommended", + // Intentionally not extending type-aware or prettier-requiring configs. + ], + + settings: { + // Allow using Vue compiler macros like defineProps/defineEmits in templates + "vue/setup-compiler-macros": true, + }, + + // Avoid linting build artifacts and generated files + ignorePatterns: [ + "dist/", + "build/", + "node_modules/", + "public/", + "dashboard/dist/", + "dashboard/node_modules/", + "env.d.ts", + "scripts/**/*.mjs", + ".vite/", + ".cache/", + ], + + rules: { + // Keep console/debug permissible but warned + "no-console": ["warn", { allow: ["warn", "error", "info"] }], + "no-debugger": "warn", + + // TypeScript rules (relaxed) + "@typescript-eslint/no-unused-vars": [ + "warn", + { + argsIgnorePattern: "^_", + varsIgnorePattern: "^_", + caughtErrorsIgnorePattern: "^_", + }, + ], + "@typescript-eslint/explicit-module-boundary-types": "off", + "@typescript-eslint/no-explicit-any": "off", + + // Vue rules adjustments — relax a few rules that generate a lot of noise + // These are intentionally relaxed to allow incremental, safe fixes of template code. + "vue/multi-word-component-names": "off", + "vue/html-self-closing": [ + "error", + { + html: { + void: "never", + normal: "always", + component: "always", + }, + svg: "always", + math: "always", + }, + ], + + // Reduce template noise for legacy / Vuetify patterns used across this codebase + "vue/valid-v-slot": "off", + "vue/v-on-event-hyphenation": "off", + "vue/no-unused-components": "off", + // Broadly disable unused vars detection for templates to avoid false positives from compiled/generated template usage + "vue/no-unused-vars": "off", + "vue/require-default-prop": "off", + // Keep v-html as a warn so security-sensitive usage is highlighted + "vue/no-v-html": "warn", + }, + + overrides: [ + // Vue Single File Components + { + files: ["*.vue", "src/**/*.vue"], + parser: "vue-eslint-parser", + parserOptions: { + parser: "@typescript-eslint/parser", + extraFileExtensions: [".vue"], + ecmaVersion: "latest", + sourceType: "module", + // Enable type-aware rules for script blocks inside .vue files + project: "./tsconfig.eslint.json", + tsconfigRootDir: __dirname, + }, + rules: { + // Component/template specific overrides can go here + }, + }, + + // TypeScript files (no project required) + { + files: ["*.ts", "*.tsx", "src/**/*.ts", "src/**/*.tsx"], + parser: "@typescript-eslint/parser", + parserOptions: { + ecmaVersion: "latest", + sourceType: "module", + // Use type-aware linting for TS files via the dedicated tsconfig for ESLint + project: "./tsconfig.eslint.json", + tsconfigRootDir: __dirname, + }, + rules: { + // Project-specific relaxations for TS files + }, + }, + + // Node scripts / tooling + { + files: ["scripts/**/*.mjs", "scripts/**/*.cjs", "*.cjs"], + env: { node: true }, + parserOptions: { sourceType: "module" }, + }, + // Disable strict v-slot validation for extension component panels where shorthand slots are used + { + files: [ + "src/components/extension/componentPanel/**", + "src/components/extension/**", + ], + rules: { + "vue/valid-v-slot": "off", + }, + }, + ], +}; diff --git a/dashboard/src/App.vue b/dashboard/src/App.vue index 4822d8489..12c622e4a 100644 --- a/dashboard/src/App.vue +++ b/dashboard/src/App.vue @@ -1,14 +1,28 @@