Compare commits
22 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
55d219b364 | ||
|
|
a4234532cd | ||
|
|
3275a64852 | ||
|
|
21505702e6 | ||
|
|
45db832dad | ||
|
|
b806ade655 | ||
|
|
f39f46bfbf | ||
|
|
5819ac3c04 | ||
|
|
c4964a9e21 | ||
|
|
c0dcffce9d | ||
|
|
b14dbe0d1d | ||
|
|
b024600ef0 | ||
|
|
bc2893fad1 | ||
|
|
a098da39ee | ||
|
|
42339e3c51 | ||
|
|
20aeeefb3c | ||
|
|
08ffd4de6c | ||
|
|
2238e23c8d | ||
|
|
0f506e5afc | ||
|
|
44c45d11f2 | ||
|
|
50e91680bb | ||
|
|
b2598f2406 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -7,4 +7,5 @@ cache
|
|||||||
log
|
log
|
||||||
dist
|
dist
|
||||||
*.log
|
*.log
|
||||||
blacklist.txt
|
blacklist.txt
|
||||||
|
frontend.*
|
||||||
|
|||||||
36
app/assistant.go
Normal file
36
app/assistant.go
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
package app
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"go-wechat/common/response"
|
||||||
|
"go-wechat/config"
|
||||||
|
"go-wechat/service"
|
||||||
|
)
|
||||||
|
|
||||||
|
// SaveAssistant
|
||||||
|
// @description: 保存AI助手
|
||||||
|
// @param ctx
|
||||||
|
func SaveAssistant(ctx *gin.Context) {
|
||||||
|
|
||||||
|
//ctx.String(http.StatusOK, "操作成功")
|
||||||
|
ctx.Redirect(302, "/assistant.html")
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetAssistants
|
||||||
|
// @description: 获取AI助手列表
|
||||||
|
// @param ctx
|
||||||
|
func GetAssistants(ctx *gin.Context) {
|
||||||
|
records, err := service.GetAllAiAssistant()
|
||||||
|
if err != nil {
|
||||||
|
response.New(ctx).SetMsg("系统错误").SetError(err).Fail()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
response.New(ctx).SetData(records).Success()
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetAiModels
|
||||||
|
// @description: 获取AI模型列表
|
||||||
|
// @param ctx
|
||||||
|
func GetAiModels(ctx *gin.Context) {
|
||||||
|
response.New(ctx).SetData(config.Conf.Ai.Models).Success()
|
||||||
|
}
|
||||||
33
app/contact.go
Normal file
33
app/contact.go
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
package app
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"go-wechat/common/response"
|
||||||
|
"go-wechat/service"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetFriends
|
||||||
|
// @description: 获取好友列表
|
||||||
|
// @param ctx
|
||||||
|
func GetFriends(ctx *gin.Context) {
|
||||||
|
// 取出所有好友列表
|
||||||
|
friends, _, err := service.GetAllFriend()
|
||||||
|
if err != nil {
|
||||||
|
response.New(ctx).SetMsg("系统错误").SetError(err).Fail()
|
||||||
|
}
|
||||||
|
|
||||||
|
response.New(ctx).SetData(friends).Success()
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetGroups
|
||||||
|
// @description: 获取群列表
|
||||||
|
// @param ctx
|
||||||
|
func GetGroups(ctx *gin.Context) {
|
||||||
|
// 取出所有好友列表
|
||||||
|
_, groups, err := service.GetAllFriend()
|
||||||
|
if err != nil {
|
||||||
|
response.New(ctx).SetMsg("系统错误").SetError(err).Fail()
|
||||||
|
}
|
||||||
|
|
||||||
|
response.New(ctx).SetData(groups).Success()
|
||||||
|
}
|
||||||
@@ -3,7 +3,7 @@ package app
|
|||||||
import (
|
import (
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"go-wechat/client"
|
"go-wechat/client"
|
||||||
"go-wechat/entity"
|
"go-wechat/model/entity"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -23,6 +23,13 @@ type changeUseAiModelParam struct {
|
|||||||
Model string `json:"model" binding:"required"` // 模型代码
|
Model string `json:"model" binding:"required"` // 模型代码
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// autoClearMembers
|
||||||
|
// @description: 自动清理群成员
|
||||||
|
type autoClearMembers struct {
|
||||||
|
WxId string `json:"wxid" binding:"required"` // 群Id
|
||||||
|
Days int `json:"days"` // 多少天未发言
|
||||||
|
}
|
||||||
|
|
||||||
// ChangeEnableAiStatus
|
// ChangeEnableAiStatus
|
||||||
// @description: 修改是否开启AI
|
// @description: 修改是否开启AI
|
||||||
// @param ctx
|
// @param ctx
|
||||||
@@ -67,6 +74,28 @@ func ChangeUseAiModel(ctx *gin.Context) {
|
|||||||
ctx.String(http.StatusOK, "操作成功")
|
ctx.String(http.StatusOK, "操作成功")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ChangeUseAiAssistant
|
||||||
|
// @description: 修改使用的AI助手
|
||||||
|
// @param ctx
|
||||||
|
func ChangeUseAiAssistant(ctx *gin.Context) {
|
||||||
|
// 此处复用一下结构体
|
||||||
|
var p changeUseAiModelParam
|
||||||
|
if err := ctx.ShouldBind(&p); err != nil {
|
||||||
|
ctx.String(http.StatusBadRequest, "参数错误")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err := client.MySQL.Model(&entity.Friend{}).
|
||||||
|
Where("wxid = ?", p.WxId).
|
||||||
|
Update("`prompt`", p.Model).Error
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("修改【%s】的AI助手失败:%s", p.WxId, err)
|
||||||
|
ctx.String(http.StatusInternalServerError, "操作失败: %s", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.String(http.StatusOK, "操作成功")
|
||||||
|
}
|
||||||
|
|
||||||
// ChangeEnableGroupRankStatus
|
// ChangeEnableGroupRankStatus
|
||||||
// @description: 修改是否开启水群排行榜
|
// @description: 修改是否开启水群排行榜
|
||||||
// @param ctx
|
// @param ctx
|
||||||
@@ -205,3 +234,26 @@ func ChangeEnableNewsStatus(ctx *gin.Context) {
|
|||||||
|
|
||||||
ctx.String(http.StatusOK, "操作成功")
|
ctx.String(http.StatusOK, "操作成功")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AutoClearMembers
|
||||||
|
// @description: 自动清理群成员
|
||||||
|
// @param ctx
|
||||||
|
func AutoClearMembers(ctx *gin.Context) {
|
||||||
|
var p autoClearMembers
|
||||||
|
if err := ctx.ShouldBindJSON(&p); err != nil {
|
||||||
|
ctx.String(http.StatusBadRequest, "参数错误")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
log.Printf("待修改的Id:%s", p.WxId)
|
||||||
|
|
||||||
|
err := client.MySQL.Model(&entity.Friend{}).
|
||||||
|
Where("wxid = ?", p.WxId).
|
||||||
|
Update("`clear_member`", p.Days).Error
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("修改自动清理群成员阈值失败:%s", err)
|
||||||
|
ctx.String(http.StatusInternalServerError, "操作失败: %s", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.String(http.StatusOK, "操作成功")
|
||||||
|
}
|
||||||
|
|||||||
17
app/pages.go
17
app/pages.go
@@ -66,6 +66,7 @@ func Friend(ctx *gin.Context) {
|
|||||||
result["friends"] = friends
|
result["friends"] = friends
|
||||||
result["vnc"] = config.Conf.Wechat.VncUrl
|
result["vnc"] = config.Conf.Wechat.VncUrl
|
||||||
result["aiModels"] = config.Conf.Ai.Models
|
result["aiModels"] = config.Conf.Ai.Models
|
||||||
|
result["assistant"], _ = service.GetAllAiAssistant()
|
||||||
// 渲染页面
|
// 渲染页面
|
||||||
ctx.HTML(http.StatusOK, "friend.html", result)
|
ctx.HTML(http.StatusOK, "friend.html", result)
|
||||||
}
|
}
|
||||||
@@ -85,11 +86,27 @@ func Group(ctx *gin.Context) {
|
|||||||
result["groups"] = groups
|
result["groups"] = groups
|
||||||
result["vnc"] = config.Conf.Wechat.VncUrl
|
result["vnc"] = config.Conf.Wechat.VncUrl
|
||||||
result["aiModels"] = config.Conf.Ai.Models
|
result["aiModels"] = config.Conf.Ai.Models
|
||||||
|
result["assistant"], _ = service.GetAllAiAssistant()
|
||||||
|
|
||||||
// 渲染页面
|
// 渲染页面
|
||||||
ctx.HTML(http.StatusOK, "group.html", result)
|
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
|
// PageNotFound
|
||||||
// @description: 404页面
|
// @description: 404页面
|
||||||
// @param ctx
|
// @param ctx
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package current
|
package current
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go-wechat/model"
|
"go-wechat/model/model"
|
||||||
plugin "go-wechat/plugin"
|
plugin "go-wechat/plugin"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
16
common/response/fail.go
Normal file
16
common/response/fail.go
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
package response
|
||||||
|
|
||||||
|
// Fail
|
||||||
|
// @description: 失败响应
|
||||||
|
// @receiver r
|
||||||
|
// @param data
|
||||||
|
// @return err
|
||||||
|
func (r *Response) Fail() {
|
||||||
|
if r.msg == "" {
|
||||||
|
r.msg = "系统错误"
|
||||||
|
}
|
||||||
|
if r.code == 0 {
|
||||||
|
r.code = fail
|
||||||
|
}
|
||||||
|
r.Result()
|
||||||
|
}
|
||||||
43
common/response/page.go
Normal file
43
common/response/page.go
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
package response
|
||||||
|
|
||||||
|
// PageData
|
||||||
|
// @description: 分页数据通用结构体
|
||||||
|
type PageData[T any] struct {
|
||||||
|
Current int `json:"current"` // 当前页码
|
||||||
|
Size int `json:"size"` // 每页数量
|
||||||
|
Total int64 `json:"total"` // 总数
|
||||||
|
TotalPage int `json:"totalPage"` // 总页数
|
||||||
|
Records T `json:"records"` // 返回数据
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewPageData
|
||||||
|
// @description: 创建分页数据
|
||||||
|
// @param records any 数据列表
|
||||||
|
// @param total int64 总数
|
||||||
|
// @param current int 页码
|
||||||
|
// @param size int 页数量
|
||||||
|
// @return data PageData[any] 分页数据
|
||||||
|
func NewPageData(records any, total int64, current, size int) (data PageData[any]) {
|
||||||
|
// 处理一下页码、页数量
|
||||||
|
if current == -1 {
|
||||||
|
current = 1
|
||||||
|
size = int(total)
|
||||||
|
}
|
||||||
|
// 计算总页码
|
||||||
|
totalPage := 0
|
||||||
|
if total > 0 {
|
||||||
|
upPage := 0
|
||||||
|
if int(total)%size > 0 {
|
||||||
|
upPage = 1
|
||||||
|
}
|
||||||
|
totalPage = (int(total) / size) + upPage
|
||||||
|
}
|
||||||
|
data = PageData[any]{
|
||||||
|
Current: current,
|
||||||
|
Size: size,
|
||||||
|
Total: total,
|
||||||
|
TotalPage: totalPage,
|
||||||
|
Records: records,
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
81
common/response/response.go
Normal file
81
common/response/response.go
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
package response
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"go-wechat/common/validator"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
// 定义状态码
|
||||||
|
const (
|
||||||
|
fail = http.StatusInternalServerError
|
||||||
|
success = http.StatusOK
|
||||||
|
)
|
||||||
|
|
||||||
|
// Response
|
||||||
|
// @description: 返回结果
|
||||||
|
type Response struct {
|
||||||
|
ctx *gin.Context
|
||||||
|
code int
|
||||||
|
data any
|
||||||
|
msg string
|
||||||
|
errMsg string
|
||||||
|
}
|
||||||
|
|
||||||
|
// New
|
||||||
|
// @description: 返回结果实现
|
||||||
|
// @param ctx
|
||||||
|
// @return Response
|
||||||
|
func New(ctx *gin.Context) *Response {
|
||||||
|
var r Response
|
||||||
|
r.ctx = ctx
|
||||||
|
|
||||||
|
return &r
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetCode
|
||||||
|
// @description: 设置状态码
|
||||||
|
// @receiver r
|
||||||
|
// @param code
|
||||||
|
// @return *Response
|
||||||
|
func (r *Response) SetCode(code int) *Response {
|
||||||
|
r.code = code
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetData
|
||||||
|
// @description: 设置返回数据
|
||||||
|
// @receiver r
|
||||||
|
// @param data
|
||||||
|
// @return *Response
|
||||||
|
func (r *Response) SetData(data any) *Response {
|
||||||
|
r.data = data
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetMsg
|
||||||
|
// @description: 设置返回消息
|
||||||
|
// @receiver r
|
||||||
|
// @param msg
|
||||||
|
// @return *Response
|
||||||
|
func (r *Response) SetMsg(msg string) *Response {
|
||||||
|
r.msg = msg
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetError
|
||||||
|
// @description: 设置错误信息
|
||||||
|
// @receiver r
|
||||||
|
// @param err
|
||||||
|
// @return *Response
|
||||||
|
func (r *Response) SetError(err error) *Response {
|
||||||
|
if err != nil {
|
||||||
|
ne := validator.Translate(err)
|
||||||
|
if ne != nil {
|
||||||
|
r.errMsg = ne.Error()
|
||||||
|
} else {
|
||||||
|
r.errMsg = err.Error()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return r
|
||||||
|
}
|
||||||
27
common/response/result.go
Normal file
27
common/response/result.go
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
package response
|
||||||
|
|
||||||
|
// Result
|
||||||
|
// @description: 响应
|
||||||
|
// @receiver r
|
||||||
|
// @param code int 状态码
|
||||||
|
// @param data any 数据
|
||||||
|
// @param msg string 消息
|
||||||
|
// @param err string 错误信息
|
||||||
|
// @return err error 返回数据错误
|
||||||
|
func (r *Response) Result() {
|
||||||
|
type resp struct {
|
||||||
|
Code int `json:"code"`
|
||||||
|
Data any `json:"data"`
|
||||||
|
Msg string `json:"message"`
|
||||||
|
ErrMsg string `json:"errMsg,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
rd := resp{
|
||||||
|
r.code,
|
||||||
|
r.data,
|
||||||
|
r.msg,
|
||||||
|
r.errMsg,
|
||||||
|
}
|
||||||
|
// 返回数据
|
||||||
|
r.ctx.JSON(r.code, rd)
|
||||||
|
}
|
||||||
16
common/response/success.go
Normal file
16
common/response/success.go
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
package response
|
||||||
|
|
||||||
|
// Success
|
||||||
|
// @description: 成功响应
|
||||||
|
// @receiver r
|
||||||
|
// @param data
|
||||||
|
// @return err
|
||||||
|
func (r *Response) Success() {
|
||||||
|
if r.msg == "" {
|
||||||
|
r.msg = "success"
|
||||||
|
}
|
||||||
|
if r.code == 0 {
|
||||||
|
r.code = success
|
||||||
|
}
|
||||||
|
r.Result()
|
||||||
|
}
|
||||||
56
common/validator/validator.go
Normal file
56
common/validator/validator.go
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
package validator
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"github.com/gin-gonic/gin/binding"
|
||||||
|
"github.com/go-playground/locales/zh"
|
||||||
|
ut "github.com/go-playground/universal-translator"
|
||||||
|
"github.com/go-playground/validator/v10"
|
||||||
|
zhTranslations "github.com/go-playground/validator/v10/translations/zh"
|
||||||
|
"log"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
uni *ut.UniversalTranslator
|
||||||
|
validate *validator.Validate
|
||||||
|
trans ut.Translator
|
||||||
|
)
|
||||||
|
|
||||||
|
// Init
|
||||||
|
// @description: 初始化验证器
|
||||||
|
func Init() {
|
||||||
|
//注册翻译器
|
||||||
|
zhTranslator := zh.New()
|
||||||
|
uni = ut.New(zhTranslator, zhTranslator)
|
||||||
|
|
||||||
|
trans, _ = uni.GetTranslator("zh")
|
||||||
|
|
||||||
|
//获取gin的校验器
|
||||||
|
validate = binding.Validator.Engine().(*validator.Validate)
|
||||||
|
//注册翻译器
|
||||||
|
err := zhTranslations.RegisterDefaultTranslations(validate, trans)
|
||||||
|
if err != nil {
|
||||||
|
log.Panicf("注册翻译器失败:%v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Translate
|
||||||
|
// @description: 翻译错误信息
|
||||||
|
// @param err
|
||||||
|
// @return error
|
||||||
|
func Translate(err error) error {
|
||||||
|
errorMsg := make([]string, 0)
|
||||||
|
|
||||||
|
var ves validator.ValidationErrors
|
||||||
|
ok := errors.As(err, &ves)
|
||||||
|
if !ok {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, e := range ves {
|
||||||
|
errorMsg = append(errorMsg, e.Translate(trans))
|
||||||
|
}
|
||||||
|
|
||||||
|
return errors.New(strings.Join(errorMsg, ";"))
|
||||||
|
}
|
||||||
@@ -20,7 +20,7 @@ system:
|
|||||||
# 微信HOOK配置
|
# 微信HOOK配置
|
||||||
wechat:
|
wechat:
|
||||||
# 微信HOOK接口地址
|
# 微信HOOK接口地址
|
||||||
host: 10.0.0.73:19088
|
host: 10.0.0.79:19088
|
||||||
# 微信容器映射出来的vnc页面地址,没有就不填
|
# 微信容器映射出来的vnc页面地址,没有就不填
|
||||||
# vncUrl: http://192.168.1.175:19087/vnc_lite.html
|
# vncUrl: http://192.168.1.175:19087/vnc_lite.html
|
||||||
# 是否在启动的时候自动设置hook服务的回调
|
# 是否在启动的时候自动设置hook服务的回调
|
||||||
@@ -42,7 +42,7 @@ mysql:
|
|||||||
schema: public # postgres 专用
|
schema: public # postgres 专用
|
||||||
|
|
||||||
task:
|
task:
|
||||||
enable: true
|
enable: false
|
||||||
news:
|
news:
|
||||||
enable: true
|
enable: true
|
||||||
cron: '14 11 * * *' # 每天0:30
|
cron: '14 11 * * *' # 每天0:30
|
||||||
@@ -101,6 +101,10 @@ ai:
|
|||||||
model: moonshot-v1-128k
|
model: moonshot-v1-128k
|
||||||
- name: 跃问
|
- name: 跃问
|
||||||
model: StepChat
|
model: StepChat
|
||||||
|
- name: 豆包Lite-4k
|
||||||
|
model: Doubao-lite-4k
|
||||||
|
- name: 豆包Pro-4k
|
||||||
|
model: Doubao-pro-4k
|
||||||
|
|
||||||
# 资源配置
|
# 资源配置
|
||||||
# map[k]v结构,k 会变成全小写,所以这儿不能用大写字母
|
# map[k]v结构,k 会变成全小写,所以这儿不能用大写字母
|
||||||
|
|||||||
18
frontend/.eslintrc.cjs
Normal file
18
frontend/.eslintrc.cjs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
/* eslint-env node */
|
||||||
|
require('@rushstack/eslint-patch/modern-module-resolution')
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
env: {
|
||||||
|
node: true,
|
||||||
|
},
|
||||||
|
root: true,
|
||||||
|
'extends': [
|
||||||
|
'plugin:vue/vue3-essential',
|
||||||
|
'eslint:recommended',
|
||||||
|
'@vue/eslint-config-typescript',
|
||||||
|
'@vue/eslint-config-prettier/skip-formatting'
|
||||||
|
],
|
||||||
|
parserOptions: {
|
||||||
|
ecmaVersion: 'latest'
|
||||||
|
}
|
||||||
|
}
|
||||||
30
frontend/.gitignore
vendored
Normal file
30
frontend/.gitignore
vendored
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
pnpm-debug.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
|
||||||
|
node_modules
|
||||||
|
.DS_Store
|
||||||
|
dist
|
||||||
|
dist-ssr
|
||||||
|
coverage
|
||||||
|
*.local
|
||||||
|
|
||||||
|
/cypress/videos/
|
||||||
|
/cypress/screenshots/
|
||||||
|
|
||||||
|
# Editor directories and files
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/extensions.json
|
||||||
|
.idea
|
||||||
|
*.suo
|
||||||
|
*.ntvs*
|
||||||
|
*.njsproj
|
||||||
|
*.sln
|
||||||
|
*.sw?
|
||||||
|
|
||||||
|
*.tsbuildinfo
|
||||||
8
frontend/.prettierrc.json
Normal file
8
frontend/.prettierrc.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://json.schemastore.org/prettierrc",
|
||||||
|
"semi": false,
|
||||||
|
"tabWidth": 2,
|
||||||
|
"singleQuote": true,
|
||||||
|
"printWidth": 100,
|
||||||
|
"trailingComma": "none"
|
||||||
|
}
|
||||||
7
frontend/.vscode/extensions.json
vendored
Normal file
7
frontend/.vscode/extensions.json
vendored
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"recommendations": [
|
||||||
|
"Vue.volar",
|
||||||
|
"dbaeumer.vscode-eslint",
|
||||||
|
"esbenp.prettier-vscode"
|
||||||
|
]
|
||||||
|
}
|
||||||
39
frontend/README.md
Normal file
39
frontend/README.md
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
# frontend
|
||||||
|
|
||||||
|
This template should help get you started developing with Vue 3 in Vite.
|
||||||
|
|
||||||
|
## Recommended IDE Setup
|
||||||
|
|
||||||
|
[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur).
|
||||||
|
|
||||||
|
## Type Support for `.vue` Imports in TS
|
||||||
|
|
||||||
|
TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) to make the TypeScript language service aware of `.vue` types.
|
||||||
|
|
||||||
|
## Customize configuration
|
||||||
|
|
||||||
|
See [Vite Configuration Reference](https://vitejs.dev/config/).
|
||||||
|
|
||||||
|
## Project Setup
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install
|
||||||
|
```
|
||||||
|
|
||||||
|
### Compile and Hot-Reload for Development
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm run dev
|
||||||
|
```
|
||||||
|
|
||||||
|
### Type-Check, Compile and Minify for Production
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm run build
|
||||||
|
```
|
||||||
|
|
||||||
|
### Lint with [ESLint](https://eslint.org/)
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm run lint
|
||||||
|
```
|
||||||
1
frontend/env.d.ts
vendored
Normal file
1
frontend/env.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
/// <reference types="vite/client" />
|
||||||
13
frontend/index.html
Normal file
13
frontend/index.html
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en" class="h-full bg-gray-100">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<link rel="icon" href="/favicon.ico">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>一个微信机器人</title>
|
||||||
|
</head>
|
||||||
|
<body style="min-height: 911px" class="h-full">
|
||||||
|
<div id="app"></div>
|
||||||
|
<script type="module" src="/src/main.ts"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
5312
frontend/package-lock.json
generated
Normal file
5312
frontend/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
46
frontend/package.json
Normal file
46
frontend/package.json
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
{
|
||||||
|
"name": "frontend",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"private": true,
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"dev": "vite",
|
||||||
|
"build": "run-p type-check \"build-only {@}\" --",
|
||||||
|
"preview": "vite preview",
|
||||||
|
"build-only": "vite build",
|
||||||
|
"type-check": "vue-tsc --build --force",
|
||||||
|
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
|
||||||
|
"format": "prettier --write src/"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@headlessui/vue": "^1.7.22",
|
||||||
|
"@tailwindcss/forms": "^0.5.7",
|
||||||
|
"axios": "^1.7.2",
|
||||||
|
"pinia": "^2.1.7",
|
||||||
|
"qs": "^6.12.2",
|
||||||
|
"vue": "^3.4.29",
|
||||||
|
"vue-router": "^4.3.3"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@rushstack/eslint-patch": "^1.8.0",
|
||||||
|
"@tsconfig/node20": "^20.1.4",
|
||||||
|
"@types/node": "^20.14.5",
|
||||||
|
"@types/qs": "^6.9.15",
|
||||||
|
"@vitejs/plugin-vue": "^5.0.5",
|
||||||
|
"@vitejs/plugin-vue-jsx": "^4.0.0",
|
||||||
|
"@vue/eslint-config-prettier": "^9.0.0",
|
||||||
|
"@vue/eslint-config-typescript": "^13.0.0",
|
||||||
|
"@vue/tsconfig": "^0.5.1",
|
||||||
|
"autoprefixer": "^10.4.19",
|
||||||
|
"daisyui": "^4.12.10",
|
||||||
|
"eslint": "^8.57.0",
|
||||||
|
"eslint-plugin-vue": "^9.23.0",
|
||||||
|
"npm-run-all2": "^6.2.0",
|
||||||
|
"postcss": "^8.4.39",
|
||||||
|
"prettier": "^3.2.5",
|
||||||
|
"tailwindcss": "^3.4.4",
|
||||||
|
"typescript": "~5.4.0",
|
||||||
|
"vite": "^5.3.1",
|
||||||
|
"vue-tsc": "^2.0.21"
|
||||||
|
}
|
||||||
|
}
|
||||||
6
frontend/postcss.config.js
Normal file
6
frontend/postcss.config.js
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
export default {
|
||||||
|
plugins: {
|
||||||
|
tailwindcss: {},
|
||||||
|
autoprefixer: {},
|
||||||
|
},
|
||||||
|
};
|
||||||
BIN
frontend/public/favicon.ico
Normal file
BIN
frontend/public/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
10
frontend/src/App.vue
Normal file
10
frontend/src/App.vue
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import MainNav from '@/components/layout/MainNav.vue'
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<MainNav />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
</style>
|
||||||
6
frontend/src/api/base.ts
Normal file
6
frontend/src/api/base.ts
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
// 默认返回数据结构
|
||||||
|
export type BaseResult<T> = {
|
||||||
|
code: number;
|
||||||
|
message: string;
|
||||||
|
data?: T;
|
||||||
|
};
|
||||||
43
frontend/src/api/contact.ts
Normal file
43
frontend/src/api/contact.ts
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
import { http } from '@/utils/http'
|
||||||
|
import type { BaseResult } from '@/api/base'
|
||||||
|
|
||||||
|
/** 通讯录列表返回结果 */
|
||||||
|
export type ContactItem = {
|
||||||
|
/** 微信号 */
|
||||||
|
CustomAccount: string,
|
||||||
|
/** 昵称 */
|
||||||
|
Nickname: string,
|
||||||
|
/** 昵称拼音大写首字母 */
|
||||||
|
Pinyin: string,
|
||||||
|
/** 昵称拼音全拼 */
|
||||||
|
PinyinAll: string,
|
||||||
|
/** 微信原始Id */
|
||||||
|
Wxid: string,
|
||||||
|
/** 最后活跃时间 */
|
||||||
|
LastActive: Date,
|
||||||
|
/** 是否使用AI */
|
||||||
|
EnableAi: boolean,
|
||||||
|
/** AI模型 */
|
||||||
|
AiModel: string,
|
||||||
|
/** AI助手或者自定义提示词 */
|
||||||
|
Prompt: string,
|
||||||
|
/** 是否使用聊天排行 */
|
||||||
|
EnableChatRank: boolean,
|
||||||
|
/** 是否使用迎新 */
|
||||||
|
EnableWelcome: boolean,
|
||||||
|
/** 是否启用指令 */
|
||||||
|
EnableCommand: boolean,
|
||||||
|
/** 是否启用总结 */
|
||||||
|
EnableSummary: boolean,
|
||||||
|
/** 是否启用新闻 */
|
||||||
|
EnableNews: boolean,
|
||||||
|
/** 清理成员配置(多少天未活跃的) */
|
||||||
|
ClearMember: number,
|
||||||
|
/** 是否还在通讯库(群聊是要还在群里也算) */
|
||||||
|
IsOk: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 获取首页基础信息 */
|
||||||
|
export const getFriendList = () => {
|
||||||
|
return http.request<BaseResult<Array<ContactItem>>>('get', '/api/contact/friend')
|
||||||
|
}
|
||||||
BIN
frontend/src/assets/img/logo.png
Normal file
BIN
frontend/src/assets/img/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
BIN
frontend/src/assets/img/status-fail.png
Normal file
BIN
frontend/src/assets/img/status-fail.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 210 KiB |
BIN
frontend/src/assets/img/status-ok.png
Normal file
BIN
frontend/src/assets/img/status-ok.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 123 KiB |
3
frontend/src/components/contact/index.vue
Normal file
3
frontend/src/components/contact/index.vue
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<template>
|
||||||
|
|
||||||
|
</template>
|
||||||
73
frontend/src/components/layout/MainNav.vue
Normal file
73
frontend/src/components/layout/MainNav.vue
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { RouterView } from 'vue-router'
|
||||||
|
import { Disclosure, DisclosureButton, DisclosurePanel, Menu, MenuButton, MenuItem, MenuItems } from '@headlessui/vue'
|
||||||
|
|
||||||
|
defineOptions({
|
||||||
|
name: 'MainNav'
|
||||||
|
})
|
||||||
|
|
||||||
|
const navigation = [
|
||||||
|
{ name: '首页', href: '/', current: true },
|
||||||
|
{ name: '好友列表', href: '/friend', current: false },
|
||||||
|
{ name: '群组', href: '/group', current: false },
|
||||||
|
{ name: 'AI角色', href: '/assistant', current: false }
|
||||||
|
]
|
||||||
|
|
||||||
|
// 设置当前选中的导航
|
||||||
|
const setCurrent = (href: string) => {
|
||||||
|
navigation.forEach(item => {
|
||||||
|
item.current = item.href === href
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="min-h-full">
|
||||||
|
<div class="bg-green-600 pb-32">
|
||||||
|
<Disclosure as="nav" class="border-b border-green-300 border-opacity-25 bg-green-600 lg:border-none">
|
||||||
|
<div class="mx-auto max-w-7xl px-2 sm:px-4 lg:px-8">
|
||||||
|
<div
|
||||||
|
class="relative flex h-16 items-center justify-between lg:border-b lg:border-green-400 lg:border-opacity-25">
|
||||||
|
<div class="flex items-center px-2 lg:px-0">
|
||||||
|
<div class="flex-shrink-0">
|
||||||
|
<img class="block h-8 w-8" src="../../assets/img/logo.png" alt="Your Company" />
|
||||||
|
</div>
|
||||||
|
<div class="hidden lg:ml-10 lg:block">
|
||||||
|
<div class="flex space-x-4">
|
||||||
|
<a v-for="item in navigation" :key="item.name" :href="item.href"
|
||||||
|
:class="[item.current ? 'bg-green-700 text-white' : 'text-white hover:bg-green-500 hover:bg-opacity-75', 'rounded-md px-3 py-2 text-sm font-medium']"
|
||||||
|
:aria-current="item.current ? 'page' : undefined" @click="setCurrent(item.href)">{{ item.name }}</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Disclosure>
|
||||||
|
<header class="py-10">
|
||||||
|
<div class="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8">
|
||||||
|
<h1 class="text-3xl font-bold tracking-tight text-white">Dashboard</h1>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<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">
|
||||||
|
<RouterView />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<footer>
|
||||||
|
<div class="mx-auto max-w-3xl px-4 sm:px-6 lg:max-w-7xl lg:px-8">
|
||||||
|
<div class="border-t border-gray-200 py-8 text-center text-sm text-gray-500 sm:text-left">
|
||||||
|
<span class="block sm:inline">本项目完全开源,开源地址: </span>
|
||||||
|
<span class="block sm:inline text-red-500">
|
||||||
|
<a target="_blank" href="https://gitee.ltd/lxh/go-wxhelper">https://gitee.ltd</a>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
15
frontend/src/main.ts
Normal file
15
frontend/src/main.ts
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import { createApp } from 'vue'
|
||||||
|
import { createPinia } from 'pinia'
|
||||||
|
|
||||||
|
import App from './App.vue'
|
||||||
|
import router from './router'
|
||||||
|
|
||||||
|
// Tailwind CSS
|
||||||
|
import "tailwindcss/tailwind.css";
|
||||||
|
|
||||||
|
const app = createApp(App)
|
||||||
|
|
||||||
|
app.use(createPinia())
|
||||||
|
app.use(router)
|
||||||
|
|
||||||
|
app.mount('#app')
|
||||||
31
frontend/src/router/index.ts
Normal file
31
frontend/src/router/index.ts
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
import { createRouter, createWebHistory } from 'vue-router'
|
||||||
|
import IndexPage from '@/views/index/index.vue'
|
||||||
|
|
||||||
|
const router = createRouter({
|
||||||
|
history: createWebHistory(import.meta.env.BASE_URL),
|
||||||
|
routes: [
|
||||||
|
{
|
||||||
|
path: '/',
|
||||||
|
name: 'home',
|
||||||
|
component: IndexPage
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/friend',
|
||||||
|
name: 'Friend',
|
||||||
|
// 这么写是为了实现懒加载
|
||||||
|
component: () => import('@/views/friend/index.vue')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/group',
|
||||||
|
name: 'Group',
|
||||||
|
component: () => import('@/views/group/index.vue')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/assistant',
|
||||||
|
name: 'Assistant',
|
||||||
|
component: () => import('@/views/assistant/index.vue')
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
|
||||||
|
export default router
|
||||||
12
frontend/src/stores/counter.ts
Normal file
12
frontend/src/stores/counter.ts
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import { ref, computed } from 'vue'
|
||||||
|
import { defineStore } from 'pinia'
|
||||||
|
|
||||||
|
export const useCounterStore = defineStore('counter', () => {
|
||||||
|
const count = ref(0)
|
||||||
|
const doubleCount = computed(() => count.value * 2)
|
||||||
|
function increment() {
|
||||||
|
count.value++
|
||||||
|
}
|
||||||
|
|
||||||
|
return { count, doubleCount, increment }
|
||||||
|
})
|
||||||
136
frontend/src/utils/http/index.ts
Normal file
136
frontend/src/utils/http/index.ts
Normal file
@@ -0,0 +1,136 @@
|
|||||||
|
import Axios, {
|
||||||
|
type AxiosInstance,
|
||||||
|
type AxiosRequestConfig,
|
||||||
|
type CustomParamsSerializer,
|
||||||
|
type AxiosResponse
|
||||||
|
} from 'axios'
|
||||||
|
import type { HttpError, RequestMethods } from './types.d'
|
||||||
|
import { stringify } from 'qs'
|
||||||
|
|
||||||
|
// 相关配置请参考:www.axios-js.com/zh-cn/docs/#axios-request-config-1
|
||||||
|
const defaultConfig: AxiosRequestConfig = {
|
||||||
|
// 请求超时时间
|
||||||
|
timeout: 10000,
|
||||||
|
headers: {
|
||||||
|
Accept: 'application/json, text/plain, */*',
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'X-Requested-With': 'XMLHttpRequest'
|
||||||
|
},
|
||||||
|
// 数组格式参数序列化(https://github.com/axios/axios/issues/5142)
|
||||||
|
paramsSerializer: {
|
||||||
|
serialize: stringify as unknown as CustomParamsSerializer
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Http {
|
||||||
|
constructor() {
|
||||||
|
this.httpInterceptorsRequest()
|
||||||
|
this.httpInterceptorsResponse()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 初始化配置对象 */
|
||||||
|
private static initConfig: AxiosRequestConfig = {}
|
||||||
|
|
||||||
|
/** 保存当前`Axios`实例对象 */
|
||||||
|
private static axiosInstance: AxiosInstance = Axios.create(defaultConfig)
|
||||||
|
|
||||||
|
/** 请求拦截 */
|
||||||
|
private httpInterceptorsRequest(): void {
|
||||||
|
Http.axiosInstance.interceptors.request.use(
|
||||||
|
async (config: AxiosRequestConfig): Promise<any> => {
|
||||||
|
// 开启进度条动画
|
||||||
|
// NProgress.start();
|
||||||
|
// 优先判断post/get等方法是否传入回调,否则执行初始化设置等回调
|
||||||
|
// if (typeof config.beforeRequestCallback === 'function') {
|
||||||
|
// config.beforeRequestCallback(config)
|
||||||
|
// return config
|
||||||
|
// }
|
||||||
|
// if (Http.initConfig.beforeRequestCallback) {
|
||||||
|
// Http.initConfig.beforeRequestCallback(config)
|
||||||
|
// return config
|
||||||
|
// }
|
||||||
|
return config
|
||||||
|
},
|
||||||
|
(error: HttpError) => {
|
||||||
|
return Promise.reject(error)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 响应拦截 */
|
||||||
|
private httpInterceptorsResponse(): void {
|
||||||
|
const instance = Http.axiosInstance
|
||||||
|
instance.interceptors.response.use(
|
||||||
|
(response: AxiosResponse) => {
|
||||||
|
// const $config = response.config
|
||||||
|
// 关闭进度条动画
|
||||||
|
// NProgress.done()
|
||||||
|
// 优先判断post/get等方法是否传入回调,否则执行初始化设置等回调
|
||||||
|
// if (typeof $config.beforeResponseCallback === 'function') {
|
||||||
|
// $config.beforeResponseCallback(response)
|
||||||
|
// return response.data
|
||||||
|
// }
|
||||||
|
// if (Http.initConfig.beforeResponseCallback) {
|
||||||
|
// Http.initConfig.beforeResponseCallback(response)
|
||||||
|
// return response.data
|
||||||
|
// }
|
||||||
|
return response.data
|
||||||
|
},
|
||||||
|
(error: HttpError) => {
|
||||||
|
const $error = error
|
||||||
|
$error.isCancelRequest = Axios.isCancel($error)
|
||||||
|
// 关闭进度条动画
|
||||||
|
// NProgress.done()
|
||||||
|
// 所有的响应异常 区分来源为取消请求/非取消请求
|
||||||
|
return Promise.reject($error)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 通用请求工具函数 */
|
||||||
|
public request<T>(
|
||||||
|
method: RequestMethods,
|
||||||
|
url: string,
|
||||||
|
param?: AxiosRequestConfig,
|
||||||
|
axiosConfig?: AxiosRequestConfig
|
||||||
|
): Promise<T> {
|
||||||
|
const config = {
|
||||||
|
method,
|
||||||
|
url,
|
||||||
|
...param,
|
||||||
|
...axiosConfig
|
||||||
|
} as AxiosRequestConfig
|
||||||
|
|
||||||
|
// 单独处理自定义请求/响应回调
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
Http.axiosInstance
|
||||||
|
.request<T>(config)
|
||||||
|
.then((response: any): void => {
|
||||||
|
return resolve(response)
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
reject(error)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 单独抽离的`post`工具函数 */
|
||||||
|
public post<T, P>(
|
||||||
|
url: string,
|
||||||
|
params?: AxiosRequestConfig<P>,
|
||||||
|
config?: AxiosRequestConfig
|
||||||
|
): Promise<T> {
|
||||||
|
return this.request<T>('post', url, params, config)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 单独抽离的`get`工具函数 */
|
||||||
|
public get<T, P>(
|
||||||
|
url: string,
|
||||||
|
params?: AxiosRequestConfig<P>,
|
||||||
|
config?: AxiosRequestConfig
|
||||||
|
): Promise<T> {
|
||||||
|
return this.request<T>('get', url, params, config)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const http = new Http()
|
||||||
43
frontend/src/utils/http/types.d.ts
vendored
Normal file
43
frontend/src/utils/http/types.d.ts
vendored
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
import type {
|
||||||
|
Method,
|
||||||
|
AxiosError,
|
||||||
|
AxiosResponse,
|
||||||
|
AxiosRequestConfig
|
||||||
|
} from "axios";
|
||||||
|
|
||||||
|
export type RequestMethods = Extract<
|
||||||
|
Method,
|
||||||
|
"get" | "post" | "put" | "delete" | "patch" | "option" | "head"
|
||||||
|
>;
|
||||||
|
|
||||||
|
export interface HttpError extends AxiosError {
|
||||||
|
isCancelRequest?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface HttpResponse extends AxiosResponse {
|
||||||
|
config: HttpRequestConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface HttpRequestConfig extends AxiosRequestConfig {
|
||||||
|
beforeRequestCallback?: (request: HttpRequestConfig) => void;
|
||||||
|
beforeResponseCallback?: (response: HttpResponse) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class Http {
|
||||||
|
request<T>(
|
||||||
|
method: RequestMethods,
|
||||||
|
url: string,
|
||||||
|
param?: AxiosRequestConfig,
|
||||||
|
axiosConfig?: HttpRequestConfig
|
||||||
|
): Promise<T>;
|
||||||
|
post<T, P>(
|
||||||
|
url: string,
|
||||||
|
params?: T,
|
||||||
|
config?: HttpRequestConfig
|
||||||
|
): Promise<P>;
|
||||||
|
get<T, P>(
|
||||||
|
url: string,
|
||||||
|
params?: T,
|
||||||
|
config?: HttpRequestConfig
|
||||||
|
): Promise<P>;
|
||||||
|
}
|
||||||
12
frontend/src/views/assistant/index.vue
Normal file
12
frontend/src/views/assistant/index.vue
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
|
||||||
|
defineOptions({
|
||||||
|
name: "AssistantPage"
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<main>
|
||||||
|
<h1>AI角色</h1>
|
||||||
|
</main>
|
||||||
|
</template>
|
||||||
25
frontend/src/views/friend/hook.tsx
Normal file
25
frontend/src/views/friend/hook.tsx
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import { onMounted, ref } from 'vue'
|
||||||
|
|
||||||
|
import { type ContactItem, getFriendList } from '@/api/contact'
|
||||||
|
|
||||||
|
// 起飞
|
||||||
|
export function useHook() {
|
||||||
|
const dataList = ref<ContactItem[]>([]);
|
||||||
|
|
||||||
|
// 获取数据
|
||||||
|
async function onSearch() {
|
||||||
|
const { data } = await getFriendList();
|
||||||
|
dataList.value = data;
|
||||||
|
console.log(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 挂载时执行
|
||||||
|
onMounted(() => {
|
||||||
|
onSearch();
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
dataList,
|
||||||
|
onSearch
|
||||||
|
}
|
||||||
|
}
|
||||||
47
frontend/src/views/friend/index.vue
Normal file
47
frontend/src/views/friend/index.vue
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
|
||||||
|
import { useHook } from '@/views/friend/hook'
|
||||||
|
|
||||||
|
defineOptions({
|
||||||
|
name: "FriendPage"
|
||||||
|
});
|
||||||
|
|
||||||
|
const { dataList, onSearch } = useHook()
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<ul role="list" class="grid grid-cols-1 gap-x-6 gap-y-8 lg:grid-cols-3 xl:gap-x-8">
|
||||||
|
<li class="overflow-hidden rounded-xl border border-gray-200" v-for="item in dataList" :key="item.Wxid">
|
||||||
|
<div class="flex items-center gap-x-4 border-b border-gray-900/5 bg-gray-50 p-6">
|
||||||
|
<img v-if="item.IsOk" src="@/assets/img/status-ok.png" alt="Tuple" class="h-12 w-12 flex-none rounded-lg bg-white object-cover ring-1 ring-gray-900/10">
|
||||||
|
<img v-else src="@/assets/img/status-fail.png" alt="Tuple" class="h-12 w-12 flex-none rounded-lg bg-white object-cover ring-1 ring-gray-900/10">
|
||||||
|
|
||||||
|
<div class="flex-1">
|
||||||
|
<div class="text-sm font-medium leading-6 text-gray-900">{{ item.Nickname }}</div>
|
||||||
|
<span v-if="item.IsOk"
|
||||||
|
class="inline-flex items-center rounded-md bg-green-50 px-2 py-1 text-xs font-medium text-green-700 ring-1 ring-inset ring-green-600/20">在通讯录</span>
|
||||||
|
<span v-else
|
||||||
|
class="inline-flex items-center rounded-md bg-red-50 px-2 py-1 text-xs font-medium text-red-700 ring-1 ring-inset ring-red-600/20">不在通讯录</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<dl class="-my-3 divide-y divide-gray-100 px-6 py-4 text-sm leading-6">
|
||||||
|
<div class="flex justify-between gap-x-4 py-3">
|
||||||
|
<dt class="text-gray-500">原始微信Id<br/>微信号</dt>
|
||||||
|
<dd>
|
||||||
|
<div class="text-gray-700">{{ item.Wxid }}</div>
|
||||||
|
<div class="truncate text-gray-500">{{ item.CustomAccount }}</div>
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
<div class="flex justify-between gap-x-4 py-3">
|
||||||
|
<dt class="text-gray-500">最后活跃时间</dt>
|
||||||
|
<dd class="flex items-start gap-x-2">
|
||||||
|
<div class="font-medium text-gray-900">
|
||||||
|
{{ item.LastActive }}
|
||||||
|
</div>
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</dl>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</template>
|
||||||
12
frontend/src/views/group/index.vue
Normal file
12
frontend/src/views/group/index.vue
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
|
||||||
|
defineOptions({
|
||||||
|
name: "GroupPage"
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<main>
|
||||||
|
<h1>群组</h1>
|
||||||
|
</main>
|
||||||
|
</template>
|
||||||
12
frontend/src/views/index/index.vue
Normal file
12
frontend/src/views/index/index.vue
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
|
||||||
|
defineOptions({
|
||||||
|
name: "IndexPage"
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<main>
|
||||||
|
<h1 class="text-orange-700">首页</h1>
|
||||||
|
</main>
|
||||||
|
</template>
|
||||||
12
frontend/tailwind.config.js
Normal file
12
frontend/tailwind.config.js
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
/** @type {import('tailwindcss').Config} */
|
||||||
|
export default {
|
||||||
|
content: ['./index.html', './src/**/*.{vue,js,ts,jsx,tsx,md}'],
|
||||||
|
theme: {
|
||||||
|
container: {
|
||||||
|
center: true,
|
||||||
|
padding: '2rem',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
plugins: [require('daisyui'), require('@tailwindcss/forms'),],
|
||||||
|
}
|
||||||
|
|
||||||
14
frontend/tsconfig.app.json
Normal file
14
frontend/tsconfig.app.json
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"extends": "@vue/tsconfig/tsconfig.dom.json",
|
||||||
|
"include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
|
||||||
|
"exclude": ["src/**/__tests__/*"],
|
||||||
|
"compilerOptions": {
|
||||||
|
"composite": true,
|
||||||
|
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
||||||
|
|
||||||
|
"baseUrl": ".",
|
||||||
|
"paths": {
|
||||||
|
"@/*": ["./src/*"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
frontend/tsconfig.json
Normal file
11
frontend/tsconfig.json
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"files": [],
|
||||||
|
"references": [
|
||||||
|
{
|
||||||
|
"path": "./tsconfig.node.json"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "./tsconfig.app.json"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
19
frontend/tsconfig.node.json
Normal file
19
frontend/tsconfig.node.json
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"extends": "@tsconfig/node20/tsconfig.json",
|
||||||
|
"include": [
|
||||||
|
"vite.config.*",
|
||||||
|
"vitest.config.*",
|
||||||
|
"cypress.config.*",
|
||||||
|
"nightwatch.conf.*",
|
||||||
|
"playwright.config.*"
|
||||||
|
],
|
||||||
|
"compilerOptions": {
|
||||||
|
"composite": true,
|
||||||
|
"noEmit": true,
|
||||||
|
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
||||||
|
|
||||||
|
"module": "ESNext",
|
||||||
|
"moduleResolution": "Bundler",
|
||||||
|
"types": ["node"]
|
||||||
|
}
|
||||||
|
}
|
||||||
28
frontend/vite.config.ts
Normal file
28
frontend/vite.config.ts
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
import { fileURLToPath, URL } from 'node:url'
|
||||||
|
|
||||||
|
import { defineConfig } from 'vite'
|
||||||
|
import vue from '@vitejs/plugin-vue'
|
||||||
|
import vueJsx from '@vitejs/plugin-vue-jsx'
|
||||||
|
|
||||||
|
// https://vitejs.dev/config/
|
||||||
|
export default defineConfig({
|
||||||
|
server: {
|
||||||
|
proxy: {
|
||||||
|
"/api": {
|
||||||
|
// target: "https://graduate.frps.ltd",
|
||||||
|
target: "http://127.0.0.1:8080",
|
||||||
|
changeOrigin: true
|
||||||
|
// rewrite: path => path.replace(/^\/api/, "")
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
vue(),
|
||||||
|
vueJsx(),
|
||||||
|
],
|
||||||
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
'@': fileURLToPath(new URL('./src', import.meta.url))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -2,7 +2,7 @@ package initialization
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"go-wechat/common/current"
|
"go-wechat/common/current"
|
||||||
"go-wechat/model"
|
"go-wechat/model/model"
|
||||||
plugin "go-wechat/plugin"
|
plugin "go-wechat/plugin"
|
||||||
"go-wechat/plugin/plugins"
|
"go-wechat/plugin/plugins"
|
||||||
"go-wechat/service"
|
"go-wechat/service"
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"github.com/go-resty/resty/v2"
|
"github.com/go-resty/resty/v2"
|
||||||
"go-wechat/common/current"
|
"go-wechat/common/current"
|
||||||
"go-wechat/config"
|
"go-wechat/config"
|
||||||
"go-wechat/model"
|
model2 "go-wechat/model/model"
|
||||||
"log"
|
"log"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
// @description: 初始化微信机器人信息
|
// @description: 初始化微信机器人信息
|
||||||
func InitWechatRobotInfo() {
|
func InitWechatRobotInfo() {
|
||||||
// 获取数据
|
// 获取数据
|
||||||
var base model.Response[model.RobotUserInfo]
|
var base model2.Response[model2.RobotUserInfo]
|
||||||
_, err := resty.New().R().
|
_, err := resty.New().R().
|
||||||
SetHeader("Content-Type", "application/json;chartset=utf-8").
|
SetHeader("Content-Type", "application/json;chartset=utf-8").
|
||||||
SetResult(&base).
|
SetResult(&base).
|
||||||
|
|||||||
2
main.go
2
main.go
@@ -48,6 +48,8 @@ func main() {
|
|||||||
return "群组列表"
|
return "群组列表"
|
||||||
case "index":
|
case "index":
|
||||||
return "首页"
|
return "首页"
|
||||||
|
case "assistant":
|
||||||
|
return "AI角色"
|
||||||
default:
|
default:
|
||||||
return "其他页面"
|
return "其他页面"
|
||||||
}
|
}
|
||||||
|
|||||||
39
model/entity/aiassistant.go
Normal file
39
model/entity/aiassistant.go
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
package entity
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/google/uuid"
|
||||||
|
"go-wechat/common/types"
|
||||||
|
"gorm.io/gorm"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AiAssistant
|
||||||
|
// @description: AI助手表
|
||||||
|
type AiAssistant struct {
|
||||||
|
Id string `json:"id" gorm:"type:varchar(32);primarykey"`
|
||||||
|
CreatedAt types.DateTime `json:"createdAt"`
|
||||||
|
Name string `json:"name" gorm:"type:varchar(10);not null;comment:'名称'"`
|
||||||
|
Personality string `json:"personality" gorm:"type:varchar(999);not null;comment:'人设'"`
|
||||||
|
Model string `json:"model" gorm:"type:varchar(50);not null;comment:'使用的模型'"`
|
||||||
|
Enable bool `json:"enable" gorm:"type:tinyint(1);not null;default:1;comment:'是否启用'"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// TableName
|
||||||
|
// @description: 表名
|
||||||
|
// @receiver AiAssistant
|
||||||
|
// @return string
|
||||||
|
func (AiAssistant) TableName() string {
|
||||||
|
return "t_ai_assistant"
|
||||||
|
}
|
||||||
|
|
||||||
|
// BeforeCreate
|
||||||
|
// @description: 创建数据库对象之前生成UUID
|
||||||
|
// @receiver m
|
||||||
|
// @param *gorm.DB
|
||||||
|
// @return err
|
||||||
|
func (m *AiAssistant) BeforeCreate(*gorm.DB) (err error) {
|
||||||
|
if m.Id == "" {
|
||||||
|
m.Id = strings.ReplaceAll(uuid.New().String(), "-", "")
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
@@ -163,3 +163,15 @@ func (m Message) CleanContentStartWith(prefix string) bool {
|
|||||||
|
|
||||||
return strings.HasPrefix(content, prefix)
|
return strings.HasPrefix(content, prefix)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsInvitationJoinGroup
|
||||||
|
// @description: 是否是邀请入群消息
|
||||||
|
// @receiver m
|
||||||
|
// @return bool
|
||||||
|
func (m Message) IsInvitationJoinGroup() bool {
|
||||||
|
if m.Type == types.MsgTypeApp {
|
||||||
|
// 解析xml
|
||||||
|
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
@@ -15,6 +15,7 @@ type FriendItem struct {
|
|||||||
LastActive types.DateTime // 最后活跃时间
|
LastActive types.DateTime // 最后活跃时间
|
||||||
EnableAi bool // 是否使用AI
|
EnableAi bool // 是否使用AI
|
||||||
AiModel string // AI模型
|
AiModel string // AI模型
|
||||||
|
Prompt string // AI助手或者自定义提示词
|
||||||
EnableChatRank bool // 是否使用聊天排行
|
EnableChatRank bool // 是否使用聊天排行
|
||||||
EnableWelcome bool // 是否使用迎新
|
EnableWelcome bool // 是否使用迎新
|
||||||
EnableCommand bool // 是否启用指令
|
EnableCommand bool // 是否启用指令
|
||||||
@@ -3,7 +3,7 @@ package mq
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"go-wechat/common/current"
|
"go-wechat/common/current"
|
||||||
"go-wechat/model"
|
"go-wechat/model/model"
|
||||||
"go-wechat/types"
|
"go-wechat/types"
|
||||||
"log"
|
"log"
|
||||||
"strings"
|
"strings"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package plugin
|
package plugin
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go-wechat/model"
|
"go-wechat/model/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MessageHandler 消息处理函数
|
// MessageHandler 消息处理函数
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
"go-wechat/client"
|
"go-wechat/client"
|
||||||
"go-wechat/common/current"
|
"go-wechat/common/current"
|
||||||
"go-wechat/config"
|
"go-wechat/config"
|
||||||
"go-wechat/entity"
|
"go-wechat/model/entity"
|
||||||
"go-wechat/plugin"
|
"go-wechat/plugin"
|
||||||
"go-wechat/service"
|
"go-wechat/service"
|
||||||
"go-wechat/types"
|
"go-wechat/types"
|
||||||
@@ -48,8 +48,23 @@ func AI(m *plugin.MessageContext) {
|
|||||||
|
|
||||||
// 处理预设角色,默认是配置文件里的,如果数据库配置不为空,则使用数据库配置
|
// 处理预设角色,默认是配置文件里的,如果数据库配置不为空,则使用数据库配置
|
||||||
prompt := config.Conf.Ai.Personality
|
prompt := config.Conf.Ai.Personality
|
||||||
|
var dbPrompt entity.AiAssistant
|
||||||
if friendInfo.Prompt != "" {
|
if friendInfo.Prompt != "" {
|
||||||
prompt = friendInfo.Prompt
|
// 取出配置的角色
|
||||||
|
client.MySQL.First(&dbPrompt, "id = ?", friendInfo.Prompt)
|
||||||
|
if dbPrompt.Id != "" {
|
||||||
|
prompt = dbPrompt.Personality
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 配置模型
|
||||||
|
chatModel := openai.GPT3Dot5Turbo0613
|
||||||
|
if friendInfo.AiModel != "" {
|
||||||
|
chatModel = friendInfo.AiModel
|
||||||
|
} else if dbPrompt.Model != "" {
|
||||||
|
chatModel = dbPrompt.Model
|
||||||
|
} else if config.Conf.Ai.Model != "" {
|
||||||
|
chatModel = config.Conf.Ai.Model
|
||||||
}
|
}
|
||||||
|
|
||||||
// 组装消息体
|
// 组装消息体
|
||||||
@@ -101,14 +116,6 @@ func AI(m *plugin.MessageContext) {
|
|||||||
Content: m.Content,
|
Content: m.Content,
|
||||||
})
|
})
|
||||||
|
|
||||||
// 配置模型
|
|
||||||
chatModel := openai.GPT3Dot5Turbo0613
|
|
||||||
if friendInfo.AiModel != "" {
|
|
||||||
chatModel = friendInfo.AiModel
|
|
||||||
} else if config.Conf.Ai.Model != "" {
|
|
||||||
chatModel = config.Conf.Ai.Model
|
|
||||||
}
|
|
||||||
|
|
||||||
// 默认使用AI回复
|
// 默认使用AI回复
|
||||||
conf := openai.DefaultConfig(config.Conf.Ai.ApiKey)
|
conf := openai.DefaultConfig(config.Conf.Ai.ApiKey)
|
||||||
if config.Conf.Ai.BaseUrl != "" {
|
if config.Conf.Ai.BaseUrl != "" {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package command
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"go-wechat/client"
|
"go-wechat/client"
|
||||||
"go-wechat/entity"
|
"go-wechat/model/entity"
|
||||||
"go-wechat/utils"
|
"go-wechat/utils"
|
||||||
"log"
|
"log"
|
||||||
"strings"
|
"strings"
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"github.com/go-resty/resty/v2"
|
"github.com/go-resty/resty/v2"
|
||||||
"go-wechat/utils"
|
"go-wechat/utils"
|
||||||
"log"
|
"log"
|
||||||
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
// KfcCrazyThursdayCmd
|
// KfcCrazyThursdayCmd
|
||||||
@@ -33,8 +34,9 @@ func kfcApi1() string {
|
|||||||
res := resty.New()
|
res := resty.New()
|
||||||
resp, err := res.R().
|
resp, err := res.R().
|
||||||
Post("https://api.jixs.cc/api/wenan-fkxqs/index.php")
|
Post("https://api.jixs.cc/api/wenan-fkxqs/index.php")
|
||||||
if err != nil {
|
if err != nil || resp.StatusCode() != http.StatusOK {
|
||||||
log.Panicf("KFC接口1文案获取失败: %s", err.Error())
|
log.Printf("KFC接口1文案获取失败: %v", err)
|
||||||
|
return ""
|
||||||
}
|
}
|
||||||
log.Printf("KFC接口1文案获取结果: %s", resp.String())
|
log.Printf("KFC接口1文案获取结果: %s", resp.String())
|
||||||
return resp.String()
|
return resp.String()
|
||||||
@@ -58,8 +60,9 @@ func kfcApi2() string {
|
|||||||
resp, err := res.R().
|
resp, err := res.R().
|
||||||
SetResult(&resData).
|
SetResult(&resData).
|
||||||
Post("https://api.jixs.cc/api/wenan-fkxqs/index.php")
|
Post("https://api.jixs.cc/api/wenan-fkxqs/index.php")
|
||||||
if err != nil {
|
if err != nil || resp.StatusCode() != http.StatusOK {
|
||||||
log.Panicf("KFC接口2文案获取失败: %s", err.Error())
|
log.Printf("KFC接口2文案获取失败: %v", err)
|
||||||
|
return ""
|
||||||
}
|
}
|
||||||
log.Printf("KFC接口2文案获取结果: %s", resp.String())
|
log.Printf("KFC接口2文案获取结果: %s", resp.String())
|
||||||
if resData.Data.Msg != "" {
|
if resData.Data.Msg != "" {
|
||||||
@@ -84,8 +87,9 @@ func kfcApi3() string {
|
|||||||
resp, err := res.R().
|
resp, err := res.R().
|
||||||
SetResult(&resData).
|
SetResult(&resData).
|
||||||
Post("https://api.pearktrue.cn/api/kfc")
|
Post("https://api.pearktrue.cn/api/kfc")
|
||||||
if err != nil {
|
if err != nil || resp.StatusCode() != http.StatusOK {
|
||||||
log.Panicf("KFC接口3文案获取失败: %s", err.Error())
|
log.Printf("KFC接口3文案获取失败: %v", err)
|
||||||
|
return ""
|
||||||
}
|
}
|
||||||
log.Printf("KFC接口3文案获取结果: %s", resp.String())
|
log.Printf("KFC接口3文案获取结果: %s", resp.String())
|
||||||
if resData.Text != "" {
|
if resData.Text != "" {
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"go-wechat/client"
|
"go-wechat/client"
|
||||||
"go-wechat/entity"
|
"go-wechat/model/entity"
|
||||||
"go-wechat/model"
|
"go-wechat/model/model"
|
||||||
|
"go-wechat/model/vo"
|
||||||
"go-wechat/utils"
|
"go-wechat/utils"
|
||||||
"go-wechat/vo"
|
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
"log"
|
"log"
|
||||||
"strings"
|
"strings"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package plugins
|
package plugins
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go-wechat/entity"
|
"go-wechat/model/entity"
|
||||||
"go-wechat/plugin"
|
"go-wechat/plugin"
|
||||||
"go-wechat/service"
|
"go-wechat/service"
|
||||||
"time"
|
"time"
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package plugins
|
|||||||
import (
|
import (
|
||||||
"go-wechat/client"
|
"go-wechat/client"
|
||||||
"go-wechat/config"
|
"go-wechat/config"
|
||||||
"go-wechat/entity"
|
"go-wechat/model/entity"
|
||||||
"go-wechat/plugin"
|
"go-wechat/plugin"
|
||||||
"go-wechat/utils"
|
"go-wechat/utils"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -9,26 +9,49 @@ import (
|
|||||||
// @description: 初始化路由
|
// @description: 初始化路由
|
||||||
// @param g
|
// @param g
|
||||||
func Init(g *gin.Engine) {
|
func Init(g *gin.Engine) {
|
||||||
g.GET("/", func(ctx *gin.Context) {
|
//g.GET("/", func(ctx *gin.Context) {
|
||||||
// 重定向到index.html
|
// // 重定向到index.html
|
||||||
ctx.Redirect(302, "/index.html")
|
// ctx.Redirect(302, "/index.html")
|
||||||
})
|
//})
|
||||||
|
|
||||||
g.GET("/index.html", app.Index) // 首页
|
g.GET("/index.html", app.Index) // 首页
|
||||||
g.GET("/friend.html", app.Friend) // 好友列表
|
g.GET("/friend.html", app.Friend) // 好友列表
|
||||||
g.GET("/group.html", app.Group) // 群组列表
|
g.GET("/group.html", app.Group) // 群组列表
|
||||||
|
g.GET("/assistant.html", app.Assistant) // AI角色
|
||||||
|
|
||||||
g.GET("/404.html", app.PageNotFound) // 群组列表
|
//g.GET("/404.html", app.PageNotFound) // 群组列表
|
||||||
|
|
||||||
// 接口
|
// 接口
|
||||||
api := g.Group("/api")
|
api := g.Group("/api")
|
||||||
api.PUT("/ai/status", app.ChangeEnableAiStatus) // 修改是否开启AI状态
|
|
||||||
api.POST("/ai/model", app.ChangeUseAiModel) // 修改使用的AI模型
|
contact := api.Group("/contact") // 通讯录
|
||||||
api.PUT("/welcome/status", app.ChangeEnableWelcomeStatus) // 修改是否开启迎新状态
|
{
|
||||||
api.PUT("/command/status", app.ChangeEnableCommandStatus) // 修改是否开启指令状态
|
contact.GET("/friend", app.GetFriends) // 获取好友列表
|
||||||
api.PUT("/news/status", app.ChangeEnableNewsStatus) // 修改是否开启早报状态
|
contact.GET("/group", app.GetGroups) // 获取群组列表
|
||||||
api.PUT("/grouprank/status", app.ChangeEnableGroupRankStatus) // 修改是否开启水群排行榜状态
|
profile := contact.Group("/profile") // 配置
|
||||||
api.PUT("/grouprank/skip", app.ChangeSkipGroupRankStatus) // 修改是否跳过水群排行榜状态
|
{
|
||||||
api.GET("/group/users", app.GetGroupUsers) // 获取群成员列表
|
profile.PUT("/ai/status", app.ChangeEnableAiStatus) // 修改是否开启AI状态
|
||||||
api.PUT("/summary/status", app.ChangeEnableSummaryStatus) // 修改是否开启群聊总结状态
|
profile.POST("/ai/model", app.ChangeUseAiModel) // 修改使用的AI模型
|
||||||
|
profile.POST("/ai/assistant", app.ChangeUseAiAssistant) // 修改使用的AI助手
|
||||||
|
profile.PUT("/welcome/status", app.ChangeEnableWelcomeStatus) // 修改是否开启迎新
|
||||||
|
profile.PUT("/command/status", app.ChangeEnableCommandStatus) // 修改是否开启指令
|
||||||
|
profile.PUT("/news/status", app.ChangeEnableNewsStatus) // 修改是否开启早报
|
||||||
|
profile.PUT("/grouprank/status", app.ChangeEnableGroupRankStatus) // 修改是否开启水群排行榜
|
||||||
|
profile.PUT("/summary/status", app.ChangeEnableSummaryStatus) // 修改是否开启群聊总结
|
||||||
|
profile.PUT("/clearmembers", app.AutoClearMembers) // 自动清理群成员
|
||||||
|
}
|
||||||
|
|
||||||
|
group := contact.Group("/group") // 群组
|
||||||
|
{
|
||||||
|
group.GET("/users", app.GetGroupUsers) // 获取群成员列表
|
||||||
|
group.PUT("/grouprank/skip", app.ChangeSkipGroupRankStatus) // 修改是否跳过水群排行榜状态
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
system := api.Group("/system") // 系统设置
|
||||||
|
{
|
||||||
|
system.GET("/assistant", app.GetAssistants) // 获取AI助手列表
|
||||||
|
system.POST("/assistant", app.SaveAssistant) // 保存AI助手
|
||||||
|
system.GET("/models", app.GetAiModels) // 获取AI模型列表
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
14
service/aiassistant.go
Normal file
14
service/aiassistant.go
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
package service
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go-wechat/client"
|
||||||
|
"go-wechat/model/entity"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetAllAiAssistant
|
||||||
|
// @description: 取出所有AI助手
|
||||||
|
// @return records
|
||||||
|
func GetAllAiAssistant() (records []entity.AiAssistant, err error) {
|
||||||
|
err = client.MySQL.Order("created_at DESC").Find(&records).Error
|
||||||
|
return
|
||||||
|
}
|
||||||
@@ -2,8 +2,8 @@ package service
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"go-wechat/client"
|
"go-wechat/client"
|
||||||
"go-wechat/entity"
|
"go-wechat/model/entity"
|
||||||
"go-wechat/vo"
|
"go-wechat/model/vo"
|
||||||
"log"
|
"log"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package service
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"go-wechat/client"
|
"go-wechat/client"
|
||||||
"go-wechat/vo"
|
"go-wechat/model/vo"
|
||||||
)
|
)
|
||||||
|
|
||||||
// GetGroupUsersByGroupId
|
// GetGroupUsersByGroupId
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package service
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"go-wechat/client"
|
"go-wechat/client"
|
||||||
"go-wechat/entity"
|
"go-wechat/model/entity"
|
||||||
"go-wechat/vo"
|
"go-wechat/model/vo"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -73,6 +73,8 @@ func GetTextMessagesById(id string) (records []vo.TextMessageItem, err error) {
|
|||||||
Where("tm.`from_user` = ?", id).
|
Where("tm.`from_user` = ?", id).
|
||||||
Where(`(tm.type = 1 OR ( tm.type = 49 AND EXTRACTVALUE ( tm.content, "/msg/appmsg/type" ) IN (?) ))`, appMsgList).
|
Where(`(tm.type = 1 OR ( tm.type = 49 AND EXTRACTVALUE ( tm.content, "/msg/appmsg/type" ) IN (?) ))`, appMsgList).
|
||||||
Where("DATE ( tm.create_at ) = DATE ( CURDATE() - INTERVAL 1 DAY )").
|
Where("DATE ( tm.create_at ) = DATE ( CURDATE() - INTERVAL 1 DAY )").
|
||||||
|
Where("tm.content NOT LIKE '#昨日水群排行榜%'").
|
||||||
|
Where("tm.content NOT LIKE '#昨日消息总结%'").
|
||||||
Order("tm.create_at ASC")
|
Order("tm.create_at ASC")
|
||||||
|
|
||||||
err = tx.Find(&records).Error
|
err = tx.Find(&records).Error
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package cleargroupuser
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"go-wechat/client"
|
"go-wechat/client"
|
||||||
"go-wechat/entity"
|
"go-wechat/model/entity"
|
||||||
"go-wechat/service"
|
"go-wechat/service"
|
||||||
"go-wechat/utils"
|
"go-wechat/utils"
|
||||||
"log"
|
"log"
|
||||||
@@ -44,7 +44,7 @@ func ClearGroupUser() {
|
|||||||
for k, v := range memberMap {
|
for k, v := range memberMap {
|
||||||
ms = append(ms, fmt.Sprintf("昵称:%s\n最后活跃时间:%s", k, v))
|
ms = append(ms, fmt.Sprintf("昵称:%s\n最后活跃时间:%s", k, v))
|
||||||
}
|
}
|
||||||
msg := fmt.Sprintf("#清理群成员\n\n很遗憾地通知各位,就在刚刚,有%d名群友引活跃度不够暂时离开了我们,希望还健在的群友引以为戒、保持活跃!\n\n活跃信息: \n%s",
|
msg := fmt.Sprintf("#清理群成员\n\n很遗憾地通知各位,就在刚刚,有%d名群友因活跃度不够暂时离开了我们,希望还健在的群友引以为戒、保持活跃!\n\n详细信息: \n%s",
|
||||||
memberCount, strings.Join(ms, "\n"))
|
memberCount, strings.Join(ms, "\n"))
|
||||||
utils.SendMessage(group.Wxid, "", msg, 0)
|
utils.SendMessage(group.Wxid, "", msg, 0)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ import (
|
|||||||
"go-wechat/client"
|
"go-wechat/client"
|
||||||
"go-wechat/common/constant"
|
"go-wechat/common/constant"
|
||||||
"go-wechat/config"
|
"go-wechat/config"
|
||||||
"go-wechat/entity"
|
"go-wechat/model/entity"
|
||||||
"go-wechat/model"
|
model2 "go-wechat/model/model"
|
||||||
"go-wechat/utils"
|
"go-wechat/utils"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
"log"
|
"log"
|
||||||
@@ -24,7 +24,7 @@ var hc = resty.New()
|
|||||||
// Sync
|
// Sync
|
||||||
// @description: 同步好友列表
|
// @description: 同步好友列表
|
||||||
func Sync() {
|
func Sync() {
|
||||||
var base model.Response[[]model.FriendItem]
|
var base model2.Response[[]model2.FriendItem]
|
||||||
|
|
||||||
resp, err := hc.R().
|
resp, err := hc.R().
|
||||||
SetHeader("Content-Type", "application/json;chartset=utf-8").
|
SetHeader("Content-Type", "application/json;chartset=utf-8").
|
||||||
@@ -103,6 +103,7 @@ func Sync() {
|
|||||||
"custom_account": friend.CustomAccount,
|
"custom_account": friend.CustomAccount,
|
||||||
"pinyin": friend.Pinyin,
|
"pinyin": friend.Pinyin,
|
||||||
"pinyin_all": friend.PinyinAll,
|
"pinyin_all": friend.PinyinAll,
|
||||||
|
"is_ok": true,
|
||||||
}
|
}
|
||||||
err = tx.Model(&entity.Friend{}).Where("wxid = ?", friend.Wxid).Updates(pm).Error
|
err = tx.Model(&entity.Friend{}).Where("wxid = ?", friend.Wxid).Updates(pm).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -133,7 +134,19 @@ func Sync() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 清理不在列表中的好友
|
// 清理不在列表中的好友
|
||||||
err = tx.Model(&entity.Friend{}).Where("wxid NOT IN (?)", nowIds).Update("is_ok", false).Error
|
clearPm := map[string]any{
|
||||||
|
"is_ok": false,
|
||||||
|
"enable_chat_rank": false,
|
||||||
|
"enable_welcome": false,
|
||||||
|
"enable_summary": false,
|
||||||
|
"enable_news": false,
|
||||||
|
"clear_member": false,
|
||||||
|
"enable_ai": false,
|
||||||
|
}
|
||||||
|
err = tx.Model(&entity.Friend{}).Where("wxid NOT IN (?)", nowIds).Updates(clearPm).Error
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("清理好友失败: %s", err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
log.Println("同步好友列表完成")
|
log.Println("同步好友列表完成")
|
||||||
}
|
}
|
||||||
@@ -142,7 +155,7 @@ func Sync() {
|
|||||||
// @description: 同步群成员
|
// @description: 同步群成员
|
||||||
// @param gid
|
// @param gid
|
||||||
func syncGroupUsers(tx *gorm.DB, gid string) {
|
func syncGroupUsers(tx *gorm.DB, gid string) {
|
||||||
var baseResp model.Response[model.GroupUser]
|
var baseResp model2.Response[model2.GroupUser]
|
||||||
|
|
||||||
// 组装参数
|
// 组装参数
|
||||||
param := map[string]any{
|
param := map[string]any{
|
||||||
@@ -229,8 +242,8 @@ func syncGroupUsers(tx *gorm.DB, gid string) {
|
|||||||
// @param wxid
|
// @param wxid
|
||||||
// @return ent
|
// @return ent
|
||||||
// @return err
|
// @return err
|
||||||
func getContactProfile(wxid string) (ent model.ContactProfile, err error) {
|
func getContactProfile(wxid string) (ent model2.ContactProfile, err error) {
|
||||||
var baseResp model.Response[model.ContactProfile]
|
var baseResp model2.Response[model2.ContactProfile]
|
||||||
|
|
||||||
// 组装参数
|
// 组装参数
|
||||||
param := map[string]any{
|
param := map[string]any{
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/sashabaranov/go-openai"
|
"github.com/sashabaranov/go-openai"
|
||||||
"go-wechat/config"
|
"go-wechat/config"
|
||||||
|
"go-wechat/model/vo"
|
||||||
"go-wechat/service"
|
"go-wechat/service"
|
||||||
"go-wechat/utils"
|
"go-wechat/utils"
|
||||||
"go-wechat/vo"
|
|
||||||
"log"
|
"log"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
@@ -42,11 +42,12 @@ func AiSummary() {
|
|||||||
注意,他们可能是多个话题,请仔细甄别。
|
注意,他们可能是多个话题,请仔细甄别。
|
||||||
每一行代表一个人的发言,每一行的的格式为: {"{nickname}": "{content}"}--end--
|
每一行代表一个人的发言,每一行的的格式为: {"{nickname}": "{content}"}--end--
|
||||||
|
|
||||||
|
群名称: %s
|
||||||
聊天记录如下:
|
聊天记录如下:
|
||||||
%s
|
%s
|
||||||
`
|
`
|
||||||
|
|
||||||
msg := fmt.Sprintf(msgTmp, strings.Join(content, "\n"))
|
msg := fmt.Sprintf(msgTmp, group.Nickname, strings.Join(content, "\n"))
|
||||||
|
|
||||||
// AI总结
|
// AI总结
|
||||||
messages := []openai.ChatCompletionMessage{
|
messages := []openai.ChatCompletionMessage{
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"go-wechat/client"
|
"go-wechat/client"
|
||||||
"go-wechat/config"
|
"go-wechat/config"
|
||||||
"go-wechat/entity"
|
"go-wechat/model/entity"
|
||||||
"go-wechat/service"
|
"go-wechat/service"
|
||||||
"go-wechat/utils"
|
"go-wechat/utils"
|
||||||
"log"
|
"log"
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"go-wechat/client"
|
"go-wechat/client"
|
||||||
"go-wechat/config"
|
"go-wechat/config"
|
||||||
"go-wechat/entity"
|
"go-wechat/model/entity"
|
||||||
"go-wechat/service"
|
"go-wechat/service"
|
||||||
"go-wechat/utils"
|
"go-wechat/utils"
|
||||||
"log"
|
"log"
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"go-wechat/client"
|
"go-wechat/client"
|
||||||
"go-wechat/config"
|
"go-wechat/config"
|
||||||
"go-wechat/entity"
|
"go-wechat/model/entity"
|
||||||
"go-wechat/service"
|
"go-wechat/service"
|
||||||
"go-wechat/utils"
|
"go-wechat/utils"
|
||||||
"log"
|
"log"
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"go-wechat/client"
|
"go-wechat/client"
|
||||||
"go-wechat/config"
|
"go-wechat/config"
|
||||||
"go-wechat/entity"
|
"go-wechat/model/entity"
|
||||||
"go-wechat/service"
|
"go-wechat/service"
|
||||||
"go-wechat/utils"
|
"go-wechat/utils"
|
||||||
"log"
|
"log"
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package tcpserver
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"go-wechat/common/current"
|
"go-wechat/common/current"
|
||||||
"go-wechat/model"
|
"go-wechat/model/model"
|
||||||
"go-wechat/types"
|
"go-wechat/types"
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
|
|||||||
@@ -6,16 +6,16 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/go-resty/resty/v2"
|
"github.com/go-resty/resty/v2"
|
||||||
"go-wechat/model"
|
model2 "go-wechat/model/model"
|
||||||
"log"
|
"log"
|
||||||
)
|
)
|
||||||
|
|
||||||
// LeiGod
|
// LeiGod
|
||||||
// @description: 雷神加速器相关接口
|
// @description: 雷神加速器相关接口
|
||||||
type LeiGod interface {
|
type LeiGod interface {
|
||||||
Login() error // 登录
|
Login() error // 登录
|
||||||
Info() (model.LeiGodUserInfoResp, error) // 获取用户信息
|
Info() (model2.LeiGodUserInfoResp, error) // 获取用户信息
|
||||||
Pause() error // 暂停加速
|
Pause() error // 暂停加速
|
||||||
}
|
}
|
||||||
|
|
||||||
type leiGod struct {
|
type leiGod struct {
|
||||||
@@ -59,7 +59,7 @@ func (l *leiGod) Login() (err error) {
|
|||||||
}
|
}
|
||||||
pbs, _ := json.Marshal(param)
|
pbs, _ := json.Marshal(param)
|
||||||
|
|
||||||
var loginResp model.Response[any]
|
var loginResp model2.Response[any]
|
||||||
var resp *resty.Response
|
var resp *resty.Response
|
||||||
|
|
||||||
res := resty.New()
|
res := resty.New()
|
||||||
@@ -84,7 +84,7 @@ func (l *leiGod) Login() (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var loginInfo model.LeiGodLoginResp
|
var loginInfo model2.LeiGodLoginResp
|
||||||
if err = json.Unmarshal(bs, &loginInfo); err != nil {
|
if err = json.Unmarshal(bs, &loginInfo); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -100,7 +100,7 @@ func (l *leiGod) Login() (err error) {
|
|||||||
// @description: 获取用户信息
|
// @description: 获取用户信息
|
||||||
// @receiver l
|
// @receiver l
|
||||||
// @return string
|
// @return string
|
||||||
func (l *leiGod) Info() (ui model.LeiGodUserInfoResp, err error) {
|
func (l *leiGod) Info() (ui model2.LeiGodUserInfoResp, err error) {
|
||||||
// 组装参数
|
// 组装参数
|
||||||
param := map[string]any{
|
param := map[string]any{
|
||||||
"account_token": l.token,
|
"account_token": l.token,
|
||||||
@@ -109,7 +109,7 @@ func (l *leiGod) Info() (ui model.LeiGodUserInfoResp, err error) {
|
|||||||
}
|
}
|
||||||
pbs, _ := json.Marshal(param)
|
pbs, _ := json.Marshal(param)
|
||||||
|
|
||||||
var userInfoResp model.Response[model.LeiGodUserInfoResp]
|
var userInfoResp model2.Response[model2.LeiGodUserInfoResp]
|
||||||
var resp *resty.Response
|
var resp *resty.Response
|
||||||
|
|
||||||
res := resty.New()
|
res := resty.New()
|
||||||
@@ -145,7 +145,7 @@ func (l *leiGod) Pause() (err error) {
|
|||||||
}
|
}
|
||||||
pbs, _ := json.Marshal(param)
|
pbs, _ := json.Marshal(param)
|
||||||
|
|
||||||
var pauseResp model.Response[any]
|
var pauseResp model2.Response[any]
|
||||||
var resp *resty.Response
|
var resp *resty.Response
|
||||||
|
|
||||||
res := resty.New()
|
res := resty.New()
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package utils
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/go-resty/resty/v2"
|
"github.com/go-resty/resty/v2"
|
||||||
"go-wechat/model"
|
"go-wechat/model/model"
|
||||||
"log"
|
"log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -148,7 +148,9 @@ func DeleteGroupMember(chatRoomId, memberIds string, retryCount int) {
|
|||||||
log.Printf("删除群成员失败: %s", err.Error())
|
log.Printf("删除群成员失败: %s", err.Error())
|
||||||
// 休眠五秒后重新发送
|
// 休眠五秒后重新发送
|
||||||
time.Sleep(5 * time.Second)
|
time.Sleep(5 * time.Second)
|
||||||
SendImage(chatRoomId, memberIds, retryCount+1)
|
DeleteGroupMember(chatRoomId, memberIds, retryCount+1)
|
||||||
}
|
}
|
||||||
log.Printf("删除群成员结果: %s", resp.String())
|
log.Printf("删除群成员结果: %s", resp.String())
|
||||||
|
// 这个逼接口要调用两次,第一次调用成功,第二次调用才会真正删除
|
||||||
|
DeleteGroupMember(chatRoomId, memberIds, 5)
|
||||||
}
|
}
|
||||||
|
|||||||
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>
|
||||||
@@ -197,9 +197,9 @@
|
|||||||
{{define "flagTag"}}
|
{{define "flagTag"}}
|
||||||
{{ if eq . true }}
|
{{ if eq . true }}
|
||||||
<span
|
<span
|
||||||
class="inline-flex items-center rounded-md bg-green-50 px-2 py-1 text-xs font-medium text-green-700 ring-1 ring-inset ring-green-600/20">是</span>
|
class="inline-flex items-center rounded-md bg-green-50 px-2 py-1 text-xs font-medium text-green-700 ring-1 ring-inset ring-green-600/20">在通讯录</span>
|
||||||
{{ else }}
|
{{ else }}
|
||||||
<span
|
<span
|
||||||
class="inline-flex items-center rounded-md bg-red-50 px-2 py-1 text-xs font-medium text-red-700 ring-1 ring-inset ring-red-600/20">否</span>
|
class="inline-flex items-center rounded-md bg-red-50 px-2 py-1 text-xs font-medium text-red-700 ring-1 ring-inset ring-red-600/20">不在通讯录</span>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
<main class="-mt-32">
|
<main class="-mt-32">
|
||||||
<div class="mx-auto max-w-7xl px-4 pb-12 sm:px-6 lg:px-8">
|
<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">
|
<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-3 xl:gap-x-8">
|
<ul role="list" class="grid grid-cols-1 gap-x-6 gap-y-8 lg:grid-cols-3 xl:gap-x-8">
|
||||||
{{ range .friends }}
|
{{ range .friends }}
|
||||||
<li class="overflow-hidden rounded-xl border border-gray-200">
|
<li class="overflow-hidden rounded-xl border border-gray-200">
|
||||||
@@ -76,6 +77,24 @@
|
|||||||
</label>
|
</label>
|
||||||
</dd>
|
</dd>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="flex justify-between gap-x-4 py-3">
|
||||||
|
<dt class="text-gray-500 mt-2">AI角色</dt>
|
||||||
|
<dd class="flex items-start gap-x-2">
|
||||||
|
<label>
|
||||||
|
<select 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" onchange="aiAssistantChange(event, {{.Wxid}})">
|
||||||
|
<option value="" {{ if eq .Prompt "" }}selected{{ end }}>默认</option>
|
||||||
|
|
||||||
|
{{$usePrompt := .Prompt}}
|
||||||
|
{{ range $.assistant }}
|
||||||
|
<option value="{{.Id}}" {{ if eq $usePrompt .Id}}selected{{ end }}>
|
||||||
|
{{.Name}}
|
||||||
|
</option>
|
||||||
|
{{ end }}
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
<div class="flex justify-between gap-x-4 py-3">
|
<div class="flex justify-between gap-x-4 py-3">
|
||||||
|
|||||||
218
views/group.html
218
views/group.html
@@ -21,105 +21,129 @@
|
|||||||
<main class="-mt-32">
|
<main class="-mt-32">
|
||||||
<div class="mx-auto max-w-7xl px-4 pb-12 sm:px-6 lg:px-8">
|
<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">
|
<div class="rounded-lg bg-white px-5 py-6 shadow sm:px-6 text-2xl">
|
||||||
<table class="min-w-full divide-y divide-gray-300">
|
<ul role="list" class="grid grid-cols-1 gap-x-6 gap-y-8 lg:grid-cols-2 xl:gap-x-8">
|
||||||
<thead class="bg-gray-50">
|
|
||||||
<tr>
|
|
||||||
<th scope="col" class="px-3 py-3.5 text-left text-sm font-semibold text-gray-900">群名称
|
|
||||||
</th>
|
|
||||||
<th scope="col" class="px-3 py-3.5 text-left text-sm font-semibold text-gray-900">
|
|
||||||
最后活跃时间
|
|
||||||
</th>
|
|
||||||
<th scope="col" class="px-3 py-3.5 text-left text-sm font-semibold text-gray-900">
|
|
||||||
是否在通讯录
|
|
||||||
</th>
|
|
||||||
<th scope="col" class="px-3 py-3.5 text-left text-sm font-semibold text-gray-900">
|
|
||||||
AI
|
|
||||||
</th>
|
|
||||||
<th scope="col" class="px-3 py-3.5 text-left text-sm font-semibold text-gray-900">
|
|
||||||
排行榜
|
|
||||||
</th>
|
|
||||||
<th scope="col" class="px-3 py-3.5 text-left text-sm font-semibold text-gray-900">
|
|
||||||
总结
|
|
||||||
</th>
|
|
||||||
<th scope="col" class="px-3 py-3.5 text-left text-sm font-semibold text-gray-900">
|
|
||||||
迎新
|
|
||||||
</th>
|
|
||||||
<th scope="col" class="px-3 py-3.5 text-left text-sm font-semibold text-gray-900">
|
|
||||||
早报
|
|
||||||
</th>
|
|
||||||
<th scope="col" class="px-3 py-3.5 text-left text-sm font-semibold text-gray-900">
|
|
||||||
指令
|
|
||||||
</th>
|
|
||||||
<th scope="col" class="px-3 py-3.5 text-left text-sm font-semibold text-gray-900">
|
|
||||||
末位淘汰(天)
|
|
||||||
</th>
|
|
||||||
<th scope="col" class="px-3 py-3.5 text-left text-sm font-semibold text-gray-900">
|
|
||||||
操作
|
|
||||||
</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody class="divide-y divide-gray-200 bg-white">
|
|
||||||
{{ range .groups }}
|
{{ range .groups }}
|
||||||
<tr class="even:bg-gray-50">
|
<li class="overflow-hidden rounded-xl border border-gray-200">
|
||||||
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500">
|
<div class="flex items -center gap-x-4 border-b border-gray-900/5 bg-gray-50 p-6">
|
||||||
<div class="font-medium text-gray-900">{{ .Nickname }}</div>
|
<img src="assets/img/status-{{ if eq .IsOk true }}ok{{else}}fail{{end}}.png" alt="Tuple"
|
||||||
<div class="mt-1 truncate text-gray-500">{{ .Wxid }}</div>
|
class="h-12 w-12 flex-none rounded-lg bg-white object-cover ring-1 ring-gray-900/10">
|
||||||
</td>
|
<div class="text-sm flex-1">
|
||||||
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500">
|
<div class="font-medium leading-6 text-gray-900">{{ .Nickname }}</div>
|
||||||
{{ if eq .LastActive.IsNil true }}
|
<div class="font-medium text-gray-500">{{ .Wxid }}</div>
|
||||||
无数据
|
{{ template "flagTag" .IsOk }}
|
||||||
{{ else }}
|
<button type="button" class="btn-link float-end text-red-600" onclick="getGroupUsers({{.Wxid}}, {{.Nickname}})">群成员</button>
|
||||||
{{ .LastActive }}
|
</div>
|
||||||
{{ end }}
|
</div>
|
||||||
</td>
|
|
||||||
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500">
|
|
||||||
{{ template "flagTag" .IsOk }}
|
|
||||||
</td>
|
|
||||||
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500">
|
|
||||||
{{ template "ai" . }}
|
|
||||||
<!-- 使用的模型 -->
|
|
||||||
{{ if eq .EnableAi true }}
|
|
||||||
<select id="location" name="location"
|
|
||||||
class="mt-2 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"
|
|
||||||
onchange="aiModelChange(event, {{.Wxid}})">
|
|
||||||
<option value="" {{ if eq .AiModel
|
|
||||||
"" }}selected{{ end }}>默认(gpt-3.5-turbo-0613)
|
|
||||||
</option>
|
|
||||||
|
|
||||||
{{$useModel := .AiModel}}
|
<dl class="-my-3 divide-y divide-gray-100 px-6 py-4 text-sm leading-6">
|
||||||
{{ range $.aiModels }}
|
<!-- 最后活跃时间 -->
|
||||||
<option value="{{.Model}}" {{ if eq $useModel .Model}}selected{{ end }}>
|
<div class="flex justify-between gap-x-4 py-3 items-center">
|
||||||
{{.Name}}({{.Model}})
|
<dt class="text-gray-500">最后活跃时间</dt>
|
||||||
</option>
|
<dd class="flex items-start gap-x-2">
|
||||||
{{ end }}
|
{{ if eq .LastActive.IsNil true }}
|
||||||
</select>
|
无活跃数据
|
||||||
{{ end }}
|
{{ else }}
|
||||||
</td>
|
<time datetime="{{ .LastActive }}">{{ .LastActive }}</time>
|
||||||
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500">
|
{{ end }}
|
||||||
{{ template "chatRank" . }}
|
</dd>
|
||||||
</td>
|
</div>
|
||||||
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500">
|
<!-- AI -->
|
||||||
{{ template "summary" . }}
|
<div class="flex justify-between gap-x-4 py-3 items-center">
|
||||||
</td>
|
<dt class="text-gray-500">AI(模型可选默认或者指定模型)</dt>
|
||||||
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500">
|
<dd class="flex items-start gap-x-2 items-center">
|
||||||
{{ template "welcome" . }}
|
<div>
|
||||||
</td>
|
{{ template "ai" . }}
|
||||||
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500">
|
</div>
|
||||||
{{ template "news" . }}
|
{{ if eq .EnableAi true }}
|
||||||
</td>
|
<div class="float-end">
|
||||||
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500">
|
<div>
|
||||||
{{ template "command" . }}
|
<label>
|
||||||
</td>
|
<select 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" onchange="aiModelChange(event, {{.Wxid}})">
|
||||||
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500">
|
{{$useModel := .AiModel}}
|
||||||
{{ .ClearMember }}
|
{{ range $.aiModels }}
|
||||||
</td>
|
<option value="{{.Model}}" {{ if eq $useModel .Model}}selected{{ end }}>
|
||||||
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500">
|
{{.Name}}
|
||||||
<button class="btn btn-link" onclick="getGroupUsers({{.Wxid}}, {{.Nickname}})">成员</button>
|
</option>
|
||||||
</td>
|
{{ end }}
|
||||||
</tr>
|
</select>
|
||||||
{{ end }}
|
</label>
|
||||||
</tbody>
|
</div>
|
||||||
</table>
|
<div class="float-end mt-1">
|
||||||
|
<label>
|
||||||
|
<select
|
||||||
|
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"
|
||||||
|
onchange="aiAssistantChange(event, {{.Wxid}})">
|
||||||
|
<option value="" {{ if eq .Prompt
|
||||||
|
"" }}selected{{ end }}>默认</option>
|
||||||
|
|
||||||
|
{{$usePrompt := .Prompt}}
|
||||||
|
{{ range $.assistant }}
|
||||||
|
<option value="{{.Id}}" {{ if eq $usePrompt .Id}}selected{{ end }}>
|
||||||
|
{{.Name}}
|
||||||
|
</option>
|
||||||
|
{{ end }}
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{{ end }}
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
<!-- 水群排行榜 -->
|
||||||
|
<div class="flex justify-between gap-x-4 py-3 items-center">
|
||||||
|
<dt class="text-gray-500">水群排行榜</dt>
|
||||||
|
<dd class="flex items-start gap-x-2">
|
||||||
|
{{ template "chatRank" . }}
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
<!-- 群聊总结 -->
|
||||||
|
<div class="flex justify-between gap-x-4 py-3 items-center">
|
||||||
|
<dt class="text-gray-500">群聊总结</dt>
|
||||||
|
<dd class="flex items-start gap-x-2">
|
||||||
|
{{ template "summary" . }}
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
<!-- 迎新 -->
|
||||||
|
<div class="flex justify-between gap-x-4 py-3 items-center">
|
||||||
|
<dt class="text-gray-500">迎新</dt>
|
||||||
|
<dd class="flex items-start gap-x-2">
|
||||||
|
{{ template "welcome" . }}
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
<!-- 早报 -->
|
||||||
|
<div class="flex justify-between gap-x-4 py-3 items-center">
|
||||||
|
<dt class="text-gray-500">早报</dt>
|
||||||
|
<dd class="flex items-start gap-x-2">
|
||||||
|
{{ template "news" . }}
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
<!-- 指令 -->
|
||||||
|
<div class="flex justify-between gap-x-4 py-3 items-center">
|
||||||
|
<dt class="text-gray-500">指令</dt>
|
||||||
|
<dd class="flex items-start gap-x-2">
|
||||||
|
{{ template "command" . }}
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
<!-- 自动清理不活跃成员 -->
|
||||||
|
<div class="flex justify-between gap-x-4 py-3 items-center">
|
||||||
|
<dt class="text-gray-500">末位淘汰</dt>
|
||||||
|
<dd class="flex items-start gap-x-2 items-center">
|
||||||
|
<div class="relative rounded-md">
|
||||||
|
<label>
|
||||||
|
<input type="number" id="auto-cm-{{ .Wxid }}" min="0" class="block w-1/2 float-end 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="N天不活跃自动移除"
|
||||||
|
value="{{.ClearMember}}"
|
||||||
|
onblur="changeClearMember({{.Wxid}}, {{.ClearMember}}, this.value)"
|
||||||
|
>
|
||||||
|
</label>
|
||||||
|
<div class="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-3">
|
||||||
|
<span class="text-gray-500 sm:text-sm" id="price-currency">天</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
</dl>
|
||||||
|
{{ end }}
|
||||||
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
|
|||||||
@@ -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="/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="/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="/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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
<main class="-mt-32">
|
<main class="-mt-32">
|
||||||
<div class="mx-auto max-w-7xl px-4 pb-12 sm:px-6 lg:px-8">
|
<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">
|
<div class="rounded-lg bg-white px-5 py-6 shadow sm:px-6 text-2xl">
|
||||||
|
<!-- 正文开始 -->
|
||||||
<dl class="mt-5 grid grid-cols-1 gap-5 sm:grid-cols-3">
|
<dl class="mt-5 grid grid-cols-1 gap-5 sm:grid-cols-3">
|
||||||
<div class="overflow-hidden rounded-lg bg-white px-4 py-5 shadow sm:p-6">
|
<div class="overflow-hidden rounded-lg bg-white px-4 py-5 shadow sm:p-6">
|
||||||
<dt class="truncate text-sm font-medium text-gray-500">好友数量</dt>
|
<dt class="truncate text-sm font-medium text-gray-500">好友数量</dt>
|
||||||
|
|||||||
@@ -1,4 +1,14 @@
|
|||||||
/* 隐藏滚动条 */
|
/* 隐藏滚动条 */
|
||||||
::-webkit-scrollbar {
|
::-webkit-scrollbar {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 隐藏input输入数字时的箭头 */
|
||||||
|
input[type=number]::-webkit-inner-spin-button,
|
||||||
|
input[type=number]::-webkit-outer-spin-button {
|
||||||
|
-webkit-appearance: none;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
input[type=number] {
|
||||||
|
-moz-appearance:textfield;
|
||||||
|
}
|
||||||
|
|||||||
@@ -213,3 +213,56 @@ function aiModelChange(event, wxid) {
|
|||||||
window.location.reload();
|
window.location.reload();
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AI角色变动
|
||||||
|
function aiAssistantChange(event, wxid) {
|
||||||
|
// 取出变动后的值
|
||||||
|
const assistantStr = event.target.value;
|
||||||
|
console.log("AI角色变动: ", wxid, assistantStr)
|
||||||
|
axios({
|
||||||
|
method: 'post',
|
||||||
|
url: '/api/ai/assistant',
|
||||||
|
data: {
|
||||||
|
wxid: wxid,
|
||||||
|
model: assistantStr
|
||||||
|
}
|
||||||
|
}).then(function (response) {
|
||||||
|
console.log(`返回结果: ${JSON.stringify(response)}`);
|
||||||
|
alert(`${response.data}`)
|
||||||
|
}).catch(function (error) {
|
||||||
|
console.log(`错误信息: ${error}`);
|
||||||
|
alert("修改失败")
|
||||||
|
}).finally(function () {
|
||||||
|
window.location.reload();
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改清理群成员值
|
||||||
|
function changeClearMember(wxid, oldVal, newVal) {
|
||||||
|
oldVal = Number(oldVal)
|
||||||
|
newVal = Number(newVal)
|
||||||
|
|
||||||
|
if (oldVal === newVal) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (newVal < 0) {
|
||||||
|
alert('不活跃天数的值不能小于0')
|
||||||
|
}
|
||||||
|
// 请求接口
|
||||||
|
axios({
|
||||||
|
method: 'put',
|
||||||
|
url: '/api/clearmembers',
|
||||||
|
data: {
|
||||||
|
wxid: wxid,
|
||||||
|
days: Number(newVal)
|
||||||
|
}
|
||||||
|
}).then(function (response) {
|
||||||
|
console.log(`返回结果: ${JSON.stringify(response)}`);
|
||||||
|
alert(`${response.data}`)
|
||||||
|
}).catch(function (error) {
|
||||||
|
console.log(`错误信息: ${error}`);
|
||||||
|
alert("修改失败")
|
||||||
|
}).finally(function () {
|
||||||
|
window.location.reload();
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user