Merge pull request #194 from Icyoung/dev

Remote auth for prompt templates
This commit is contained in:
tinkle-community
2025-11-01 20:34:32 +08:00
committed by GitHub
2 changed files with 5 additions and 9 deletions
+4 -3
View File
@@ -84,6 +84,10 @@ func (s *Server) setupRoutes() {
// 系统配置(无需认证) // 系统配置(无需认证)
api.GET("/config", s.handleGetSystemConfig) api.GET("/config", s.handleGetSystemConfig)
// 系统提示词模板管理(无需认证)
api.GET("/prompt-templates", s.handleGetPromptTemplates)
api.GET("/prompt-templates/:name", s.handleGetPromptTemplate)
// 需要认证的路由 // 需要认证的路由
protected := api.Group("/", s.authMiddleware()) protected := api.Group("/", s.authMiddleware())
@@ -110,9 +114,6 @@ func (s *Server) setupRoutes() {
protected.GET("/user/signal-sources", s.handleGetUserSignalSource) protected.GET("/user/signal-sources", s.handleGetUserSignalSource)
protected.POST("/user/signal-sources", s.handleSaveUserSignalSource) protected.POST("/user/signal-sources", s.handleSaveUserSignalSource)
// 系统提示词模板管理
protected.GET("/prompt-templates", s.handleGetPromptTemplates)
protected.GET("/prompt-templates/:name", s.handleGetPromptTemplate)
// 竞赛总览 // 竞赛总览
protected.GET("/competition", s.handleCompetition) protected.GET("/competition", s.handleCompetition)
+1 -6
View File
@@ -120,12 +120,7 @@ export function TraderConfigModal({
useEffect(() => { useEffect(() => {
const fetchPromptTemplates = async () => { const fetchPromptTemplates = async () => {
try { try {
const token = localStorage.getItem('token'); const response = await fetch('/api/prompt-templates');
const response = await fetch('/api/prompt-templates', {
headers: {
'Authorization': `Bearer ${token}`
}
});
const data = await response.json(); const data = await response.json();
if (data.templates) { if (data.templates) {
setPromptTemplates(data.templates); setPromptTemplates(data.templates);