|
|
@@ -1,13 +1,18 @@
|
|
1
|
1
|
import { reactive, ref } from 'vue'
|
|
2
|
|
-import { batchDelete, list, remove } from '@/api/login_log'
|
|
3
|
|
-import { list as fetchPeers } from '@/api/peer'
|
|
|
2
|
+import { list as admin_fetchPeers } from '@/api/peer'
|
|
|
3
|
+import { list as my_fetchPeers } from '@/api/my/peer'
|
|
4
|
4
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
|
5
|
5
|
import { useRoute } from 'vue-router'
|
|
6
|
6
|
import { T } from '@/utils/i18n'
|
|
|
7
|
+import { batchDelete as admin_batchDelete, list as admin_list, remove as admin_remove } from '@/api/login_log'
|
|
|
8
|
+import { batchDelete as my_batchDelete, list as my_list, remove as my_remove } from '@/api/my/login_log'
|
|
7
|
9
|
|
|
8
|
|
-export function useRepositories () {
|
|
9
|
|
- const route = useRoute()
|
|
10
|
|
- const user_id = route.query?.user_id
|
|
|
10
|
+const apis = {
|
|
|
11
|
+ admin: { batchDelete: admin_batchDelete, list: admin_list, remove: admin_remove, fetchPeers: admin_fetchPeers },
|
|
|
12
|
+ my: { batchDelete: my_batchDelete, list: my_list, remove: my_remove, fetchPeers: my_fetchPeers },
|
|
|
13
|
+}
|
|
|
14
|
+
|
|
|
15
|
+export function useRepositories (api_type = 'my') {
|
|
11
|
16
|
|
|
12
|
17
|
const listRes = reactive({
|
|
13
|
18
|
list: [], total: 0, loading: false,
|
|
|
@@ -16,16 +21,16 @@ export function useRepositories () {
|
|
16
|
21
|
page: 1,
|
|
17
|
22
|
page_size: 10,
|
|
18
|
23
|
is_my: 0,
|
|
19
|
|
- user_id: user_id ? parseInt(user_id) : null,
|
|
|
24
|
+ user_id: null,
|
|
20
|
25
|
})
|
|
21
|
26
|
|
|
22
|
27
|
const getList = async () => {
|
|
23
|
28
|
listRes.loading = true
|
|
24
|
|
- const res = await list(listQuery).catch(_ => false)
|
|
|
29
|
+ const res = await apis[api_type].list(listQuery).catch(_ => false)
|
|
25
|
30
|
listRes.loading = false
|
|
26
|
31
|
if (res) {
|
|
27
|
32
|
const uuids = res.data.list.filter(item => item.uuid).map(item => item.uuid)
|
|
28
|
|
- const peers = await fetchPeers({ uuids }).catch(_ => false)
|
|
|
33
|
+ const peers = await apis[api_type].fetchPeers({ uuids }).catch(_ => false)
|
|
29
|
34
|
if (peers?.data?.list) {
|
|
30
|
35
|
res.data.list.forEach(item => {
|
|
31
|
36
|
if (item.uuid) {
|
|
|
@@ -55,7 +60,7 @@ export function useRepositories () {
|
|
55
|
60
|
return false
|
|
56
|
61
|
}
|
|
57
|
62
|
|
|
58
|
|
- const res = await remove({ id: row.id }).catch(_ => false)
|
|
|
63
|
+ const res = await apis[api_type].remove({ id: row.id }).catch(_ => false)
|
|
59
|
64
|
if (res) {
|
|
60
|
65
|
ElMessage.success(T('OperationSuccess'))
|
|
61
|
66
|
getList()
|
|
|
@@ -77,7 +82,7 @@ export function useRepositories () {
|
|
77
|
82
|
return false
|
|
78
|
83
|
}
|
|
79
|
84
|
|
|
80
|
|
- const res = await batchDelete({ ids }).catch(_ => false)
|
|
|
85
|
+ const res = await apis[api_type].batchDelete({ ids }).catch(_ => false)
|
|
81
|
86
|
if (res) {
|
|
82
|
87
|
ElMessage.success(T('OperationSuccess'))
|
|
83
|
88
|
getList()
|