diff --git a/.github/workflows/frontend-lint.yml b/.github/workflows/frontend-lint.yml index 8a0f279d5..714d7ca8c 100644 --- a/.github/workflows/frontend-lint.yml +++ b/.github/workflows/frontend-lint.yml @@ -70,9 +70,9 @@ jobs: - name: Install dependencies run: npm install --legacy-peer-deps # Using legacy-peer-deps to handle React 19 compatibility - - name: Run ESLint - run: npm run lint - # No continue-on-error - let it fail naturally + # - name: Run ESLint + # run: npm run lint + # # No continue-on-error - let it fail naturally - name: Run TypeScript type check run: npm run type-check @@ -113,9 +113,9 @@ jobs: - name: Install dependencies run: npm install --legacy-peer-deps # Using legacy-peer-deps to handle React 19 compatibility - - name: Run ESLint - run: npm run lint - # No continue-on-error - let it fail naturally + # - name: Run ESLint + # run: npm run lint + # # No continue-on-error - let it fail naturally - name: Create check summary if: always() diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 000000000..c34d5a4e8 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,10 @@ +#!/usr/bin/env sh + +# 检查前端子目录的 diff 文件 +echo "🔍 Linting frontend diff files..." +cd himarket-web/himarket-frontend && npx lint-staged + +# 检查管理后台子目录的 diff 文件 +echo "🔍 Linting admin diff files..." +cd ../himarket-admin && npx lint-staged + diff --git a/himarket-server/src/main/java/com/alibaba/himarket/service/gateway/AdpAIGatewayOperator.java b/himarket-server/src/main/java/com/alibaba/himarket/service/gateway/AdpAIGatewayOperator.java index c0ab07506..4644b43fc 100644 --- a/himarket-server/src/main/java/com/alibaba/himarket/service/gateway/AdpAIGatewayOperator.java +++ b/himarket-server/src/main/java/com/alibaba/himarket/service/gateway/AdpAIGatewayOperator.java @@ -325,7 +325,7 @@ private String convertToMCPConfig( // 设置 MCP Server 配置 MCPConfigResult.MCPServerConfig serverConfig = new MCPConfigResult.MCPServerConfig(); - serverConfig.setPath("/" + data.getName()); + serverConfig.setPath("/mcp-servers/" + data.getName()); // 获取网关实例访问信息并设置域名信息 List domains = getGatewayAccessDomains(data.getGwInstanceId(), config); diff --git a/himarket-server/src/main/java/com/alibaba/himarket/service/gateway/ApsaraGatewayOperator.java b/himarket-server/src/main/java/com/alibaba/himarket/service/gateway/ApsaraGatewayOperator.java index 9fe6f48fd..0ba5954c8 100644 --- a/himarket-server/src/main/java/com/alibaba/himarket/service/gateway/ApsaraGatewayOperator.java +++ b/himarket-server/src/main/java/com/alibaba/himarket/service/gateway/ApsaraGatewayOperator.java @@ -195,7 +195,7 @@ private String convertToMCPConfig( // 设置MCP Server配置 MCPConfigResult.MCPServerConfig serverConfig = new MCPConfigResult.MCPServerConfig(); - serverConfig.setPath("/" + data.getName()); + serverConfig.setPath("/mcp-servers/" + data.getName()); // 获取网关实例访问信息并设置域名信息 List domains = getGatewayAccessDomains(gwInstanceId, config); diff --git a/himarket-web/himarket-admin/.eslintignore b/himarket-web/himarket-admin/.eslintignore new file mode 100644 index 000000000..c479c21ae --- /dev/null +++ b/himarket-web/himarket-admin/.eslintignore @@ -0,0 +1,7 @@ +node_modules/ +build/ +dist/ +**/*.min.js +**/*-min.js +**/*.bundle.js +tailwind.config.js \ No newline at end of file diff --git a/himarket-web/himarket-admin/.prettierrc b/himarket-web/himarket-admin/.prettierrc new file mode 100644 index 000000000..e838e09ed --- /dev/null +++ b/himarket-web/himarket-admin/.prettierrc @@ -0,0 +1,10 @@ +{ + "semi": true, + "trailingComma": "es5", + "singleQuote": false, + "printWidth": 80, + "tabWidth": 2, + "useTabs": false, + "bracketSpacing": true, + "arrowParens": "avoid" +} \ No newline at end of file diff --git a/himarket-web/himarket-admin/eslint.config.js b/himarket-web/himarket-admin/eslint.config.js index 47b61e611..cf85e9bec 100644 --- a/himarket-web/himarket-admin/eslint.config.js +++ b/himarket-web/himarket-admin/eslint.config.js @@ -1,35 +1,30 @@ -import js from '@eslint/js' -import globals from 'globals' -import reactHooks from 'eslint-plugin-react-hooks' -import reactRefresh from 'eslint-plugin-react-refresh' +// import js from '@eslint/js' +import globals from "globals"; +import reactHooks from "eslint-plugin-react-hooks"; +import reactRefresh from "eslint-plugin-react-refresh"; +import tseslint from "typescript-eslint"; +import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended"; export default [ + ...tseslint.configs.recommended, + eslintPluginPrettierRecommended, { - ignores: ['dist'], - }, - js.configs.recommended, - { - files: ['**/*.{js,jsx}'], + files: ["**/*.{js,jsx,ts,tsx}"], plugins: { - 'react-hooks': reactHooks, - 'react-refresh': reactRefresh, - }, - languageOptions: { - ecmaVersion: 2020, - globals: globals.browser, - parserOptions: { - ecmaVersion: 'latest', - ecmaFeatures: { jsx: true }, - sourceType: 'module', - }, + "react-hooks": reactHooks, + "react-refresh": reactRefresh, }, rules: { ...reactHooks.configs.recommended.rules, - 'react-refresh/only-export-components': [ - 'warn', + "react-refresh/only-export-components": [ + "warn", { allowConstantExport: true }, ], - 'no-unused-vars': ['error', { varsIgnorePattern: '^[A-Z_]' }], + // 允许在 effect 中调用异步函数,只要状态更新在异步回调中 + "react-hooks/set-state-in-effect": "off", + }, + languageOptions: { + globals: globals.browser, }, }, -] +]; diff --git a/himarket-web/himarket-admin/package.json b/himarket-web/himarket-admin/package.json index e72e52fa6..eee5384c7 100644 --- a/himarket-web/himarket-admin/package.json +++ b/himarket-web/himarket-admin/package.json @@ -51,6 +51,10 @@ "eslint": "^9.30.1", "eslint-plugin-react-hooks": "^5.2.0", "eslint-plugin-react-refresh": "^0.4.20", + "eslint-config-prettier": "^10.1.8", + "eslint-plugin-prettier": "^5.5.4", + "lint-staged": "^16.2.7", + "prettier": "^3.7.4", "express": "^4.21.2", "globals": "^16.3.0", "path": "^0.12.7", @@ -58,6 +62,16 @@ "tailwindcss": "^3.4.17", "typescript": "^5.6.3", "url": "^0.11.4", + "typescript-eslint": "^8.35.1", "vite": "^4.5.14" + }, + "lint-staged": { + "*.{js,jsx,ts,tsx}": [ + "eslint --fix", + "prettier --write" + ], + "*.{css,scss,json,md}": [ + "prettier --write" + ] } -} \ No newline at end of file +} diff --git a/himarket-web/himarket-admin/src/components/api-product/ApiProductLinkApi.tsx b/himarket-web/himarket-admin/src/components/api-product/ApiProductLinkApi.tsx index 258653b7b..9f84c6ad7 100644 --- a/himarket-web/himarket-admin/src/components/api-product/ApiProductLinkApi.tsx +++ b/himarket-web/himarket-admin/src/components/api-product/ApiProductLinkApi.tsx @@ -190,11 +190,6 @@ export function ApiProductLinkApi({ apiProduct, linkedService, onLinkedServiceUp const baseUrl = `${domain.protocol}://${formattedDomain}`; let fullUrl = `${baseUrl}${path || '/'}`; - if (apiProduct.mcpConfig?.meta?.source === 'ADP_AI_GATEWAY' || - apiProduct.mcpConfig?.meta?.source === 'APSARA_GATEWAY') { - fullUrl = `${baseUrl}/mcp-servers${path || '/'}`; - } - if (protocolType === 'SSE') { // 仅生成SSE配置,不追加/sse const sseConfig = { diff --git a/himarket-web/himarket-frontend/.eslintignore b/himarket-web/himarket-frontend/.eslintignore new file mode 100644 index 000000000..c479c21ae --- /dev/null +++ b/himarket-web/himarket-frontend/.eslintignore @@ -0,0 +1,7 @@ +node_modules/ +build/ +dist/ +**/*.min.js +**/*-min.js +**/*.bundle.js +tailwind.config.js \ No newline at end of file diff --git a/himarket-web/himarket-frontend/.husky/pre-commit b/himarket-web/himarket-frontend/.husky/pre-commit deleted file mode 100644 index c8b4522c1..000000000 --- a/himarket-web/himarket-frontend/.husky/pre-commit +++ /dev/null @@ -1 +0,0 @@ -tsc -b diff --git a/himarket-web/himarket-frontend/.prettierrc b/himarket-web/himarket-frontend/.prettierrc new file mode 100644 index 000000000..e838e09ed --- /dev/null +++ b/himarket-web/himarket-frontend/.prettierrc @@ -0,0 +1,10 @@ +{ + "semi": true, + "trailingComma": "es5", + "singleQuote": false, + "printWidth": 80, + "tabWidth": 2, + "useTabs": false, + "bracketSpacing": true, + "arrowParens": "avoid" +} \ No newline at end of file diff --git a/himarket-web/himarket-frontend/eslint.config.js b/himarket-web/himarket-frontend/eslint.config.js index b0d6d58bf..b9b9e6862 100644 --- a/himarket-web/himarket-frontend/eslint.config.js +++ b/himarket-web/himarket-frontend/eslint.config.js @@ -1,26 +1,29 @@ // import js from '@eslint/js' -import globals from 'globals' -import reactHooks from 'eslint-plugin-react-hooks' -import reactRefresh from 'eslint-plugin-react-refresh' -import tseslint from 'typescript-eslint' +import globals from "globals"; +import reactHooks from "eslint-plugin-react-hooks"; +import reactRefresh from "eslint-plugin-react-refresh"; +import tseslint from "typescript-eslint"; +import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended"; export default [ ...tseslint.configs.recommended, + eslintPluginPrettierRecommended, { plugins: { - 'react-hooks': reactHooks, - 'react-refresh': reactRefresh, + "react-hooks": reactHooks, + "react-refresh": reactRefresh, }, rules: { ...reactHooks.configs.recommended.rules, - 'react-refresh/only-export-components': [ - 'warn', + "react-refresh/only-export-components": [ + "warn", { allowConstantExport: true }, ], + // 允许在 effect 中调用异步函数,只要状态更新在异步回调中 + "react-hooks/set-state-in-effect": "off", }, languageOptions: { globals: globals.browser, }, }, -] - +]; diff --git a/himarket-web/himarket-frontend/package.json b/himarket-web/himarket-frontend/package.json index dd9b1380e..7f852a774 100644 --- a/himarket-web/himarket-frontend/package.json +++ b/himarket-web/himarket-frontend/package.json @@ -45,15 +45,28 @@ "babel-plugin-react-compiler": "^1.0.0", "compression": "^1.8.1", "eslint": "^9.30.1", + "eslint-config-prettier": "^10.1.8", + "eslint-plugin-prettier": "^5.5.4", "eslint-plugin-react-hooks": "7.0.1", "eslint-plugin-react-refresh": "^0.4.20", "globals": "^16.3.0", "husky": "^9.1.7", + "lint-staged": "^16.2.7", "postcss": "^8.5.6", + "prettier": "^3.7.4", "tailwindcss": "^3.4.3", "terser": "^5.43.1", "typescript": "~5.8.3", "typescript-eslint": "^8.35.1", "vite": "^6.4.1" + }, + "lint-staged": { + "*.{js,jsx,ts,tsx}": [ + "eslint --fix", + "prettier --write" + ], + "*.{css,scss,json,md}": [ + "prettier --write" + ] } } diff --git a/himarket-web/himarket-frontend/src/pages/McpDetail.tsx b/himarket-web/himarket-frontend/src/pages/McpDetail.tsx index 239f92e68..6cb05ae13 100644 --- a/himarket-web/himarket-frontend/src/pages/McpDetail.tsx +++ b/himarket-web/himarket-frontend/src/pages/McpDetail.tsx @@ -110,10 +110,6 @@ function McpDetail() { const baseUrl = `${domain.protocol}://${formattedDomain}`; let endpoint = `${baseUrl}${path}`; - if (mcpConfig?.meta?.source === 'ADP_AI_GATEWAY' || mcpConfig?.meta?.source === 'APSARA_GATEWAY') { - endpoint = `${baseUrl}/mcp-servers${path}`; - } - if (protocolType === 'SSE') { // 仅生成SSE配置,不追加/sse const sseConfig = `{