Compare commits

...
5 Commits
Author SHA1 Message Date
wonder 91fa5a7bf2 ✨Feat: 增加 Card 组件 2026-03-24 11:59:20 +08:00
wonder fe966d876f 🔧Chore: 配置跨域 2026-03-24 11:56:25 +08:00
wonder 0200ca99b2 ✨Feat: 导入heroui组件库和tailwindcss 2026-03-24 11:12:33 +08:00
wonder 1c860d0957 🔧Chore: 清理冗余内容 2026-03-23 22:47:41 +08:00
wonder 902d1e24ea ✨Feat: 前端项目初始化 2026-03-23 22:33:30 +08:00
26 changed files with 5933 additions and 1 deletions
View File
View File
+3 -1
View File
@@ -2,6 +2,7 @@ package main
import ( import (
handle "agent/handlers" handle "agent/handlers"
"agent/middlewares"
"context" "context"
"fmt" "fmt"
"log" "log"
@@ -16,7 +17,7 @@ import (
var ( var (
apiKey string apiKey string
baseUrl string baseUrl string
model = "stepfun-ai/Step-3.5-Flash" model = "Pro/zai-org/GLM-4.7"
ctx context.Context ctx context.Context
llm llms.Model llm llms.Model
) )
@@ -46,6 +47,7 @@ func init() {
func main() { func main() {
route := gin.Default() route := gin.Default()
route.Use(middlewares.Cors())
route.GET("/ping", func(c *gin.Context) { route.GET("/ping", func(c *gin.Context) {
c.JSON(200, gin.H{ c.JSON(200, gin.H{
"message": "pong", "message": "pong",
+21
View File
@@ -0,0 +1,21 @@
package middlewares
import (
"net/http"
"github.com/gin-gonic/gin"
)
func Cors() gin.HandlerFunc {
return func(c *gin.Context) {
c.Header("Access-Control-Allow-Origin", "*") // 可替换为具体域名
c.Header("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE")
c.Header("Access-Control-Allow-Headers", "Origin, Content-Type, Authorization")
c.Header("Access-Control-Allow-Credentials", "true")
if c.Request.Method == "OPTIONS" {
c.AbortWithStatus(http.StatusNoContent)
return
}
c.Next()
}
}
+24
View File
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
dist
dist-ssr
*.local
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
+23
View File
@@ -0,0 +1,23 @@
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 { defineConfig, globalIgnores } from 'eslint/config'
export default defineConfig([
globalIgnores(['dist']),
{
files: ['**/*.{ts,tsx}'],
extends: [
js.configs.recommended,
tseslint.configs.recommended,
reactHooks.configs.flat.recommended,
reactRefresh.configs.vite,
],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
},
},
])
+13
View File
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="img/png" href="./icon-128x128.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Here we GO !!! 🎉</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="./src/main.tsx"></script>
</body>
</html>
+5673
View File
File diff suppressed because it is too large Load Diff
+36
View File
@@ -0,0 +1,36 @@
{
"name": "frontend",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc -b && vite build",
"lint": "eslint .",
"preview": "vite preview"
},
"dependencies": {
"@heroui/react": "^3.0.1",
"@heroui/styles": "^3.0.1",
"react": "^19.2.4",
"react-dom": "^19.2.4"
},
"devDependencies": {
"@eslint/js": "^9.39.4",
"@tailwindcss/postcss": "^4.2.2",
"@types/node": "^24.12.0",
"@types/react": "^19.2.14",
"@types/react-dom": "^19.2.3",
"@vitejs/plugin-react": "^6.0.1",
"autoprefixer": "^10.4.27",
"eslint": "^9.39.4",
"eslint-plugin-react-hooks": "^7.0.1",
"eslint-plugin-react-refresh": "^0.5.2",
"globals": "^17.4.0",
"postcss": "^8.5.8",
"tailwindcss": "^4.2.2",
"typescript": "~5.9.3",
"typescript-eslint": "^8.57.0",
"vite": "^8.0.1"
}
}
+5
View File
@@ -0,0 +1,5 @@
export default {
plugins: {
'@tailwindcss/postcss': {},
},
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

+11
View File
@@ -0,0 +1,11 @@
import Card from "./components/Card"
function App() {
return (
<><Card /></>
)
}
export default App
+44
View File
@@ -0,0 +1,44 @@
import {ScrollShadow} from "@heroui/react";
import { useEffect, useState } from "react";
export default function Card() {
// Data
const [data, setData] = useState(null)
const [loading, setLoading] = useState(true)
// Load Data
useEffect(() => {
const fetchData = async () => {
try {
const response = await fetch('http://localhost:8080/agent/card/你好')
if (!response.ok) {
throw new Error('API Error');
}
const result = await response.json();
setData(result);
} catch (error) {
console.error("Failed to fetch data: ", error);
} finally {
setLoading(false);
}
};
fetchData();
}, []);
return (
<div className="w-full p-0 sm:max-w-sm">
<ScrollShadow className="max-h-[500px] p-10">
<div className="space-y-4">
{loading ? (
// 3. 加载状态显示 Loading...
<p className="text-center text-gray-500">Loading data...</p>
) : (
// 4. 渲染从 API 获取的数据
<pre>{data?.message}</pre>
)}
</div>
</ScrollShadow>
</div>
);
}
+2
View File
@@ -0,0 +1,2 @@
@import "tailwindcss/theme";
@import "@heroui/styles";
+10
View File
@@ -0,0 +1,10 @@
import './global.css'
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import App from './App.tsx'
createRoot(document.getElementById('root')!).render(
<StrictMode>
<App />
</StrictMode>,
)
+28
View File
@@ -0,0 +1,28 @@
{
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
"target": "ES2023",
"useDefineForClassFields": true,
"lib": ["ES2023", "DOM", "DOM.Iterable"],
"module": "ESNext",
"types": ["vite/client"],
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"moduleDetection": "force",
"noEmit": true,
"jsx": "react-jsx",
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"erasableSyntaxOnly": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true
},
"include": ["src"]
}
+7
View File
@@ -0,0 +1,7 @@
{
"files": [],
"references": [
{ "path": "./tsconfig.app.json" },
{ "path": "./tsconfig.node.json" }
]
}
+26
View File
@@ -0,0 +1,26 @@
{
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
"target": "ES2023",
"lib": ["ES2023"],
"module": "ESNext",
"types": ["node"],
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"moduleDetection": "force",
"noEmit": true,
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"erasableSyntaxOnly": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true
},
"include": ["vite.config.ts"]
}
+7
View File
@@ -0,0 +1,7 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
// https://vite.dev/config/
export default defineConfig({
plugins: [react()],
})