Compare commits
46 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f8f2d384f4 | ||
|
|
28f08085ee | ||
|
|
d802cbd6ca | ||
|
|
5b187ff026 | ||
|
|
e1c2eb78aa | ||
|
|
3bc33f1d64 | ||
|
|
bc5adf26d9 | ||
|
|
23ca86e75c | ||
|
|
1d41fc5a6b | ||
|
|
bcdf0a45d2 | ||
|
|
4d3bef7cf5 | ||
|
|
205e34f67e | ||
|
|
9b5152e294 | ||
|
|
c0f8169588 | ||
|
|
2e5632c203 | ||
|
|
d3ec63ff6c | ||
|
|
f747bf5ead | ||
|
|
9e8c3f5e6f | ||
|
|
d07b3b9456 | ||
|
|
f396a7f674 | ||
|
|
42ac0a5ae0 | ||
|
|
a905c3ca99 | ||
|
|
c881a1c395 | ||
|
|
df05070e0b | ||
|
|
703e183424 | ||
|
|
5afe50975b | ||
|
|
83458e649a | ||
|
|
28f111c812 | ||
|
|
0adc2ff628 | ||
|
|
4c08c5caeb | ||
|
|
de278f25e9 | ||
|
|
4fcf1779de | ||
|
|
f946044f13 | ||
|
|
44b8e4a162 | ||
|
|
0452d951a7 | ||
|
|
d8a8bf4efc | ||
|
|
8f6b7cb68d | ||
|
|
72a2e694f8 | ||
|
|
a13e39dc0a | ||
|
|
74f19e9d03 | ||
|
|
3554c95edc | ||
|
|
db8c460b42 | ||
|
|
7747a4b634 | ||
|
|
2226ec7e63 | ||
|
|
b0be537c5d | ||
|
|
9670c0b2fe |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -7,5 +7,4 @@ cache
|
||||
log
|
||||
dist
|
||||
*.log
|
||||
blacklist.txt
|
||||
frontend.*
|
||||
blacklist.txt
|
||||
@@ -2,9 +2,6 @@ package app
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"go-wechat/common/response"
|
||||
"go-wechat/config"
|
||||
"go-wechat/service"
|
||||
)
|
||||
|
||||
// SaveAssistant
|
||||
@@ -15,22 +12,3 @@ 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()
|
||||
}
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
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()
|
||||
}
|
||||
@@ -19,8 +19,8 @@ type changeStatusParam struct {
|
||||
// changeUseAiModelParam
|
||||
// @description: 修改使用的AI模型用的参数集
|
||||
type changeUseAiModelParam struct {
|
||||
WxId string `json:"wxid" binding:"required"` // 群Id或微信Id
|
||||
Model string `json:"model" binding:"required"` // 模型代码
|
||||
WxId string `json:"wxid" binding:"required"` // 群Id或微信Id
|
||||
Model string `json:"dto"` // 模型代码
|
||||
}
|
||||
|
||||
// autoClearMembers
|
||||
|
||||
15
app/group.go
15
app/group.go
@@ -25,6 +25,19 @@ func GetGroupUsers(ctx *gin.Context) {
|
||||
ctx.String(http.StatusInternalServerError, "查询失败: %s", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
result := map[string]any{
|
||||
"records": records,
|
||||
}
|
||||
// 循环数据,统计健在成员
|
||||
var isOkCount int
|
||||
for _, record := range records {
|
||||
if record.IsMember {
|
||||
isOkCount++
|
||||
}
|
||||
}
|
||||
result["isOkCount"] = isOkCount
|
||||
|
||||
// 暂时先就这样写着,跑通了再改
|
||||
ctx.JSON(http.StatusOK, records)
|
||||
ctx.JSON(http.StatusOK, result)
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package current
|
||||
|
||||
import (
|
||||
"go-wechat/model/model"
|
||||
plugin "go-wechat/plugin"
|
||||
"go-wechat/model/dto"
|
||||
"go-wechat/plugin"
|
||||
)
|
||||
|
||||
// robotInfo
|
||||
// @description: 机器人信息
|
||||
type robotInfo struct {
|
||||
info model.RobotUserInfo
|
||||
info dto.RobotUserInfo
|
||||
MessageHandler plugin.MessageHandler // 启用的插件
|
||||
}
|
||||
|
||||
@@ -18,14 +18,14 @@ var ri robotInfo
|
||||
// SetRobotInfo
|
||||
// @description: 设置机器人信息
|
||||
// @param info
|
||||
func SetRobotInfo(info model.RobotUserInfo) {
|
||||
func SetRobotInfo(info dto.RobotUserInfo) {
|
||||
ri.info = info
|
||||
}
|
||||
|
||||
// GetRobotInfo
|
||||
// @description: 获取机器人信息
|
||||
// @return model.RobotUserInfo
|
||||
func GetRobotInfo() model.RobotUserInfo {
|
||||
// @return dto.RobotUserInfo
|
||||
func GetRobotInfo() dto.RobotUserInfo {
|
||||
return ri.info
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
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()
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
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
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
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
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
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)
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
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()
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
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, ";"))
|
||||
}
|
||||
@@ -1,4 +1,7 @@
|
||||
system:
|
||||
# 每日新闻接口 Token
|
||||
# 获取地址: https://admin.alapi.cn/api_manager/token_manager
|
||||
alApiToken: xxx
|
||||
# 添加新好友或群之后通知给指定的人
|
||||
newFriendNotify:
|
||||
enable: true
|
||||
@@ -20,7 +23,7 @@ system:
|
||||
# 微信HOOK配置
|
||||
wechat:
|
||||
# 微信HOOK接口地址
|
||||
host: 10.0.0.79:19088
|
||||
host: 10.0.0.73:19088
|
||||
# 微信容器映射出来的vnc页面地址,没有就不填
|
||||
# vncUrl: http://192.168.1.175:19087/vnc_lite.html
|
||||
# 是否在启动的时候自动设置hook服务的回调
|
||||
|
||||
@@ -4,7 +4,7 @@ package config
|
||||
// @description: AI配置
|
||||
type ai struct {
|
||||
Enable bool `json:"enable" yaml:"enable"` // 是否启用AI
|
||||
Model string `json:"model" yaml:"model"` // 模型
|
||||
Model string `json:"dto" yaml:"dto"` // 模型
|
||||
SummaryModel string `json:"summaryModel" yaml:"summaryModel"` // 总结模型
|
||||
ApiKey string `json:"apiKey" yaml:"apiKey"` // API Key
|
||||
BaseUrl string `json:"baseUrl" yaml:"baseUrl"` // API地址
|
||||
@@ -15,6 +15,6 @@ type ai struct {
|
||||
// aiModel
|
||||
// @description: AI模型
|
||||
type aiModel struct {
|
||||
Name string `json:"name" yaml:"name"` // 模型名称
|
||||
Model string `json:"model" yaml:"model"` // 模型代码
|
||||
Name string `json:"name" yaml:"name"` // 模型名称
|
||||
Model string `json:"dto" yaml:"dto"` // 模型代码
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package config
|
||||
|
||||
// 系统配置
|
||||
type system struct {
|
||||
AlApiToken string `json:"alApiToken" yaml:"alApiToken"` // AL API Token
|
||||
NewFriendNotify newFriendNotify `json:"newFriendNotify" yaml:"newFriendNotify"` // 新好友通知
|
||||
DefaultRule defaultRule `json:"defaultRule" yaml:"defaultRule"` // 默认规则
|
||||
}
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
/* 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
30
frontend/.gitignore
vendored
@@ -1,30 +0,0 @@
|
||||
# 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
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/prettierrc",
|
||||
"semi": false,
|
||||
"tabWidth": 2,
|
||||
"singleQuote": true,
|
||||
"printWidth": 100,
|
||||
"trailingComma": "none"
|
||||
}
|
||||
7
frontend/.vscode/extensions.json
vendored
7
frontend/.vscode/extensions.json
vendored
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"recommendations": [
|
||||
"Vue.volar",
|
||||
"dbaeumer.vscode-eslint",
|
||||
"esbenp.prettier-vscode"
|
||||
]
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
# 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
1
frontend/env.d.ts
vendored
@@ -1 +0,0 @@
|
||||
/// <reference types="vite/client" />
|
||||
@@ -1,13 +0,0 @@
|
||||
<!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
5312
frontend/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,46 +0,0 @@
|
||||
{
|
||||
"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"
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
export default {
|
||||
plugins: {
|
||||
tailwindcss: {},
|
||||
autoprefixer: {},
|
||||
},
|
||||
};
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 4.2 KiB |
@@ -1,10 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
import MainNav from '@/components/layout/MainNav.vue'
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<MainNav />
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
</style>
|
||||
@@ -1,6 +0,0 @@
|
||||
// 默认返回数据结构
|
||||
export type BaseResult<T> = {
|
||||
code: number;
|
||||
message: string;
|
||||
data?: T;
|
||||
};
|
||||
@@ -1,43 +0,0 @@
|
||||
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')
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 24 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 210 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 123 KiB |
@@ -1,3 +0,0 @@
|
||||
<template>
|
||||
|
||||
</template>
|
||||
@@ -1,73 +0,0 @@
|
||||
<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>
|
||||
@@ -1,15 +0,0 @@
|
||||
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')
|
||||
@@ -1,31 +0,0 @@
|
||||
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
|
||||
@@ -1,12 +0,0 @@
|
||||
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 }
|
||||
})
|
||||
@@ -1,136 +0,0 @@
|
||||
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
43
frontend/src/utils/http/types.d.ts
vendored
@@ -1,43 +0,0 @@
|
||||
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>;
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
|
||||
defineOptions({
|
||||
name: "AssistantPage"
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<main>
|
||||
<h1>AI角色</h1>
|
||||
</main>
|
||||
</template>
|
||||
@@ -1,25 +0,0 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
<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>
|
||||
@@ -1,12 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
|
||||
defineOptions({
|
||||
name: "GroupPage"
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<main>
|
||||
<h1>群组</h1>
|
||||
</main>
|
||||
</template>
|
||||
@@ -1,12 +0,0 @@
|
||||
<script setup lang="ts">
|
||||
|
||||
defineOptions({
|
||||
name: "IndexPage"
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<main>
|
||||
<h1 class="text-orange-700">首页</h1>
|
||||
</main>
|
||||
</template>
|
||||
@@ -1,12 +0,0 @@
|
||||
/** @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'),],
|
||||
}
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
{
|
||||
"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/*"]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
{
|
||||
"files": [],
|
||||
"references": [
|
||||
{
|
||||
"path": "./tsconfig.node.json"
|
||||
},
|
||||
{
|
||||
"path": "./tsconfig.app.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
{
|
||||
"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"]
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
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,10 +2,11 @@ package initialization
|
||||
|
||||
import (
|
||||
"go-wechat/common/current"
|
||||
"go-wechat/model/model"
|
||||
"go-wechat/model/dto"
|
||||
plugin "go-wechat/plugin"
|
||||
"go-wechat/plugin/plugins"
|
||||
"go-wechat/service"
|
||||
"go-wechat/types"
|
||||
)
|
||||
|
||||
// Plugin
|
||||
@@ -19,25 +20,39 @@ func Plugin() {
|
||||
// 注册插件
|
||||
|
||||
// 保存消息进数据库
|
||||
dispatcher.RegisterHandler(func(*model.Message) bool {
|
||||
dispatcher.RegisterHandler(func(*dto.Message) bool {
|
||||
return true
|
||||
}, plugins.SaveToDb)
|
||||
|
||||
// 通知邀请入群消息到配置用户
|
||||
dispatcher.RegisterHandler(func(m *dto.Message) bool {
|
||||
flag, _ := m.IsInvitationJoinGroup()
|
||||
return flag
|
||||
}, plugins.NotifyInvitationJoinGroup)
|
||||
// 被移除群聊通知到配置用户
|
||||
dispatcher.RegisterHandler(func(m *dto.Message) bool {
|
||||
return m.Type == types.MsgTypeSys
|
||||
}, plugins.NotifyRemoveFromChatroom)
|
||||
// 响应好友添加成功消息
|
||||
dispatcher.RegisterHandler(func(m *dto.Message) bool {
|
||||
return m.Type == types.MsgTypeSys
|
||||
}, plugins.ReplyNewFriend)
|
||||
|
||||
// 私聊指令消息
|
||||
dispatcher.RegisterHandler(func(m *model.Message) bool {
|
||||
dispatcher.RegisterHandler(func(m *dto.Message) bool {
|
||||
// 私聊消息 或 群聊艾特机器人并且以/开头的消息
|
||||
isGroupAt := m.IsAt() && !m.IsAtAll()
|
||||
return (m.IsPrivateText() || isGroupAt) && m.CleanContentStartWith("/") && service.CheckIsEnableCommand(m.FromUser)
|
||||
}, plugins.Command)
|
||||
|
||||
// AI消息插件
|
||||
dispatcher.RegisterHandler(func(m *model.Message) bool {
|
||||
dispatcher.RegisterHandler(func(m *dto.Message) bool {
|
||||
// 群内@或者私聊文字消息
|
||||
return (m.IsAt() && !m.IsAtAll()) || m.IsPrivateText()
|
||||
}, plugins.AI)
|
||||
|
||||
// 欢迎新成员
|
||||
dispatcher.RegisterHandler(func(m *model.Message) bool {
|
||||
dispatcher.RegisterHandler(func(m *dto.Message) bool {
|
||||
return m.IsNewUserJoin()
|
||||
}, plugins.WelcomeNew)
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"github.com/go-resty/resty/v2"
|
||||
"go-wechat/common/current"
|
||||
"go-wechat/config"
|
||||
model2 "go-wechat/model/model"
|
||||
"go-wechat/model/dto"
|
||||
"log"
|
||||
)
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
// @description: 初始化微信机器人信息
|
||||
func InitWechatRobotInfo() {
|
||||
// 获取数据
|
||||
var base model2.Response[model2.RobotUserInfo]
|
||||
var base dto.Response[dto.RobotUserInfo]
|
||||
_, err := resty.New().R().
|
||||
SetHeader("Content-Type", "application/json;chartset=utf-8").
|
||||
SetResult(&base).
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package model
|
||||
package dto
|
||||
|
||||
// FriendItem
|
||||
// @description: 好友列表数据
|
||||
@@ -1,4 +1,4 @@
|
||||
package model
|
||||
package dto
|
||||
|
||||
// LeiGodLoginResp
|
||||
// @description: 雷神登录返回
|
||||
@@ -1,4 +1,4 @@
|
||||
package model
|
||||
package dto
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
@@ -32,6 +32,39 @@ type systemMsgDataXml struct {
|
||||
Type string `xml:"type,attr"`
|
||||
}
|
||||
|
||||
// appMsgDataXml
|
||||
// @description: 微信app消息的xml结构
|
||||
type appMsgDataXml struct {
|
||||
XMLName xml.Name `xml:"msg"`
|
||||
Text string `xml:",chardata"`
|
||||
AppMsg struct {
|
||||
Text string `xml:",chardata"`
|
||||
Appid string `xml:"appid,attr"`
|
||||
SdkVer string `xml:"sdkver,attr"`
|
||||
Title string `xml:"title"`
|
||||
Des string `xml:"des"`
|
||||
Action string `xml:"action"`
|
||||
Type string `xml:"type"`
|
||||
ShowType string `xml:"showtype"`
|
||||
Content string `xml:"content"`
|
||||
URL string `xml:"url"`
|
||||
ThumbUrl string `xml:"thumburl"`
|
||||
LowUrl string `xml:"lowurl"`
|
||||
AppAttach struct {
|
||||
Text string `xml:",chardata"`
|
||||
TotalLen string `xml:"totallen"`
|
||||
AttachId string `xml:"attachid"`
|
||||
FileExt string `xml:"fileext"`
|
||||
} `xml:"appattach"`
|
||||
ExtInfo string `xml:"extinfo"`
|
||||
} `xml:"appmsg"`
|
||||
AppInfo struct {
|
||||
Text string `xml:",chardata"`
|
||||
Version string `xml:"version"`
|
||||
AppName string `xml:"appname"`
|
||||
} `xml:"appinfo"`
|
||||
}
|
||||
|
||||
// atMsgDataXml
|
||||
// @description: 微信@消息的xml结构
|
||||
type atMsgDataXml struct {
|
||||
@@ -167,11 +200,18 @@ func (m Message) CleanContentStartWith(prefix string) bool {
|
||||
// IsInvitationJoinGroup
|
||||
// @description: 是否是邀请入群消息
|
||||
// @receiver m
|
||||
// @return bool
|
||||
func (m Message) IsInvitationJoinGroup() bool {
|
||||
// @return bool 是否是邀请入群消息
|
||||
// @return string 邀请入群消息内容
|
||||
func (m Message) IsInvitationJoinGroup() (flag bool, str string) {
|
||||
if m.Type == types.MsgTypeApp {
|
||||
// 解析xml
|
||||
|
||||
var md appMsgDataXml
|
||||
if err := xml.Unmarshal([]byte(m.Content), &md); err != nil {
|
||||
return
|
||||
}
|
||||
flag = md.AppMsg.Type == "5" && md.AppMsg.Title == "邀请你加入群聊"
|
||||
str = strings.ReplaceAll(md.AppMsg.Des, ",进入可查看详情。", "")
|
||||
return
|
||||
}
|
||||
return false
|
||||
return
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package model
|
||||
package dto
|
||||
|
||||
// MorningPost
|
||||
// @description: 每日早报返回结构体
|
||||
@@ -1,4 +1,4 @@
|
||||
package model
|
||||
package dto
|
||||
|
||||
// Response
|
||||
// @description: 基础返回结构体
|
||||
@@ -1,4 +1,4 @@
|
||||
package model
|
||||
package dto
|
||||
|
||||
// RobotUserInfo
|
||||
// @description: 机器人用户信息
|
||||
@@ -14,7 +14,7 @@ type AiAssistant struct {
|
||||
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:'使用的模型'"`
|
||||
Model string `json:"dto" gorm:"type:varchar(50);not null;comment:'使用的模型'"`
|
||||
Enable bool `json:"enable" gorm:"type:tinyint(1);not null;default:1;comment:'是否启用'"`
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ type Friend struct {
|
||||
EnableNews bool `json:"enableNews" gorm:"type:tinyint(1) default 0 not null"` // 是否启用新闻
|
||||
ClearMember int `json:"clearMember"` // 清理成员配置(多少天未活跃的)
|
||||
IsOk bool `json:"isOk" gorm:"type:tinyint(1) default 0 not null"` // 是否正常
|
||||
UsedTokens int `json:"usedTokens"` // 已使用的AI Token数量
|
||||
}
|
||||
|
||||
func (Friend) TableName() string {
|
||||
|
||||
@@ -3,7 +3,7 @@ package mq
|
||||
import (
|
||||
"encoding/json"
|
||||
"go-wechat/common/current"
|
||||
"go-wechat/model/model"
|
||||
"go-wechat/model/dto"
|
||||
"go-wechat/types"
|
||||
"log"
|
||||
"strings"
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
// @description: 解析消息
|
||||
// @param msg
|
||||
func parse(msg []byte) {
|
||||
var m model.Message
|
||||
var m dto.Message
|
||||
if err := json.Unmarshal(msg, &m); err != nil {
|
||||
log.Printf("消息解析失败: %v", err)
|
||||
log.Printf("消息内容: %d -> %v", len(msg), string(msg))
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
package plugin
|
||||
|
||||
import (
|
||||
"go-wechat/model/model"
|
||||
"go-wechat/model/dto"
|
||||
)
|
||||
|
||||
// MessageHandler 消息处理函数
|
||||
type MessageHandler func(msg *model.Message)
|
||||
type MessageHandler func(msg *dto.Message)
|
||||
|
||||
// MessageDispatcher 消息分发处理接口
|
||||
// 跟 DispatchMessage 结合封装成 MessageHandler
|
||||
type MessageDispatcher interface {
|
||||
Dispatch(msg *model.Message)
|
||||
Dispatch(msg *dto.Message)
|
||||
}
|
||||
|
||||
// DispatchMessage 跟 MessageDispatcher 结合封装成 MessageHandler
|
||||
func DispatchMessage(dispatcher MessageDispatcher) func(msg *model.Message) {
|
||||
return func(msg *model.Message) { dispatcher.Dispatch(msg) }
|
||||
func DispatchMessage(dispatcher MessageDispatcher) func(msg *dto.Message) {
|
||||
return func(msg *dto.Message) { dispatcher.Dispatch(msg) }
|
||||
}
|
||||
|
||||
// MessageDispatcher impl
|
||||
@@ -30,7 +30,7 @@ type MessageContext struct {
|
||||
index int
|
||||
abortIndex int
|
||||
messageHandlers MessageContextHandlerGroup
|
||||
*model.Message
|
||||
*dto.Message
|
||||
}
|
||||
|
||||
// Next 主动调用下一个消息处理函数(或开始调用)
|
||||
@@ -65,11 +65,11 @@ func (c *MessageContext) AbortHandler() MessageContextHandler {
|
||||
}
|
||||
|
||||
// MatchFunc 消息匹配函数,返回为true则表示匹配
|
||||
type MatchFunc func(*model.Message) bool
|
||||
type MatchFunc func(*dto.Message) bool
|
||||
|
||||
// MatchFuncList 将多个MatchFunc封装成一个MatchFunc
|
||||
func MatchFuncList(matchFuncs ...MatchFunc) MatchFunc {
|
||||
return func(message *model.Message) bool {
|
||||
return func(message *dto.Message) bool {
|
||||
for _, matchFunc := range matchFuncs {
|
||||
if !matchFunc(message) {
|
||||
return false
|
||||
@@ -89,7 +89,7 @@ type matchNodes []*matchNode
|
||||
// MessageMatchDispatcher impl MessageDispatcher interface
|
||||
//
|
||||
// dispatcher := NewMessageMatchDispatcher()
|
||||
// dispatcher.OnText(func(msg *model.Message){
|
||||
// dispatcher.OnText(func(msg *dto.Message){
|
||||
// msg.ReplyText("hello")
|
||||
// })
|
||||
// bot := DefaultBot()
|
||||
@@ -113,7 +113,7 @@ func (m *MessageMatchDispatcher) SetAsync(async bool) {
|
||||
// 遍历 MessageMatchDispatcher 所有的消息处理函数
|
||||
// 获取所有匹配上的函数
|
||||
// 执行处理的消息处理方法
|
||||
func (m *MessageMatchDispatcher) Dispatch(msg *model.Message) {
|
||||
func (m *MessageMatchDispatcher) Dispatch(msg *dto.Message) {
|
||||
var group MessageContextHandlerGroup
|
||||
for _, node := range m.matchNodes {
|
||||
if node.matchFunc(msg) {
|
||||
|
||||
@@ -137,11 +137,14 @@ func AI(m *plugin.MessageContext) {
|
||||
}
|
||||
|
||||
// 返回消息为空
|
||||
if resp.Choices[0].Message.Content == "" {
|
||||
if len(resp.Choices) == 0 || resp.Choices[0].Message.Content == "" {
|
||||
utils.SendMessage(m.FromUser, m.GroupUser, "AI似乎抽风了,没有告诉我你需要的回答~", 0)
|
||||
return
|
||||
}
|
||||
|
||||
// 异步更新一下已使用的AI次数
|
||||
go service.UpdateUsedAiTokens(m.FromUser, resp.Usage.TotalTokens)
|
||||
|
||||
// 保存一下AI 返回的消息,消息 Id 使用传入 Id 的负数
|
||||
var replyMessage entity.Message
|
||||
replyMessage.MsgId = -m.MsgId
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"go-wechat/client"
|
||||
"go-wechat/model/dto"
|
||||
"go-wechat/model/entity"
|
||||
"go-wechat/model/model"
|
||||
"go-wechat/model/vo"
|
||||
"go-wechat/utils"
|
||||
"gorm.io/gorm"
|
||||
@@ -156,7 +156,7 @@ func (l leiGod) info() (replyMsg string) {
|
||||
if err = lgu.Login(); err != nil {
|
||||
return "登录失败: " + err.Error()
|
||||
}
|
||||
var ui model.LeiGodUserInfoResp
|
||||
var ui dto.LeiGodUserInfoResp
|
||||
if ui, err = lgu.Info(); err != nil {
|
||||
return "获取详情失败: " + err.Error()
|
||||
}
|
||||
|
||||
52
plugin/plugins/notify2configuser.go
Normal file
52
plugin/plugins/notify2configuser.go
Normal file
@@ -0,0 +1,52 @@
|
||||
package plugins
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go-wechat/config"
|
||||
"go-wechat/plugin"
|
||||
"go-wechat/service"
|
||||
"go-wechat/utils"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// NotifyInvitationJoinGroup
|
||||
// @description: 通知邀请入群消息到配置用户
|
||||
// @param m
|
||||
func NotifyInvitationJoinGroup(m *plugin.MessageContext) {
|
||||
// 先回复一条固定句子
|
||||
utils.SendMessage(m.FromUser, m.GroupUser, "您的邀请消息已收到啦,正在通知我的主人来同意请求。在我加群之后将会进行初始化操作,直到收到我主动发送的消息就是初始化完成咯,在那之前请耐心等待喔~", 0)
|
||||
|
||||
// 如果是邀请进群,推送到配置的用户
|
||||
if flag, dec := m.IsInvitationJoinGroup(); flag {
|
||||
for _, user := range config.Conf.System.NewFriendNotify.ToUser {
|
||||
if user != "" {
|
||||
// 发送一条新消息
|
||||
dec = fmt.Sprintf("#邀请入群提醒\n\n%s", dec)
|
||||
utils.SendMessage(user, "", dec, 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NotifyRemoveFromChatroom
|
||||
// @description: 被移除群聊通知到配置用户
|
||||
// @param m
|
||||
func NotifyRemoveFromChatroom(m *plugin.MessageContext) {
|
||||
// 如果是被移出群聊,推送到配置的用户
|
||||
if strings.HasPrefix(m.Content, "你被\"") && strings.HasSuffix(m.Content, "\"移出群聊") {
|
||||
// 取出群名称
|
||||
groupInfo, err := service.GetFriendInfoById(m.FromUser)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
// 组装消息
|
||||
msg := fmt.Sprintf("#移除群聊提醒\n\n群Id: %s\n群名称: %s\n事件: %s", m.FromUser, groupInfo.Nickname, m.Content)
|
||||
|
||||
for _, user := range config.Conf.System.NewFriendNotify.ToUser {
|
||||
if user != "" {
|
||||
// 发送一条新消息
|
||||
utils.SendMessage(user, "", msg, 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
18
plugin/plugins/systemmessgae.go
Normal file
18
plugin/plugins/systemmessgae.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package plugins
|
||||
|
||||
import (
|
||||
"go-wechat/plugin"
|
||||
"go-wechat/utils"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// ReplyNewFriend
|
||||
// @description: 响应好友添加成功消息
|
||||
// @param m
|
||||
func ReplyNewFriend(m *plugin.MessageContext) {
|
||||
isNewFriend := strings.HasPrefix(m.Content, "你已添加了") && strings.HasSuffix(m.Content, ",现在可以开始聊天了。")
|
||||
isNewChatroom := strings.Contains(m.Content, "\"邀请你加入了群聊,群聊参与人还有:")
|
||||
if isNewFriend || isNewChatroom {
|
||||
utils.SendMessage(m.FromUser, m.GroupUser, "AI正在初始化,请稍等几分钟,初始化完成之后我将主动告知您。", 0)
|
||||
}
|
||||
}
|
||||
@@ -9,49 +9,31 @@ import (
|
||||
// @description: 初始化路由
|
||||
// @param g
|
||||
func Init(g *gin.Engine) {
|
||||
//g.GET("/", func(ctx *gin.Context) {
|
||||
// // 重定向到index.html
|
||||
// ctx.Redirect(302, "/index.html")
|
||||
//})
|
||||
g.GET("/", func(ctx *gin.Context) {
|
||||
// 重定向到index.html
|
||||
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("/assistant.html", app.Assistant) // AI角色
|
||||
|
||||
//g.GET("/404.html", app.PageNotFound) // 群组列表
|
||||
g.GET("/404.html", app.PageNotFound) // 群组列表
|
||||
|
||||
// 接口
|
||||
api := g.Group("/api")
|
||||
api.PUT("/ai/status", app.ChangeEnableAiStatus) // 修改是否开启AI状态
|
||||
api.POST("/ai/dto", app.ChangeUseAiModel) // 修改使用的AI模型
|
||||
api.POST("/ai/assistant", app.ChangeUseAiAssistant) // 修改使用的AI助手
|
||||
api.PUT("/welcome/status", app.ChangeEnableWelcomeStatus) // 修改是否开启迎新状态
|
||||
api.PUT("/command/status", app.ChangeEnableCommandStatus) // 修改是否开启指令状态
|
||||
api.PUT("/news/status", app.ChangeEnableNewsStatus) // 修改是否开启早报状态
|
||||
api.PUT("/grouprank/status", app.ChangeEnableGroupRankStatus) // 修改是否开启水群排行榜状态
|
||||
api.PUT("/grouprank/skip", app.ChangeSkipGroupRankStatus) // 修改是否跳过水群排行榜状态
|
||||
api.GET("/group/users", app.GetGroupUsers) // 获取群成员列表
|
||||
api.PUT("/summary/status", app.ChangeEnableSummaryStatus) // 修改是否开启群聊总结状态
|
||||
api.PUT("/clearmembers", app.AutoClearMembers) // 自动清理群成员
|
||||
|
||||
contact := api.Group("/contact") // 通讯录
|
||||
{
|
||||
contact.GET("/friend", app.GetFriends) // 获取好友列表
|
||||
contact.GET("/group", app.GetGroups) // 获取群组列表
|
||||
profile := contact.Group("/profile") // 配置
|
||||
{
|
||||
profile.PUT("/ai/status", app.ChangeEnableAiStatus) // 修改是否开启AI状态
|
||||
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模型列表
|
||||
}
|
||||
api.POST("/assistant", app.SaveAssistant) // 保存AI助手
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"go-wechat/client"
|
||||
"go-wechat/model/entity"
|
||||
"go-wechat/model/vo"
|
||||
"gorm.io/gorm"
|
||||
"log"
|
||||
"strings"
|
||||
)
|
||||
@@ -36,6 +37,16 @@ func GetAllFriend() (friends, groups []vo.FriendItem, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// GetFriendInfoById
|
||||
// @description: 通过wxId获取好友信息
|
||||
// @param wxId
|
||||
// @return ent
|
||||
// @return err
|
||||
func GetFriendInfoById(wxId string) (ent entity.Friend, err error) {
|
||||
err = client.MySQL.Where("wxid = ?", wxId).First(&ent).Error
|
||||
return
|
||||
}
|
||||
|
||||
// GetAllEnableAI
|
||||
// @description: 取出所有启用了AI的好友或群组
|
||||
// @return []entity.Friend
|
||||
@@ -119,3 +130,16 @@ func updateLastActive(msg entity.Message) {
|
||||
log.Printf("更新群或者好友活跃时间失败, 错误信息: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// UpdateUsedAiTokens
|
||||
// @description: 更新已使用的AI次数
|
||||
// @param wxId 微信好友或者群聊Id
|
||||
// @param tokens 新增的tokens额度
|
||||
func UpdateUsedAiTokens(wxId string, tokens int) {
|
||||
err := client.MySQL.Model(&entity.Friend{}).
|
||||
Where("wxid = ?", wxId).
|
||||
Update("`used_tokens`", gorm.Expr(" `used_tokens` + ?", tokens)).Error
|
||||
if err != nil {
|
||||
log.Printf("更新AI使用次数失败, 错误信息: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ func ClearGroupUser() {
|
||||
memberMap[member.Nickname] = member.LastActive.Format("2006-01-02 15:04:05")
|
||||
}
|
||||
// 调用接口
|
||||
utils.DeleteGroupMember(group.Wxid, strings.Join(deleteIds, ","), 0)
|
||||
utils.DeleteGroupMember(group.Wxid, strings.Join(deleteIds, ","), 0, false)
|
||||
// 发送通知到群里
|
||||
ms := make([]string, 0)
|
||||
for k, v := range memberMap {
|
||||
|
||||
@@ -6,8 +6,8 @@ import (
|
||||
"go-wechat/client"
|
||||
"go-wechat/common/constant"
|
||||
"go-wechat/config"
|
||||
"go-wechat/model/dto"
|
||||
"go-wechat/model/entity"
|
||||
model2 "go-wechat/model/model"
|
||||
"go-wechat/utils"
|
||||
"gorm.io/gorm"
|
||||
"log"
|
||||
@@ -24,7 +24,7 @@ var hc = resty.New()
|
||||
// Sync
|
||||
// @description: 同步好友列表
|
||||
func Sync() {
|
||||
var base model2.Response[[]model2.FriendItem]
|
||||
var base dto.Response[[]dto.FriendItem]
|
||||
|
||||
resp, err := hc.R().
|
||||
SetHeader("Content-Type", "application/json;chartset=utf-8").
|
||||
@@ -155,7 +155,7 @@ func Sync() {
|
||||
// @description: 同步群成员
|
||||
// @param gid
|
||||
func syncGroupUsers(tx *gorm.DB, gid string) {
|
||||
var baseResp model2.Response[model2.GroupUser]
|
||||
var baseResp dto.Response[dto.GroupUser]
|
||||
|
||||
// 组装参数
|
||||
param := map[string]any{
|
||||
@@ -242,8 +242,8 @@ func syncGroupUsers(tx *gorm.DB, gid string) {
|
||||
// @param wxid
|
||||
// @return ent
|
||||
// @return err
|
||||
func getContactProfile(wxid string) (ent model2.ContactProfile, err error) {
|
||||
var baseResp model2.Response[model2.ContactProfile]
|
||||
func getContactProfile(wxid string) (ent dto.ContactProfile, err error) {
|
||||
var baseResp dto.Response[dto.ContactProfile]
|
||||
|
||||
// 组装参数
|
||||
param := map[string]any{
|
||||
|
||||
@@ -24,7 +24,7 @@ func DailyNews() {
|
||||
return
|
||||
}
|
||||
|
||||
newsStr := fmt.Sprintf("#每日早报\n\n又是新的一天了,让我们康康一觉醒来世界又发生了哪些变化~\n\n%s", strings.Join(news, "\n"))
|
||||
newsStr := fmt.Sprintf("#每日早报\n\n又是新的一天了,让我们康康一觉醒来世界又发生了哪些变化~\n\n%s", strings.Join(news, "\n \n"))
|
||||
|
||||
// 循环发送新闻
|
||||
for _, group := range groups {
|
||||
|
||||
@@ -3,7 +3,7 @@ package tcpserver
|
||||
import (
|
||||
"encoding/json"
|
||||
"go-wechat/common/current"
|
||||
"go-wechat/model/model"
|
||||
"go-wechat/model/dto"
|
||||
"go-wechat/types"
|
||||
"log"
|
||||
"net"
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
// @description: 解析消息
|
||||
// @param msg
|
||||
func parse(remoteAddr net.Addr, msg []byte) {
|
||||
var m model.Message
|
||||
var m dto.Message
|
||||
if err := json.Unmarshal(msg, &m); err != nil {
|
||||
log.Printf("[%s]消息解析失败: %v", remoteAddr, err)
|
||||
log.Printf("[%s]消息内容: %d -> %v", remoteAddr, len(msg), string(msg))
|
||||
|
||||
@@ -6,16 +6,16 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/go-resty/resty/v2"
|
||||
model2 "go-wechat/model/model"
|
||||
"go-wechat/model/dto"
|
||||
"log"
|
||||
)
|
||||
|
||||
// LeiGod
|
||||
// @description: 雷神加速器相关接口
|
||||
type LeiGod interface {
|
||||
Login() error // 登录
|
||||
Info() (model2.LeiGodUserInfoResp, error) // 获取用户信息
|
||||
Pause() error // 暂停加速
|
||||
Login() error // 登录
|
||||
Info() (dto.LeiGodUserInfoResp, error) // 获取用户信息
|
||||
Pause() error // 暂停加速
|
||||
}
|
||||
|
||||
type leiGod struct {
|
||||
@@ -59,7 +59,7 @@ func (l *leiGod) Login() (err error) {
|
||||
}
|
||||
pbs, _ := json.Marshal(param)
|
||||
|
||||
var loginResp model2.Response[any]
|
||||
var loginResp dto.Response[any]
|
||||
var resp *resty.Response
|
||||
|
||||
res := resty.New()
|
||||
@@ -84,7 +84,7 @@ func (l *leiGod) Login() (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
var loginInfo model2.LeiGodLoginResp
|
||||
var loginInfo dto.LeiGodLoginResp
|
||||
if err = json.Unmarshal(bs, &loginInfo); err != nil {
|
||||
return
|
||||
}
|
||||
@@ -100,7 +100,7 @@ func (l *leiGod) Login() (err error) {
|
||||
// @description: 获取用户信息
|
||||
// @receiver l
|
||||
// @return string
|
||||
func (l *leiGod) Info() (ui model2.LeiGodUserInfoResp, err error) {
|
||||
func (l *leiGod) Info() (ui dto.LeiGodUserInfoResp, err error) {
|
||||
// 组装参数
|
||||
param := map[string]any{
|
||||
"account_token": l.token,
|
||||
@@ -109,7 +109,7 @@ func (l *leiGod) Info() (ui model2.LeiGodUserInfoResp, err error) {
|
||||
}
|
||||
pbs, _ := json.Marshal(param)
|
||||
|
||||
var userInfoResp model2.Response[model2.LeiGodUserInfoResp]
|
||||
var userInfoResp dto.Response[dto.LeiGodUserInfoResp]
|
||||
var resp *resty.Response
|
||||
|
||||
res := resty.New()
|
||||
@@ -145,7 +145,7 @@ func (l *leiGod) Pause() (err error) {
|
||||
}
|
||||
pbs, _ := json.Marshal(param)
|
||||
|
||||
var pauseResp model2.Response[any]
|
||||
var pauseResp dto.Response[any]
|
||||
var resp *resty.Response
|
||||
|
||||
res := resty.New()
|
||||
|
||||
@@ -2,7 +2,8 @@ package utils
|
||||
|
||||
import (
|
||||
"github.com/go-resty/resty/v2"
|
||||
"go-wechat/model/model"
|
||||
"go-wechat/config"
|
||||
"go-wechat/model/dto"
|
||||
"log"
|
||||
)
|
||||
|
||||
@@ -28,12 +29,12 @@ func NewsUtil() News {
|
||||
// @receiver news
|
||||
// @return records
|
||||
func (news) MorningPost() (records []string) {
|
||||
var newsResp model.MorningPost
|
||||
var newsResp dto.MorningPost
|
||||
|
||||
res := resty.New()
|
||||
resp, err := res.R().
|
||||
SetHeader("Content-Type", "application/json;chartset=utf-8").
|
||||
SetQueryParam("token", "cFoMZNNBxT4jQovS").
|
||||
SetQueryParam("token", config.Conf.System.AlApiToken).
|
||||
SetResult(&newsResp).
|
||||
Post("https://v2.alapi.cn/api/zaobao")
|
||||
if err != nil {
|
||||
|
||||
@@ -126,7 +126,9 @@ func SendEmotion(toId, emotionHash string, retryCount int) {
|
||||
// @description: 删除群成员
|
||||
// @param chatRoomId 群Id
|
||||
// @param memberIds 成员id,用','分隔
|
||||
func DeleteGroupMember(chatRoomId, memberIds string, retryCount int) {
|
||||
// @param retryCount 重试次数
|
||||
// @param isSure 是否确认删除
|
||||
func DeleteGroupMember(chatRoomId, memberIds string, retryCount int, isSure bool) {
|
||||
if retryCount > 5 {
|
||||
log.Printf("重试五次失败,停止发送")
|
||||
return
|
||||
@@ -148,9 +150,11 @@ func DeleteGroupMember(chatRoomId, memberIds string, retryCount int) {
|
||||
log.Printf("删除群成员失败: %s", err.Error())
|
||||
// 休眠五秒后重新发送
|
||||
time.Sleep(5 * time.Second)
|
||||
DeleteGroupMember(chatRoomId, memberIds, retryCount+1)
|
||||
DeleteGroupMember(chatRoomId, memberIds, retryCount+1, isSure)
|
||||
}
|
||||
log.Printf("删除群成员结果: %s", resp.String())
|
||||
log.Printf("[%s]删除群成员结果: %s", chatRoomId, resp.String())
|
||||
// 这个逼接口要调用两次,第一次调用成功,第二次调用才会真正删除
|
||||
DeleteGroupMember(chatRoomId, memberIds, 5)
|
||||
if !isSure {
|
||||
DeleteGroupMember(chatRoomId, memberIds, 5, true)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
<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-3 xl:gap-x-8">
|
||||
{{ range .friends }}
|
||||
<li class="overflow-hidden rounded-xl border border-gray-200">
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
<dialog id="groupUserModal" class="modal">
|
||||
<div class="modal-box w-11/12 max-w-7xl">
|
||||
<h3 class="font-bold text-lg" id="groupUserModalName">我是群名称</h3>
|
||||
<div class="flex">
|
||||
<h3 class="font-bold text-lg" id="groupUserModalName">我是群名称</h3>
|
||||
<h3 class="font-bold text-lg ml-5" id="groupUserCount">(健在成员100人)</h3>
|
||||
</div>
|
||||
<div class="divider divider-warning">成员列表</div>
|
||||
<table class="table table-zebra">
|
||||
<thead>
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
<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">
|
||||
<!-- 正文开始 -->
|
||||
<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">
|
||||
<dt class="truncate text-sm font-medium text-gray-500">好友数量</dt>
|
||||
|
||||
@@ -2,82 +2,82 @@ console.log("打开首页")
|
||||
|
||||
// 改变AI开启状态
|
||||
function changeAiEnableStatus(wxId) {
|
||||
// console.log("修改AI开启状态: ", wxId)
|
||||
// console.log("修改AI开启状态: ", wxId)
|
||||
|
||||
axios({
|
||||
method: 'put',
|
||||
url: '/api/ai/status',
|
||||
data: {
|
||||
wxId: wxId
|
||||
}
|
||||
}).then(function (response) {
|
||||
console.log(`返回结果: ${JSON.stringify(response)}`);
|
||||
alert(`${response.data}`)
|
||||
}).catch(function (error) {
|
||||
console.log(`错误信息: ${error}`);
|
||||
alert("修改失败")
|
||||
}).finally(function () {
|
||||
window.location.reload();
|
||||
})
|
||||
axios({
|
||||
method: 'put',
|
||||
url: '/api/ai/status',
|
||||
data: {
|
||||
wxId: wxId
|
||||
}
|
||||
}).then(function (response) {
|
||||
console.log(`返回结果: ${JSON.stringify(response)}`);
|
||||
alert(`${response.data}`)
|
||||
}).catch(function (error) {
|
||||
console.log(`错误信息: ${error}`);
|
||||
alert("修改失败")
|
||||
}).finally(function () {
|
||||
window.location.reload();
|
||||
})
|
||||
}
|
||||
|
||||
// 修改水群排行榜状态
|
||||
function changeGroupRankEnableStatus(wxId) {
|
||||
// console.log("修改水群排行榜开启状态: ", wxId)
|
||||
axios({
|
||||
method: 'put',
|
||||
url: '/api/grouprank/status',
|
||||
data: {
|
||||
wxId: wxId
|
||||
}
|
||||
}).then(function (response) {
|
||||
console.log(`返回结果: ${JSON.stringify(response)}`);
|
||||
alert(`${response.data}`)
|
||||
}).catch(function (error) {
|
||||
console.log(`错误信息: ${error}`);
|
||||
alert("修改失败")
|
||||
}).finally(function () {
|
||||
window.location.reload();
|
||||
})
|
||||
// console.log("修改水群排行榜开启状态: ", wxId)
|
||||
axios({
|
||||
method: 'put',
|
||||
url: '/api/grouprank/status',
|
||||
data: {
|
||||
wxId: wxId
|
||||
}
|
||||
}).then(function (response) {
|
||||
console.log(`返回结果: ${JSON.stringify(response)}`);
|
||||
alert(`${response.data}`)
|
||||
}).catch(function (error) {
|
||||
console.log(`错误信息: ${error}`);
|
||||
alert("修改失败")
|
||||
}).finally(function () {
|
||||
window.location.reload();
|
||||
})
|
||||
}
|
||||
|
||||
// 修改水群排行榜状态
|
||||
function changeSummaryEnableStatus(wxId) {
|
||||
// console.log("修改聊天记录总结开启状态: ", wxId)
|
||||
axios({
|
||||
method: 'put',
|
||||
url: '/api/summary/status',
|
||||
data: {
|
||||
wxId: wxId
|
||||
}
|
||||
}).then(function (response) {
|
||||
console.log(`返回结果: ${JSON.stringify(response)}`);
|
||||
alert(`${response.data}`)
|
||||
}).catch(function (error) {
|
||||
console.log(`错误信息: ${error}`);
|
||||
alert("修改失败")
|
||||
}).finally(function () {
|
||||
window.location.reload();
|
||||
})
|
||||
// console.log("修改聊天记录总结开启状态: ", wxId)
|
||||
axios({
|
||||
method: 'put',
|
||||
url: '/api/summary/status',
|
||||
data: {
|
||||
wxId: wxId
|
||||
}
|
||||
}).then(function (response) {
|
||||
console.log(`返回结果: ${JSON.stringify(response)}`);
|
||||
alert(`${response.data}`)
|
||||
}).catch(function (error) {
|
||||
console.log(`错误信息: ${error}`);
|
||||
alert("修改失败")
|
||||
}).finally(function () {
|
||||
window.location.reload();
|
||||
})
|
||||
}
|
||||
|
||||
// 修改欢迎语开启状态
|
||||
function changeWelcomeEnableStatus(wxId) {
|
||||
axios({
|
||||
method: 'put',
|
||||
url: '/api/welcome/status',
|
||||
data: {
|
||||
wxId: wxId
|
||||
}
|
||||
}).then(function (response) {
|
||||
console.log(`返回结果: ${JSON.stringify(response)}`);
|
||||
alert(`${response.data}`)
|
||||
}).catch(function (error) {
|
||||
console.log(`错误信息: ${error}`);
|
||||
alert("修改失败")
|
||||
}).finally(function () {
|
||||
window.location.reload();
|
||||
})
|
||||
axios({
|
||||
method: 'put',
|
||||
url: '/api/welcome/status',
|
||||
data: {
|
||||
wxId: wxId
|
||||
}
|
||||
}).then(function (response) {
|
||||
console.log(`返回结果: ${JSON.stringify(response)}`);
|
||||
alert(`${response.data}`)
|
||||
}).catch(function (error) {
|
||||
console.log(`错误信息: ${error}`);
|
||||
alert("修改失败")
|
||||
}).finally(function () {
|
||||
window.location.reload();
|
||||
})
|
||||
}
|
||||
|
||||
// 修改用户新闻开启状态
|
||||
@@ -101,117 +101,123 @@ function changeUserNewsStatus(wxId) {
|
||||
|
||||
// 修改指令权限启用状态
|
||||
function changeCommandEnableStatus(wxId) {
|
||||
axios({
|
||||
method: 'put',
|
||||
url: '/api/command/status',
|
||||
data: {
|
||||
wxId: wxId
|
||||
}
|
||||
}).then(function (response) {
|
||||
console.log(`返回结果: ${JSON.stringify(response)}`);
|
||||
alert(`${response.data}`)
|
||||
}).catch(function (error) {
|
||||
console.log(`错误信息: ${error}`);
|
||||
alert("修改失败")
|
||||
}).finally(function () {
|
||||
window.location.reload();
|
||||
})
|
||||
axios({
|
||||
method: 'put',
|
||||
url: '/api/command/status',
|
||||
data: {
|
||||
wxId: wxId
|
||||
}
|
||||
}).then(function (response) {
|
||||
console.log(`返回结果: ${JSON.stringify(response)}`);
|
||||
alert(`${response.data}`)
|
||||
}).catch(function (error) {
|
||||
console.log(`错误信息: ${error}`);
|
||||
alert("修改失败")
|
||||
}).finally(function () {
|
||||
window.location.reload();
|
||||
})
|
||||
}
|
||||
|
||||
// 修改群成员是否参与排行榜状态
|
||||
function changeUserGroupRankSkipStatus(groupId, userId) {
|
||||
console.log("修改水群排行榜开启状态: ", groupId, userId)
|
||||
axios({
|
||||
method: 'put',
|
||||
url: '/api/grouprank/skip',
|
||||
data: {
|
||||
wxId: groupId,
|
||||
userId: userId
|
||||
}
|
||||
}).then(function (response) {
|
||||
console.log(`返回结果: ${JSON.stringify(response)}`);
|
||||
alert(`${response.data}`)
|
||||
}).catch(function (error) {
|
||||
console.log(`错误信息: ${error}`);
|
||||
alert("修改失败")
|
||||
}).finally(function () {
|
||||
window.location.reload();
|
||||
})
|
||||
console.log("修改水群排行榜开启状态: ", groupId, userId)
|
||||
axios({
|
||||
method: 'put',
|
||||
url: '/api/grouprank/skip',
|
||||
data: {
|
||||
wxId: groupId,
|
||||
userId: userId
|
||||
}
|
||||
}).then(function (response) {
|
||||
console.log(`返回结果: ${JSON.stringify(response)}`);
|
||||
alert(`${response.data}`)
|
||||
}).catch(function (error) {
|
||||
console.log(`错误信息: ${error}`);
|
||||
alert("修改失败")
|
||||
}).finally(function () {
|
||||
window.location.reload();
|
||||
})
|
||||
}
|
||||
|
||||
// 获取群成员列表
|
||||
function getGroupUsers(groupId, groupName) {
|
||||
// 获取表格的tbody部分,以便稍后向其中添加行
|
||||
var tbody = document.getElementById("groupUsers");
|
||||
tbody.innerHTML = ""
|
||||
// 获取表格的tbody部分,以便稍后向其中添加行
|
||||
var tbody = document.getElementById("groupUsers");
|
||||
tbody.innerHTML = ""
|
||||
|
||||
// 打开模态框
|
||||
const modal = document.getElementById("groupUserModal");
|
||||
modal.showModal()
|
||||
// 打开模态框
|
||||
const modal = document.getElementById("groupUserModal");
|
||||
modal.showModal()
|
||||
|
||||
// 设置群名称
|
||||
const groupNameTag = document.getElementById("groupUserModalName");
|
||||
groupNameTag.innerHTML = '<span class="loading loading-dots loading-lg"></span>'
|
||||
// 设置群名称
|
||||
const groupNameTag = document.getElementById("groupUserModalName");
|
||||
groupNameTag.innerHTML = '<span class="loading loading-dots loading-lg"></span>'
|
||||
|
||||
// 显示加载框
|
||||
// const loading = document.getElementById("groupUserDataLoading");
|
||||
// loading.style.display = "block"
|
||||
// 显示加载框
|
||||
// const loading = document.getElementById("groupUserDataLoading");
|
||||
// loading.style.display = "block"
|
||||
|
||||
axios.get('/api/group/users', {
|
||||
params: {
|
||||
groupId: groupId
|
||||
}
|
||||
}).then(function (response) {
|
||||
// console.log(`返回结果: ${JSON.stringify(response)}`);
|
||||
// 渲染群成员列表
|
||||
const groupUsers = response.data
|
||||
// 循环渲染数据
|
||||
groupUsers.forEach((groupUser, i) => {
|
||||
console.log(groupUser)
|
||||
const { wxid, nickname, isMember, isAdmin, joinTime, lastActive, leaveTime, skipChatRank } = groupUser;
|
||||
axios.get('/api/group/users', {
|
||||
params: {
|
||||
groupId: groupId
|
||||
}
|
||||
}).then(function (response) {
|
||||
// console.log(`返回结果: ${JSON.stringify(response.data)}`);
|
||||
// 渲染群成员列表
|
||||
const groupUsers = response.data.records;
|
||||
const groupUserCount = response.data.isOkCount;
|
||||
|
||||
let row = tbody.insertRow(i);
|
||||
// Insert data into cells
|
||||
row.insertCell(0).innerHTML = wxid;
|
||||
row.insertCell(1).innerHTML = nickname;
|
||||
row.insertCell(2).innerHTML = `<span class="inline-flex items-center rounded-md px-2 py-1 text-xs font-medium ring-1 ring-inset ${isMember ? 'bg-green-50 text-green-700 ring-green-600/20' : 'bg-red-50 text-red-700 ring-red-600/20'}">${isMember ? '是' : '否'}</span>`;
|
||||
row.insertCell(3).innerHTML = `<span class="inline-flex items-center rounded-md px-2 py-1 text-xs font-medium ring-1 ring-inset ${isAdmin ? 'bg-green-50 text-green-700 ring-green-600/20' : 'bg-red-50 text-red-700 ring-red-600/20'}">${isAdmin ? '是' : '否'}</span>`;
|
||||
row.insertCell(4).innerHTML = joinTime;
|
||||
row.insertCell(5).innerHTML = lastActive;
|
||||
row.insertCell(6).innerHTML = leaveTime;
|
||||
// row.insertCell(7).innerHTML = `<input type="checkbox" class="toggle toggle-error" ${skipChatRank ? 'checked' : ''} onclick="changeUserGroupRankSkipStatus('${groupId}', '${wxid}')" />`;
|
||||
row.insertCell(7).innerHTML = `<span class="inline-flex items-center rounded-md px-2 py-1 text-xs font-medium ring-1 ring-inset ${skipChatRank ? 'bg-green-50 text-green-700 ring-green-600/20' : 'bg-red-50 text-red-700 ring-red-600/20'}">${skipChatRank ? '是' : '否'}</span>`;
|
||||
});
|
||||
}).catch(function (error) {
|
||||
console.log(`错误信息: ${error}`);
|
||||
}).finally(function () {
|
||||
// 隐藏加载框
|
||||
// loading.style.display = "none"
|
||||
groupNameTag.innerHTML = groupName
|
||||
})
|
||||
// 设置成员总数
|
||||
const groupUserCountTag = document.getElementById("groupUserCount");
|
||||
groupUserCountTag.innerHTML = `健在成员: ${groupUserCount}人`
|
||||
|
||||
// 循环渲染数据
|
||||
groupUsers.forEach((groupUser, i) => {
|
||||
// console.log(groupUser)
|
||||
const {wxid, nickname, isMember, isAdmin, joinTime, lastActive, leaveTime, skipChatRank} = groupUser;
|
||||
|
||||
let row = tbody.insertRow(i);
|
||||
// Insert data into cells
|
||||
row.insertCell(0).innerHTML = wxid;
|
||||
row.insertCell(1).innerHTML = nickname;
|
||||
row.insertCell(2).innerHTML = `<span class="inline-flex items-center rounded-md px-2 py-1 text-xs font-medium ring-1 ring-inset ${isMember ? 'bg-green-50 text-green-700 ring-green-600/20' : 'bg-red-50 text-red-700 ring-red-600/20'}">${isMember ? '是' : '否'}</span>`;
|
||||
row.insertCell(3).innerHTML = `<span class="inline-flex items-center rounded-md px-2 py-1 text-xs font-medium ring-1 ring-inset ${isAdmin ? 'bg-green-50 text-green-700 ring-green-600/20' : 'bg-red-50 text-red-700 ring-red-600/20'}">${isAdmin ? '是' : '否'}</span>`;
|
||||
row.insertCell(4).innerHTML = joinTime;
|
||||
row.insertCell(5).innerHTML = lastActive;
|
||||
row.insertCell(6).innerHTML = leaveTime;
|
||||
// row.insertCell(7).innerHTML = `<input type="checkbox" class="toggle toggle-error" ${skipChatRank ? 'checked' : ''} onclick="changeUserGroupRankSkipStatus('${groupId}', '${wxid}')" />`;
|
||||
row.insertCell(7).innerHTML = `<span class="inline-flex items-center rounded-md px-2 py-1 text-xs font-medium ring-1 ring-inset ${skipChatRank ? 'bg-green-50 text-green-700 ring-green-600/20' : 'bg-red-50 text-red-700 ring-red-600/20'}">${skipChatRank ? '是' : '否'}</span>`;
|
||||
});
|
||||
}).catch(function (error) {
|
||||
console.log(`错误信息: ${error}`);
|
||||
}).finally(function () {
|
||||
// 隐藏加载框
|
||||
// loading.style.display = "none"
|
||||
groupNameTag.innerHTML = groupName
|
||||
})
|
||||
}
|
||||
|
||||
// AI模型变动
|
||||
function aiModelChange(event, wxid) {
|
||||
// 取出变动后的值
|
||||
const modelStr = event.target.value;
|
||||
console.log("AI模型变动: ", wxid, modelStr)
|
||||
axios({
|
||||
method: 'post',
|
||||
url: '/api/ai/model',
|
||||
data: {
|
||||
wxid: wxid,
|
||||
model: modelStr
|
||||
}
|
||||
}).then(function (response) {
|
||||
console.log(`返回结果: ${JSON.stringify(response)}`);
|
||||
alert(`${response.data}`)
|
||||
}).catch(function (error) {
|
||||
console.log(`错误信息: ${error}`);
|
||||
alert("修改失败")
|
||||
}).finally(function () {
|
||||
window.location.reload();
|
||||
})
|
||||
// 取出变动后的值
|
||||
const modelStr = event.target.value;
|
||||
console.log("AI模型变动: ", wxid, modelStr)
|
||||
axios({
|
||||
method: 'post',
|
||||
url: '/api/ai/model',
|
||||
data: {
|
||||
wxid: wxid,
|
||||
model: modelStr
|
||||
}
|
||||
}).then(function (response) {
|
||||
console.log(`返回结果: ${JSON.stringify(response)}`);
|
||||
alert(`${response.data}`)
|
||||
}).catch(function (error) {
|
||||
console.log(`错误信息: ${error}`);
|
||||
alert("修改失败")
|
||||
}).finally(function () {
|
||||
window.location.reload();
|
||||
})
|
||||
}
|
||||
|
||||
// AI角色变动
|
||||
|
||||
Reference in New Issue
Block a user