From 3225e84cff86a1b8c1be26670d545824b5989db6 Mon Sep 17 00:00:00 2001 From: zhangjianjun Date: Mon, 29 Jun 2026 17:27:58 +0800 Subject: [PATCH] ud --- api/news/list.ts | 8 ++++++++ data/const.ts | 3 +++ proxy.mjs | 5 +++++ views/history/list.tsx | 1 - views/jobs/list.tsx | 2 -- views/news/list.tsx | 5 ++++- 6 files changed, 20 insertions(+), 4 deletions(-) diff --git a/api/news/list.ts b/api/news/list.ts index 5c0fa18..19c252a 100644 --- a/api/news/list.ts +++ b/api/news/list.ts @@ -1,5 +1,6 @@ import Request from "lib/utils/requests"; import { translateApi, categoryApi, uploadApi } from '../common'; +import { REVALIDATE_SECRET } from '../../data/const'; export default { getDataList(params: any) { @@ -39,5 +40,12 @@ export default { getCategoryList: categoryApi.getDataList, ...translateApi, ...uploadApi, + revalidateCache(id: string | number) { + fetch('/revalidate', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ id, secret: REVALIDATE_SECRET }), + }).catch(() => {}) + }, } diff --git a/data/const.ts b/data/const.ts index d75a7ac..eb704f7 100644 --- a/data/const.ts +++ b/data/const.ts @@ -11,6 +11,9 @@ export const LOCALES = [ }, ]; +// Next.js 缓存刷新密钥 +export const REVALIDATE_SECRET = 'a6fa461b512dc9e8ece9a9fc2ed59debe50ee948fd430aaf688fbb060c7ec508' + // 分类 export const categoryTypes = [ { key: 'process', name: '历程', path: '/history' }, diff --git a/proxy.mjs b/proxy.mjs index 002b17e..c2cef22 100644 --- a/proxy.mjs +++ b/proxy.mjs @@ -8,5 +8,10 @@ export default { target: isDev ? "http://10.3.0.7:9999/" : 'http://yintai.batiao8.com/', changeOrigin: true, rewrite: (path) => path.replace(/^\/companyHome/, '') + }, + '/revalidate': { + target: 'https://www.china-yintai.com', + changeOrigin: true, + rewrite: (path) => path.replace(/^\/revalidate/, '/api/revalidate') } } diff --git a/views/history/list.tsx b/views/history/list.tsx index 0d3641f..3f820fc 100644 --- a/views/history/list.tsx +++ b/views/history/list.tsx @@ -101,7 +101,6 @@ const data: TableData = { [self.bean.processTypes] = results.map( (res) => toOptions(res?.data?.items ?? []) ) - console.log('processTypes', self.bean.processTypes) } } ], diff --git a/views/jobs/list.tsx b/views/jobs/list.tsx index d909f82..1e64a91 100644 --- a/views/jobs/list.tsx +++ b/views/jobs/list.tsx @@ -58,7 +58,6 @@ const data: TableData = { data[langKey][fieldKey] = langData[fieldKey]; }) }) - console.log('data', data) return data }} /> @@ -69,7 +68,6 @@ const data: TableData = { async (self: any) => { if (self.bean) { self.bean.id = null; - console.log('self.bean.jobTypes', self.bean.jobTypes) self.bean.form = [ { name: '职业类别', diff --git a/views/news/list.tsx b/views/news/list.tsx index 8f9af25..239a89a 100644 --- a/views/news/list.tsx +++ b/views/news/list.tsx @@ -46,8 +46,11 @@ const data: TableData = { if (data.id) { await self.api?.updateData(params) + self.api?.revalidateCache(data.id) } else { - await self.api?.addData(params) + const res = await self.api?.addData(params) + const newId = res?.data?.id + if (newId) self.api?.revalidateCache(newId) } self.bean.showEditorDialog = false; self.bean.id = null;