Browse Source

Merge branch 'newlogin' of Pchen0/RunForge-Frontend into main

Pchen0 1 month ago
parent
commit
61054b2b29
3 changed files with 127 additions and 3 deletions
  1. 18 0
      src/api/user.js
  2. 1 1
      src/components/userCard/userCard.vue
  3. 108 2
      src/pages/admin/user/userList.vue

+ 18 - 0
src/api/user.js

@@ -7,6 +7,8 @@ const api = {
   BindEmail: '/User/BindEmail',
   GetRepos: '/User/GetRepos',
   AdminUserList: '/Admin/User/GetUserList',
+  AdminSetSendCountAutoApprove: '/Admin/User/SetSendCountAutoApprove',
+  AdminSetUserBan: '/Admin/User/SetUserBan',
   AdminChangeLepaoCount: '/Admin/User/ChangeLepaoCount',
   AdminGetReqLog: '/Admin/User/GetReqLog',
   AdminGetReqLogDetail: '/Admin/User/GetReqLogDetail'
@@ -44,6 +46,22 @@ export function adminChangeLepaoCount(parameter) {
   })
 }
 
+export function adminSetSendCountAutoApprove(parameter) {
+  return request({
+    url: api.AdminSetSendCountAutoApprove,
+    method: 'post',
+    data: parameter
+  })
+}
+
+export function adminSetUserBan(parameter) {
+  return request({
+    url: api.AdminSetUserBan,
+    method: 'post',
+    data: parameter
+  })
+}
+
 export function BindEmail(parameter) {
   return request({
     url: api.BindEmail,

+ 1 - 1
src/components/userCard/userCard.vue

@@ -83,7 +83,7 @@ const handleBeforeOk = async (done) => {
       return false
     }
 
-    Message.success('已提交审核,审核通过后接收方将到账')
+    Message.success(res.msg || '操作成功')
     done()
     GetCount()
   } catch (error) {

+ 108 - 2
src/pages/admin/user/userList.vue

@@ -99,6 +99,25 @@
                 <template #last_login_type="{ record }">
                     <span>{{ formatLastLoginType(record.last_login_type) }}</span>
                 </template>
+                <template #send_count_auto_approve="{ record }">
+                    <a-switch
+                        :model-value="isSendCountAutoApprove(record)"
+                        :loading="whitelistLoadingUuid === record.uuid"
+                        @change="(checked) => onSendCountAutoApproveChange(record, checked)"
+                    />
+                </template>
+                <template #is_banned_status="{ record }">
+                    <a-tag v-if="isBanned(record)" color="red">已封禁</a-tag>
+                    <a-tag v-else color="green">正常</a-tag>
+                </template>
+                <template #is_banned="{ record }">
+                    <a-switch
+                        :model-value="isBanned(record)"
+                        :loading="banLoadingUuid === record.uuid"
+                        checked-color="rgb(var(--red-6))"
+                        @change="(checked) => onBanChange(record, checked)"
+                    />
+                </template>
                 <template #optional="{ record }">
                     <a-button @click="changeCount(record)">更改次数</a-button>
                 </template>
@@ -125,8 +144,8 @@
 
 <script setup>
 import { ref, reactive, onMounted } from 'vue'
-import { adminGetUserList, adminChangeLepaoCount } from '@/api/user'
-import { Notification, Message } from '@arco-design/web-vue'
+import { adminGetUserList, adminChangeLepaoCount, adminSetSendCountAutoApprove, adminSetUserBan } from '@/api/user'
+import { Notification, Message, Modal } from '@arco-design/web-vue'
 
 const visible = ref(false)
 const ok_loading = ref(false)
@@ -151,6 +170,81 @@ const pagination = reactive({
 
 const loading = ref(false)
 const data = ref([])
+const whitelistLoadingUuid = ref('')
+const banLoadingUuid = ref('')
+
+const isSendCountAutoApprove = (record) => Number(record?.send_count_auto_approve) === 1
+const isBanned = (record) => Number(record?.is_banned) === 1
+
+const onSendCountAutoApproveChange = async (record, checked) => {
+    if (!record?.uuid || whitelistLoadingUuid.value) return
+    const next = checked === true ? 1 : 0
+    whitelistLoadingUuid.value = record.uuid
+    try {
+        const res = await adminSetSendCountAutoApprove({
+            userid: record.uuid,
+            send_count_auto_approve: next
+        })
+        if (!res || res.code !== 0) {
+            Notification.error({
+                title: '保存失败',
+                content: res?.msg ?? '请稍后再试'
+            })
+            return
+        }
+        record.send_count_auto_approve = next
+        Message.success(next ? '已加入赠送免审白名单' : '已关闭赠送免审')
+    } catch (error) {
+        Notification.error({
+            title: '保存失败',
+            content: error.message || '请稍后再试'
+        })
+    } finally {
+        whitelistLoadingUuid.value = ''
+    }
+}
+
+const setUserBan = async (record, next) => {
+    banLoadingUuid.value = record.uuid
+    try {
+        const res = await adminSetUserBan({
+            userid: record.uuid,
+            is_banned: next
+        })
+        if (!res || res.code !== 0) {
+            Notification.error({
+                title: '操作失败',
+                content: res?.msg ?? '请稍后再试'
+            })
+            return
+        }
+        record.is_banned = next
+        Message.success(next ? '已封禁该用户' : '已解除封禁')
+    } catch (error) {
+        Notification.error({
+            title: '操作失败',
+            content: error.message || '请稍后再试'
+        })
+    } finally {
+        banLoadingUuid.value = ''
+    }
+}
+
+const onBanChange = async (record, checked) => {
+    if (!record?.uuid || banLoadingUuid.value) return
+    const next = checked === true ? 1 : 0
+    if (next === 1) {
+        Modal.confirm({
+            title: '确认封禁',
+            content: `确定封禁用户「${record.username || record.uuid}」?封禁后该用户将立即下线且无法登录。`,
+            onOk: async () => {
+                await setUserBan(record, next)
+            }
+        })
+        return
+    }
+    await setUserBan(record, 0)
+}
 
 const columns = [
 
@@ -193,6 +287,18 @@ const columns = [
         title: '剩余乐跑次数',
         dataIndex: 'lepao_count',
         width: 120,
+    }, {
+        title: '赠送免审',
+        slotName: 'send_count_auto_approve',
+        width: 110,
+    }, {
+        title: '账号状态',
+        slotName: 'is_banned_status',
+        width: 100,
+    }, {
+        title: '封禁',
+        slotName: 'is_banned',
+        width: 80,
     }, {
         title: '操作',
         slotName: 'optional',