hotfix #59
14
app/assistant.go
Normal file
14
app/assistant.go
Normal file
@ -0,0 +1,14 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// SaveAssistant
|
||||
// @description: 保存AI助手
|
||||
// @param ctx
|
||||
func SaveAssistant(ctx *gin.Context) {
|
||||
|
||||
//ctx.String(http.StatusOK, "操作成功")
|
||||
ctx.Redirect(302, "/assistant.html")
|
||||
}
|
15
app/pages.go
15
app/pages.go
@ -92,6 +92,21 @@ func Group(ctx *gin.Context) {
|
||||
ctx.HTML(http.StatusOK, "group.html", result)
|
||||
}
|
||||
|
||||
// Assistant
|
||||
// @description: AI角色
|
||||
// @param ctx
|
||||
func Assistant(ctx *gin.Context) {
|
||||
var result = gin.H{
|
||||
"msg": "success",
|
||||
}
|
||||
|
||||
result["aiModels"] = config.Conf.Ai.Models
|
||||
result["assistant"], _ = service.GetAllAiAssistant()
|
||||
|
||||
// 渲染页面
|
||||
ctx.HTML(http.StatusOK, "assistant.html", result)
|
||||
}
|
||||
|
||||
// PageNotFound
|
||||
// @description: 404页面
|
||||
// @param ctx
|
||||
|
2
main.go
2
main.go
@ -48,6 +48,8 @@ func main() {
|
||||
return "群组列表"
|
||||
case "index":
|
||||
return "首页"
|
||||
case "assistant":
|
||||
return "AI角色"
|
||||
default:
|
||||
return "其他页面"
|
||||
}
|
||||
|
@ -14,9 +14,10 @@ func Init(g *gin.Engine) {
|
||||
ctx.Redirect(302, "/index.html")
|
||||
})
|
||||
|
||||
g.GET("/index.html", app.Index) // 首页
|
||||
g.GET("/friend.html", app.Friend) // 好友列表
|
||||
g.GET("/group.html", app.Group) // 群组列表
|
||||
g.GET("/index.html", app.Index) // 首页
|
||||
g.GET("/friend.html", app.Friend) // 好友列表
|
||||
g.GET("/group.html", app.Group) // 群组列表
|
||||
g.GET("/assistant.html", app.Assistant) // AI角色
|
||||
|
||||
g.GET("/404.html", app.PageNotFound) // 群组列表
|
||||
|
||||
@ -33,4 +34,6 @@ func Init(g *gin.Engine) {
|
||||
api.GET("/group/users", app.GetGroupUsers) // 获取群成员列表
|
||||
api.PUT("/summary/status", app.ChangeEnableSummaryStatus) // 修改是否开启群聊总结状态
|
||||
api.PUT("/clearmembers", app.AutoClearMembers) // 自动清理群成员
|
||||
|
||||
api.POST("/assistant", app.SaveAssistant) // 保存AI助手
|
||||
}
|
||||
|
89
views/assistant.html
Normal file
89
views/assistant.html
Normal file
@ -0,0 +1,89 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" class="h-full bg-gray-100">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>水群助手</title>
|
||||
|
||||
<link href="assets/css/daisyui-4.4.14-full.min.css" rel="stylesheet" type="text/css"/>
|
||||
<link href="assets/css/index.css" rel="stylesheet" type="text/css"/>
|
||||
|
||||
<script src="https://cdn.tailwindcss.com?plugins=forms,typography,aspect-ratio,line-clamp"></script>
|
||||
<script src="https://cdn.bootcdn.net/ajax/libs/axios/1.5.0/axios.min.js"></script>
|
||||
|
||||
<script src="assets/js/index.js"></script>
|
||||
</head>
|
||||
|
||||
<body class="h-full">
|
||||
<div class="min-h-full">
|
||||
{{ template "head.html" "assistant" }}
|
||||
|
||||
<main class="-mt-32">
|
||||
<div class="mx-auto max-w-7xl px-4 pb-12 sm:px-6 lg:px-8">
|
||||
<div class="rounded-lg bg-white px-5 py-6 shadow sm:px-6 text-2xl">
|
||||
<ul role="list" class="grid grid-cols-1 gap-x-6 gap-y-8 lg:grid-cols-2 xl:gap-x-8">
|
||||
{{ range .assistant }}
|
||||
<li class="overflow-hidden rounded-xl border border-gray-200">
|
||||
<!-- 头 -->
|
||||
<!-- <div class="flex items -center gap-x-4 border-b border-gray-900/5 bg-gray-50 p-6">-->
|
||||
<!-- <div class="text-sm flex-1">-->
|
||||
<!-- <div class="font-medium leading-6 text-gray-900">{{ .Name }}</div>-->
|
||||
<!-- <div class="font-medium text-gray-500">{{ .CreatedAt }}</div>-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
|
||||
<!-- body -->
|
||||
<form action="/api/assistant" method="post">
|
||||
<div class="-my-3 divide-y divide-gray-100 px-6 py-4 text-sm leading-6">
|
||||
<div class="border-b border-gray-900/10 pb-12">
|
||||
<div class="mt-10 grid grid-cols-1 gap-x-6 gap-y-8 sm:grid-cols-6">
|
||||
<div class="sm:col-span-4">
|
||||
<label for="name-{{.Id}}" class="block text-sm font-medium leading-6 text-gray-900">角色名称</label>
|
||||
<div class="mt-2">
|
||||
<div class="flex rounded-md shadow-sm ring-1 ring-inset ring-gray-300 focus-within:ring-2 focus-within:ring-inset focus-within:ring-indigo-600 sm:max-w-md">
|
||||
<input type="text" value="{{.Name}}" name="name" id="name-{{.Id}}" class="block flex-1 border-0 bg-transparent py-1.5 pl-1 text-gray-900 placeholder:text-gray-400 focus:ring-0 sm:text-sm sm:leading-6" placeholder="请输入角色名称">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-span-full">
|
||||
<label for="about-{{.Id}}" class="block text-sm font-medium leading-6 text-gray-900">Prompt</label>
|
||||
<div class="mt-2">
|
||||
<textarea id="about-{{.Id}}" name="about" rows="4" class="block w-full rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6" placeholder="请输入角色Prompt">{{.Personality}}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-span-full">
|
||||
<label for="model-{{.Id}}" class="block text-sm font-medium leading-6 text-gray-900">AI模型</label>
|
||||
<div class="mt-2">
|
||||
<select id="model-{{.Id}}" class="block w-full rounded-md border-0 py-1.5 pl-3 pr-10 text-gray-900 ring-1 ring-inset ring-gray-300 focus:ring-2 focus:ring-green-600 sm:text-sm sm:leading-6">
|
||||
{{$useModel := .Model}}
|
||||
{{ range $.aiModels }}
|
||||
<option value="{{.Model}}" {{ if eq $useModel .Model}}selected{{ end }}>
|
||||
{{.Name}}
|
||||
</option>
|
||||
{{ end }}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-6 flex items-center justify-end gap-x-6">
|
||||
<button type="submit" class="rounded-md bg-indigo-600 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600">Save</button>
|
||||
</div>
|
||||
</form>
|
||||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
{{ template "footer.html" }}
|
||||
|
||||
{{ template "groupuser.html" }}
|
||||
</div>
|
||||
|
||||
</body>
|
@ -13,6 +13,7 @@
|
||||
<a href="/friend.html" class="{{ if eq . "friend" }}bg-green-700{{ else }}hover:bg-green-500 hover:bg-opacity-75{{ end }} text-white rounded-md py-2 px-3 text-sm font-medium" aria-current="page">好友</a>
|
||||
<a href="/group.html" class="{{ if eq . "group" }}bg-green-700{{ else }}hover:bg-green-500 hover:bg-opacity-75{{ end }} text-white rounded-md py-2 px-3 text-sm font-medium">群组</a>
|
||||
<!-- <a href="/index.html" class="{{ if eq . "vnc" }}bg-green-700{{ else }}hover:bg-green-500 hover:bg-opacity-75{{ end }} text-white rounded-md py-2 px-3 text-sm font-medium">VNC</a>-->
|
||||
<a href="/assistant.html" class="{{ if eq . "assistant" }}bg-green-700{{ else }}hover:bg-green-500 hover:bg-opacity-75{{ end }} text-white rounded-md py-2 px-3 text-sm font-medium">AI角色</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user