From de477f5e6b98a93e225c22a5a40d377c3c74344a Mon Sep 17 00:00:00 2001 From: Jye10032 <736891807@qq.com> Date: Sun, 15 Mar 2026 17:42:52 +0800 Subject: [PATCH 1/3] test: update request error assertion for app message bridge --- src/test/utils/Request.test.js | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/test/utils/Request.test.js b/src/test/utils/Request.test.js index 3e42d82..e580f51 100644 --- a/src/test/utils/Request.test.js +++ b/src/test/utils/Request.test.js @@ -1,6 +1,5 @@ import { describe, it, expect, beforeEach, vi, afterEach } from 'vitest' import axios from 'axios' -import { message } from 'antd' import api from '../../utils/Request' import { __mockDispatch as mockDispatch } from '../../redux/store' @@ -19,18 +18,11 @@ vi.mock('../../redux/store', () => { } }) -// Mock antd message -vi.mock('antd', () => ({ - message: { - error: vi.fn() - } -})) - describe('Axios 拦截器', () => { beforeEach(() => { // 清空所有 mock 调用记录 mockDispatch.mockClear() - message.error.mockClear() + vi.spyOn(console, 'error').mockImplementation(() => {}) }) afterEach(() => { @@ -271,7 +263,7 @@ describe('Axios 拦截器', () => { } await expect(api.get('/fail')).rejects.toThrow('Server Error') - expect(message.error).toHaveBeenCalledWith('请求失败') + expect(console.error).toHaveBeenCalledWith('请求失败') expect(mockDispatch).toHaveBeenCalledWith({ type: 'loading_end' }) }) }) From bf182058a7b5c9c82e567f880c214b58db9eedd8 Mon Sep 17 00:00:00 2001 From: Jye10032 <736891807@qq.com> Date: Tue, 17 Mar 2026 19:32:48 +0800 Subject: [PATCH 2/3] chore: replace tracked env files with env example --- .env | 4 ---- .env.development | 2 -- .env.example | 32 ++++++++++++++++++++++++++++++++ .env.production | 3 --- 4 files changed, 32 insertions(+), 9 deletions(-) delete mode 100644 .env delete mode 100644 .env.development create mode 100644 .env.example delete mode 100644 .env.production diff --git a/.env b/.env deleted file mode 100644 index ced8e40..0000000 --- a/.env +++ /dev/null @@ -1,4 +0,0 @@ -# 开发环境变量 -VITE_API_BASE_URL=http://localhost:8000 -VITE_APP_TITLE=新闻管理系统 -VITE_APP_VERSION=1.0.0 diff --git a/.env.development b/.env.development deleted file mode 100644 index 96212e0..0000000 --- a/.env.development +++ /dev/null @@ -1,2 +0,0 @@ -# 开发环境配置 -VITE_API_BASE_URL=http://localhost:8000 diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..ce10ead --- /dev/null +++ b/.env.example @@ -0,0 +1,32 @@ +# Frontend build-time variables (Vite) +VITE_PORT=3000 +VITE_API_BASE_URL=http://localhost:8000 +VITE_PROXY_TARGET=http://localhost:8000 +VITE_APP_TITLE=NewsSystemPro +VITE_APP_VERSION=1.0.0 + +# Backend runtime variables (Express / serverless API) +PORT=8000 +FRONTEND_ORIGINS=http://localhost:3000,http://localhost:5173 +ALLOWED_ORIGINS=http://localhost:3000,http://localhost:5173,https://your-github-pages-domain.github.io +JWT_SECRET=replace-with-a-long-random-secret + +# AI routes / moderation / normalization +AI_ROUTES_ENABLED=false +AI_REVIEW_API_BASE_URL=https://api.openai.com/v1 +AI_REVIEW_API_KEY=replace-with-your-api-key +AI_REVIEW_MODEL=gpt-4o-mini +AI_BRIEF_MODEL=gpt-4o-mini +AI_NORMALIZE_MODEL=gpt-4o-mini +AI_MODERATION_MODEL=omni-moderation-latest + +# Crawl ingest +INGEST_TOKEN=replace-with-a-long-random-ingest-token +INGEST_REFRESH_ON_DUPLICATE=false +INGEST_MAX_CONTENT_CHARS=120000 + +# Optional LLM Guard runtime +LLM_GUARD_ENABLED=false +LLM_GUARD_PYTHON_BIN=python3 +LLM_GUARD_TIMEOUT_MS=6000 +LLM_GUARD_MAX_TEXT_CHARS=5000 diff --git a/.env.production b/.env.production deleted file mode 100644 index bf61d2a..0000000 --- a/.env.production +++ /dev/null @@ -1,3 +0,0 @@ -# 生产环境配置 -# 后端API地址(已部署到 Vercel) -VITE_API_BASE_URL=https://news-system-pro.vercel.app From 050f9d4257d0c3b1d51d31dde0554eb9498197e3 Mon Sep 17 00:00:00 2001 From: Jye10032 <736891807@qq.com> Date: Wed, 22 Apr 2026 15:47:07 +0800 Subject: [PATCH 3/3] =?UTF-8?q?feat=EF=BC=9A=E9=83=A8=E7=BD=B2=E5=88=B0?= =?UTF-8?q?=E5=9F=9F=E5=90=8D=E7=9A=84=20path=20=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/404.html | 5 +++-- vite.config.js | 25 +++++++++++++++++++------ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/public/404.html b/public/404.html index 704909d..3b5f9c5 100644 --- a/public/404.html +++ b/public/404.html @@ -5,10 +5,11 @@
正在加载...
diff --git a/vite.config.js b/vite.config.js index 98a1d3b..3f03b63 100644 --- a/vite.config.js +++ b/vite.config.js @@ -1,11 +1,23 @@ -import { defineConfig } from 'vite' +import { defineConfig, loadEnv } from 'vite' import react from '@vitejs/plugin-react' import path from 'path' -export default defineConfig(({ mode }) => ({ - // GitHub Pages 部署时需要设置 base - // 本地开发时为 '/', 部署到 GitHub Pages 时为 '/仓库名/' - base: mode === 'production' ? '/NewsSystemPro/' : '/', +const normalizeBasePath = (value) => { + if (!value || value === '/') { + return '/' + } + + const trimmed = value.replace(/^\/+|\/+$/g, '') + return `/${trimmed}/` +} + +export default defineConfig(({ mode }) => { + const env = loadEnv(mode, process.cwd(), '') + const basePath = normalizeBasePath(env.VITE_BASE_PATH) + + return { + // 允许通过 VITE_BASE_PATH 在根域名和子路径部署间切换 + base: basePath, plugins: [ react({ @@ -119,4 +131,5 @@ export default defineConfig(({ mode }) => ({ ], }, }, -})) + } +})