Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
55d219b364 | |||
a4234532cd | |||
3275a64852 | |||
21505702e6 | |||
45db832dad | |||
b806ade655 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -8,3 +8,4 @@ log
|
||||
dist
|
||||
*.log
|
||||
blacklist.txt
|
||||
frontend.*
|
||||
|
@ -2,6 +2,9 @@ package app
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"go-wechat/common/response"
|
||||
"go-wechat/config"
|
||||
"go-wechat/service"
|
||||
)
|
||||
|
||||
// SaveAssistant
|
||||
@ -12,3 +15,22 @@ 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 (
|
||||
"github.com/gin-gonic/gin"
|
||||
"go-wechat/client"
|
||||
"go-wechat/entity"
|
||||
"go-wechat/model/entity"
|
||||
"gorm.io/gorm"
|
||||
"log"
|
||||
"net/http"
|
||||
|
@ -1,7 +1,7 @@
|
||||
package current
|
||||
|
||||
import (
|
||||
"go-wechat/model"
|
||||
"go-wechat/model/model"
|
||||
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配置
|
||||
wechat:
|
||||
# 微信HOOK接口地址
|
||||
host: 10.0.0.73:19088
|
||||
host: 10.0.0.79:19088
|
||||
# 微信容器映射出来的vnc页面地址,没有就不填
|
||||
# vncUrl: http://192.168.1.175:19087/vnc_lite.html
|
||||
# 是否在启动的时候自动设置hook服务的回调
|
||||
|
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 (
|
||||
"go-wechat/common/current"
|
||||
"go-wechat/model"
|
||||
"go-wechat/model/model"
|
||||
plugin "go-wechat/plugin"
|
||||
"go-wechat/plugin/plugins"
|
||||
"go-wechat/service"
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"github.com/go-resty/resty/v2"
|
||||
"go-wechat/common/current"
|
||||
"go-wechat/config"
|
||||
"go-wechat/model"
|
||||
model2 "go-wechat/model/model"
|
||||
"log"
|
||||
)
|
||||
|
||||
@ -12,7 +12,7 @@ import (
|
||||
// @description: 初始化微信机器人信息
|
||||
func InitWechatRobotInfo() {
|
||||
// 获取数据
|
||||
var base model.Response[model.RobotUserInfo]
|
||||
var base model2.Response[model2.RobotUserInfo]
|
||||
_, err := resty.New().R().
|
||||
SetHeader("Content-Type", "application/json;chartset=utf-8").
|
||||
SetResult(&base).
|
||||
|
@ -163,3 +163,15 @@ func (m Message) CleanContentStartWith(prefix string) bool {
|
||||
|
||||
return strings.HasPrefix(content, prefix)
|
||||
}
|
||||
|
||||
// IsInvitationJoinGroup
|
||||
// @description: 是否是邀请入群消息
|
||||
// @receiver m
|
||||
// @return bool
|
||||
func (m Message) IsInvitationJoinGroup() bool {
|
||||
if m.Type == types.MsgTypeApp {
|
||||
// 解析xml
|
||||
|
||||
}
|
||||
return false
|
||||
}
|
@ -3,7 +3,7 @@ package mq
|
||||
import (
|
||||
"encoding/json"
|
||||
"go-wechat/common/current"
|
||||
"go-wechat/model"
|
||||
"go-wechat/model/model"
|
||||
"go-wechat/types"
|
||||
"log"
|
||||
"strings"
|
||||
|
@ -1,7 +1,7 @@
|
||||
package plugin
|
||||
|
||||
import (
|
||||
"go-wechat/model"
|
||||
"go-wechat/model/model"
|
||||
)
|
||||
|
||||
// MessageHandler 消息处理函数
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
"go-wechat/client"
|
||||
"go-wechat/common/current"
|
||||
"go-wechat/config"
|
||||
"go-wechat/entity"
|
||||
"go-wechat/model/entity"
|
||||
"go-wechat/plugin"
|
||||
"go-wechat/service"
|
||||
"go-wechat/types"
|
||||
|
@ -3,7 +3,7 @@ package command
|
||||
import (
|
||||
"fmt"
|
||||
"go-wechat/client"
|
||||
"go-wechat/entity"
|
||||
"go-wechat/model/entity"
|
||||
"go-wechat/utils"
|
||||
"log"
|
||||
"strings"
|
||||
|
@ -5,10 +5,10 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"go-wechat/client"
|
||||
"go-wechat/entity"
|
||||
"go-wechat/model"
|
||||
"go-wechat/model/entity"
|
||||
"go-wechat/model/model"
|
||||
"go-wechat/model/vo"
|
||||
"go-wechat/utils"
|
||||
"go-wechat/vo"
|
||||
"gorm.io/gorm"
|
||||
"log"
|
||||
"strings"
|
||||
|
@ -1,7 +1,7 @@
|
||||
package plugins
|
||||
|
||||
import (
|
||||
"go-wechat/entity"
|
||||
"go-wechat/model/entity"
|
||||
"go-wechat/plugin"
|
||||
"go-wechat/service"
|
||||
"time"
|
||||
|
@ -3,7 +3,7 @@ package plugins
|
||||
import (
|
||||
"go-wechat/client"
|
||||
"go-wechat/config"
|
||||
"go-wechat/entity"
|
||||
"go-wechat/model/entity"
|
||||
"go-wechat/plugin"
|
||||
"go-wechat/utils"
|
||||
)
|
||||
|
@ -9,31 +9,49 @@ 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/model", 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) // 自动清理群成员
|
||||
|
||||
api.POST("/assistant", app.SaveAssistant) // 保存AI助手
|
||||
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模型列表
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package service
|
||||
|
||||
import (
|
||||
"go-wechat/client"
|
||||
"go-wechat/entity"
|
||||
"go-wechat/model/entity"
|
||||
)
|
||||
|
||||
// GetAllAiAssistant
|
||||
|
@ -2,8 +2,8 @@ package service
|
||||
|
||||
import (
|
||||
"go-wechat/client"
|
||||
"go-wechat/entity"
|
||||
"go-wechat/vo"
|
||||
"go-wechat/model/entity"
|
||||
"go-wechat/model/vo"
|
||||
"log"
|
||||
"strings"
|
||||
)
|
||||
|
@ -2,7 +2,7 @@ package service
|
||||
|
||||
import (
|
||||
"go-wechat/client"
|
||||
"go-wechat/vo"
|
||||
"go-wechat/model/vo"
|
||||
)
|
||||
|
||||
// GetGroupUsersByGroupId
|
||||
|
@ -2,8 +2,8 @@ package service
|
||||
|
||||
import (
|
||||
"go-wechat/client"
|
||||
"go-wechat/entity"
|
||||
"go-wechat/vo"
|
||||
"go-wechat/model/entity"
|
||||
"go-wechat/model/vo"
|
||||
"log"
|
||||
"os"
|
||||
"strconv"
|
||||
|
@ -3,7 +3,7 @@ package cleargroupuser
|
||||
import (
|
||||
"fmt"
|
||||
"go-wechat/client"
|
||||
"go-wechat/entity"
|
||||
"go-wechat/model/entity"
|
||||
"go-wechat/service"
|
||||
"go-wechat/utils"
|
||||
"log"
|
||||
|
@ -6,8 +6,8 @@ import (
|
||||
"go-wechat/client"
|
||||
"go-wechat/common/constant"
|
||||
"go-wechat/config"
|
||||
"go-wechat/entity"
|
||||
"go-wechat/model"
|
||||
"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 model.Response[[]model.FriendItem]
|
||||
var base model2.Response[[]model2.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 model.Response[model.GroupUser]
|
||||
var baseResp model2.Response[model2.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 model.ContactProfile, err error) {
|
||||
var baseResp model.Response[model.ContactProfile]
|
||||
func getContactProfile(wxid string) (ent model2.ContactProfile, err error) {
|
||||
var baseResp model2.Response[model2.ContactProfile]
|
||||
|
||||
// 组装参数
|
||||
param := map[string]any{
|
||||
|
@ -5,9 +5,9 @@ import (
|
||||
"fmt"
|
||||
"github.com/sashabaranov/go-openai"
|
||||
"go-wechat/config"
|
||||
"go-wechat/model/vo"
|
||||
"go-wechat/service"
|
||||
"go-wechat/utils"
|
||||
"go-wechat/vo"
|
||||
"log"
|
||||
"strings"
|
||||
)
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"fmt"
|
||||
"go-wechat/client"
|
||||
"go-wechat/config"
|
||||
"go-wechat/entity"
|
||||
"go-wechat/model/entity"
|
||||
"go-wechat/service"
|
||||
"go-wechat/utils"
|
||||
"log"
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"fmt"
|
||||
"go-wechat/client"
|
||||
"go-wechat/config"
|
||||
"go-wechat/entity"
|
||||
"go-wechat/model/entity"
|
||||
"go-wechat/service"
|
||||
"go-wechat/utils"
|
||||
"log"
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"fmt"
|
||||
"go-wechat/client"
|
||||
"go-wechat/config"
|
||||
"go-wechat/entity"
|
||||
"go-wechat/model/entity"
|
||||
"go-wechat/service"
|
||||
"go-wechat/utils"
|
||||
"log"
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"fmt"
|
||||
"go-wechat/client"
|
||||
"go-wechat/config"
|
||||
"go-wechat/entity"
|
||||
"go-wechat/model/entity"
|
||||
"go-wechat/service"
|
||||
"go-wechat/utils"
|
||||
"log"
|
||||
|
@ -3,7 +3,7 @@ package tcpserver
|
||||
import (
|
||||
"encoding/json"
|
||||
"go-wechat/common/current"
|
||||
"go-wechat/model"
|
||||
"go-wechat/model/model"
|
||||
"go-wechat/types"
|
||||
"log"
|
||||
"net"
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/go-resty/resty/v2"
|
||||
"go-wechat/model"
|
||||
model2 "go-wechat/model/model"
|
||||
"log"
|
||||
)
|
||||
|
||||
@ -14,7 +14,7 @@ import (
|
||||
// @description: 雷神加速器相关接口
|
||||
type LeiGod interface {
|
||||
Login() error // 登录
|
||||
Info() (model.LeiGodUserInfoResp, error) // 获取用户信息
|
||||
Info() (model2.LeiGodUserInfoResp, error) // 获取用户信息
|
||||
Pause() error // 暂停加速
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ func (l *leiGod) Login() (err error) {
|
||||
}
|
||||
pbs, _ := json.Marshal(param)
|
||||
|
||||
var loginResp model.Response[any]
|
||||
var loginResp model2.Response[any]
|
||||
var resp *resty.Response
|
||||
|
||||
res := resty.New()
|
||||
@ -84,7 +84,7 @@ func (l *leiGod) Login() (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
var loginInfo model.LeiGodLoginResp
|
||||
var loginInfo model2.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 model.LeiGodUserInfoResp, err error) {
|
||||
func (l *leiGod) Info() (ui model2.LeiGodUserInfoResp, err error) {
|
||||
// 组装参数
|
||||
param := map[string]any{
|
||||
"account_token": l.token,
|
||||
@ -109,7 +109,7 @@ func (l *leiGod) Info() (ui model.LeiGodUserInfoResp, err error) {
|
||||
}
|
||||
pbs, _ := json.Marshal(param)
|
||||
|
||||
var userInfoResp model.Response[model.LeiGodUserInfoResp]
|
||||
var userInfoResp model2.Response[model2.LeiGodUserInfoResp]
|
||||
var resp *resty.Response
|
||||
|
||||
res := resty.New()
|
||||
@ -145,7 +145,7 @@ func (l *leiGod) Pause() (err error) {
|
||||
}
|
||||
pbs, _ := json.Marshal(param)
|
||||
|
||||
var pauseResp model.Response[any]
|
||||
var pauseResp model2.Response[any]
|
||||
var resp *resty.Response
|
||||
|
||||
res := resty.New()
|
||||
|
@ -2,7 +2,7 @@ package utils
|
||||
|
||||
import (
|
||||
"github.com/go-resty/resty/v2"
|
||||
"go-wechat/model"
|
||||
"go-wechat/model/model"
|
||||
"log"
|
||||
)
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
<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">
|
||||
|
@ -21,6 +21,7 @@
|
||||
<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>
|
||||
|
Loading…
Reference in New Issue
Block a user