forked from ChatGPTNextWeb/NextChat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 移除直接在 .env 中设置公告内容的方式- 新增 ANNOUNCEMENT_PATH环境变量,用于指定公告文件路径 - 在服务器端读取公告文件内容并生成哈希值 - 客户端根据哈希值判断是否有新公告- 优化公告弹窗组件,支持动态加载公告内容
- Loading branch information
1 parent
92b7fc4
commit f8d1692
Showing
8 changed files
with
41 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,17 @@ | ||
import fs from "fs/promises"; | ||
import crypto from "crypto"; | ||
import { NextResponse } from "next/server"; | ||
function generateHash(input: string) { | ||
return crypto.createHash("sha256").update(input).digest("hex"); | ||
} | ||
async function handler(req: any, res: any) { | ||
// 定义文件路径 | ||
if (process.env.ANNOUNCEMENT_PATH) { | ||
const filePath = process.env.ANNOUNCEMENT_PATH; | ||
const data = await fs.readFile(filePath, "utf8"); | ||
return NextResponse.json({ content: data }); | ||
return NextResponse.json({ content: data, hash: generateHash(data) }); | ||
} | ||
return NextResponse.json({ content: "" }); | ||
return NextResponse.json({ content: "", hash: "" }); | ||
} | ||
export const GET = handler; | ||
export const POST = handler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters