🆕 完善页面(未完成)

This commit is contained in:
李寻欢
2023-11-30 17:31:50 +08:00
parent 0430c2203e
commit 699f10e854
8 changed files with 379 additions and 83 deletions

View File

@@ -5,7 +5,11 @@
<title>水群助手</title>
<link href="https://cdn.jsdelivr.net/npm/daisyui@4.4.14/dist/full.min.css" rel="stylesheet" type="text/css" />
<link href="assets/css/index.css" rel="stylesheet" type="text/css" />
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/axios/1.5.0/axios.min.js"></script>
<script src="assets/js/index.js"></script>
</head>
@@ -19,92 +23,162 @@
</div>
{{ end }}
<div class="collapse collapse-arrow bg-base-200">
<input type="radio" name="my-accordion-2" checked="checked" />
<div class="collapse-title text-xl font-medium">
好友列表
</div>
<div class="collapse-content">
<div role="tablist" class="tabs tabs-bordered">
<input type="radio" name="friend_tab" role="tab" class="tab" aria-label="好友列表" />
<div role="tabpanel" class="tab-content p-6">
<!-- 循环好友列表 -->
<div class="overflow-x-auto">
<table class="table table-zebra">
<!-- head -->
<thead>
<tr>
<th>微信Id</th>
<th>微信号</th>
<th>昵称</th>
<th>最后活跃时间</th>
<th>是否在通讯录</th>
<th>是否启用AI</th>
<th>是否启用水群排行榜</th>
</tr>
</thead>
<tbody>
{{ range .friends }}
<tr>
<td>{{ .Wxid }}</td>
<td>{{ .CustomAccount }}</td>
<td>{{ .Nickname }}</td>
<td>
{{ if eq .LastActiveTime.IsNil true }}
无数据
{{ else }}
{{ .LastActiveTime }}
{{ end }}
</td>
<td>{{ .IsOk }}</td>
<td>{{ .EnableAi }}</td>
<td>{{ .EnableChatRank }}</td>
</tr>
{{ end }}
</tbody>
</table>
</div>
<table class="table table-zebra">
<!-- head -->
<thead>
<tr>
<th>微信Id</th>
<th>微信</th>
<th>昵称</th>
<th>最后活跃时间</th>
<th>是否在通讯录</th>
<th>是否启用AI</th>
</tr>
</thead>
<tbody>
{{ range .friends }}
<tr>
<td>{{ .Wxid }}</td>
<td>{{ .CustomAccount }}</td>
<td>{{ .Nickname }}</td>
<td>
{{ if eq .LastActiveTime.IsNil true }}
无数据
{{ else }}
{{ .LastActiveTime }}
{{ end }}
</td>
<td>
{{ if eq .IsOk true }}
<div class="badge badge-info gap-2">
</div>
{{ else }}
<div class="badge badge-error gap-2">
</div>
{{ end }}
</td>
<td>
<label class="swap swap-flip {{ checkSwap .EnableAi }}">
<input type="checkbox" onclick="changeAiEnableStatus({{.Wxid}})"/>
<div class="swap-on">✔️已启用</div>
<div class="swap-off">❌已禁用</div>
</label>
</td>
</tr>
{{ end }}
</tbody>
</table>
</div>
</div>
<div class="collapse collapse-arrow bg-base-200">
<input type="radio" name="my-accordion-2" />
<div class="collapse-title text-xl font-medium">
群列表
</div>
<div class="collapse-content">
<input type="radio" name="friend_tab" role="tab" class="tab" aria-label="群列表" checked/>
<div role="tabpanel" class="tab-content p-6">
<!-- 循环群列表 -->
<div class="overflow-x-auto">
<table class="table table-zebra">
<!-- head -->
<thead>
<tr>
<th>群Id</th>
<th>昵称</th>
<th>最后活跃时间</th>
<th>是否在通讯录</th>
<th>是否启用AI</th>
<th>是否启用水群排行榜</th>
</tr>
</thead>
<tbody>
{{ range .groups }}
<tr>
<td>{{ .Wxid }}</td>
<td>{{ .Nickname }}</td>
<td>
{{ if eq .LastActiveTime.IsNil true }}
无数据
{{ else }}
{{ .LastActiveTime }}
{{ end }}
</td>
<td>{{ .IsOk }}</td>
<td>{{ .EnableAi }}</td>
<td>{{ .EnableChatRank }}</td>
</tr>
{{ end }}
</tbody>
</table>
</div>
<table class="table table-zebra">
<!-- head -->
<thead>
<tr>
<th>群Id</th>
<th>昵称</th>
<th>最后活跃时间</th>
<th>是否在通讯录</th>
<th>是否启用AI</th>
<th>是否启用水群排行榜</th>
<th>操作</th>
</tr>
</thead>
<tbody>
{{ range .groups }}
<tr>
<td>{{ .Wxid }}</td>
<td>{{ .Nickname }}</td>
<td>
{{ if eq .LastActiveTime.IsNil true }}
无数据
{{ else }}
{{ .LastActiveTime }}
{{ end }}
</td>
<td>
{{ if eq .IsOk true }}
<div class="badge badge-info gap-2">
</div>
{{ else }}
<div class="badge badge-error gap-2">
</div>
{{ end }}
</td>
<td>
<!-- EnableAi -->
<label class="swap swap-flip {{ checkSwap .EnableAi }}">
<input type="checkbox" onclick="changeAiEnableStatus({{.Wxid}})"/>
<div class="swap-on">✔️已启用</div>
<div class="swap-off">❌已禁用</div>
</label>
</td>
<td>
<!-- EnableChatRank -->
<label class="swap swap-flip {{ checkSwap .EnableChatRank }}">
<input type="checkbox" onclick="changeGroupRankEnableStatus({{.Wxid}})"/>
<div class="swap-on">✔️已启用</div>
<div class="swap-off">❌已禁用</div>
</label>
</td>
<td>
<button class="btn btn-link" onclick="getGroupUsers({{.Wxid}})">查看群成员</button>
</td>
</tr>
{{ end }}
</tbody>
</table>
</div>
</div>
</div>
<dialog id="groupUserModal" class="modal">
<div class="modal-box w-11/12 max-w-5xl">
<form method="dialog">
<button class="btn btn-sm btn-circle btn-ghost absolute right-2 top-2"></button>
</form>
<h3 class="font-bold text-lg">我是群名称</h3>
<table class="table table-zebra">
<!-- head -->
<thead>
<tr>
<th>微信Id</th>
<th>昵称</th>
<th>是否群成员</th>
<th>最后活跃时间</th>
<th>退群时间</th>
<th>是否跳过水群排行榜</th>
</tr>
</thead>
<tbody id="groupUsers">
<tr>
<td>25984982106634049@openim</td>
<td>成员</td>
<td>true</td>
<td>2023-11-30 16:49:42</td>
<td>2023-11-30 16:49:42</td>
<td>
<input type="checkbox" class="toggle toggle-success" onclick="changeUserGroupRankSkipStatus()" />
</td>
</tr>
</tbody>
</table>
</div>
</dialog>
</body>
</html>

View File

@@ -0,0 +1,4 @@
/* 隐藏滚动条 */
::-webkit-scrollbar {
display: none;
}

View File

@@ -1 +1,104 @@
console.log("打开首页")
console.log("打开首页")
// 改变AI开启状态
function changeAiEnableStatus(wxId) {
console.log("修改AI开启状态: ", wxId)
axios({
method: 'put',
url: '/api/ai/status',
data: {
wxId: wxId
}
}).then(function (response) {
console.log(`返回结果: ${JSON.stringify(response)}`);
}).catch(function (error) {
console.log(`错误信息: ${error}`);
})
}
// 修改水群排行榜状态
function changeGroupRankEnableStatus(wxId) {
console.log("修改水群排行榜开启状态: ", wxId)
axios({
method: 'put',
url: '/api/grouprank/status',
data: {
wxId: wxId
}
}).then(function (response) {
console.log(`返回结果: ${JSON.stringify(response)}`);
}).catch(function (error) {
console.log(`错误信息: ${error}`);
})
}
// 修改群成员是否参与排行榜状态
function changeUserGroupRankSkipStatus(groupId, userId) {
console.log("修改水群排行榜开启状态: ", groupId, userId)
axios({
method: 'put',
url: '/api/grouprank/skip',
data: {
wxId: wxId,
userId: userId
}
}).then(function (response) {
console.log(`返回结果: ${JSON.stringify(response)}`);
}).catch(function (error) {
console.log(`错误信息: ${error}`);
})
}
// 获取群成员列表
function getGroupUsers(groupId) {
// 打开模态框
const modal = document.getElementById("groupUserModal");
modal.showModal()
axios.get('/api/group/users', {
params: {
groupId: groupId
}
}).then(function (response) {
console.log(`返回结果: ${JSON.stringify(response)}`);
// 渲染群成员列表
const groupUsers = response.data
// const groupUserList = document.getElementById("groupUsers")
// 获取表格的tbody部分以便稍后向其中添加行
var tbody = document.getElementById("groupUsers");
for (let i = 0; i < groupUsers.length; i++) {
const groupUser = groupUsers[i]
var row = tbody.insertRow(i); // 插入新行
// 微信Id
var wxId = row.insertCell(0);
wxId.innerHTML = data[i].wxId;
// 昵称
var nickname = row.insertCell(1);
nickname.innerHTML = data[i].wxId;
// 是否群成员
var isMember = row.insertCell(2);
isMember.innerHTML = data[i].wxId;
// 最后活跃时间
var wxId = row.insertCell(3);
wxId.innerHTML = data[i].wxId;
// 退群时间
var wxId = row.insertCell(4);
wxId.innerHTML = data[i].wxId;
// 是否跳过水群排行榜
var wxId = row.insertCell(5);
wxId.innerHTML = data[i].wxId;
}
}).catch(function (error) {
console.log(`错误信息: ${error}`);
})
}