Skip to content

Commit

Permalink
rewrited: IcpCheck.vue
Browse files Browse the repository at this point in the history
  • Loading branch information
Muska-Ami committed Sep 6, 2024
1 parent ac31ea9 commit 2da7f0c
Show file tree
Hide file tree
Showing 12 changed files with 129 additions and 71 deletions.
2 changes: 1 addition & 1 deletion src/api/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const base = {
api_v2_url: 'https://api-v2.locyanfrp.cn/api/v2',
buildResponse: (res: any, useDataPath: boolean = true) => {
return {
status: res.status,
status: res.status as number,
data: useDataPath ? res.data.data : res.data
}
}
Expand Down
17 changes: 17 additions & 0 deletions src/api/v2/icp/check.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import base from '@/api/base'
//@ts-ignore
import { get } from '@/utils/request'

/**
* 审核 ICP 备案域名
*/
const check = async (username: string, token: string, domain: string) => {
const rs = get(`${base.api_v2_url}/icp/check`, {
username: username,
token: token,
domain: domain
})
return base.buildResponse(await rs)
}

export default check
9 changes: 9 additions & 0 deletions src/api/v2/icp/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import list from './list'
import check from './check'
import remove from './remove'

export default {
check: check,
remove: remove,
list: list
}
16 changes: 16 additions & 0 deletions src/api/v2/icp/list.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import base from '@/api/base'
//@ts-ignore
import { get } from '@/utils/request'

/**
* 列出已审核 ICP 备案域名
*/
const list = async (username: string, token: string) => {
const rs = get(`${base.api_v2_url}/icp/list`, {
username: username,
token: token
})
return base.buildResponse(await rs)
}

export default list
14 changes: 14 additions & 0 deletions src/api/v2/icp/remove.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import base from '@/api/base'
//@ts-ignore
import { deleteReq } from '@/utils/request'

const remove = async (username: string, token: string, domain_id: number) => {
const rs = deleteReq(`${base.api_v2_url}/icp/remove`, {
username: username,
token: token,
id: domain_id
})
return base.buildResponse(await rs)
}

export default remove
4 changes: 3 additions & 1 deletion src/api/v2/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import config from './config'
import donate from './donate'
import icp from './icp'
import nodes from './nodes'
import oauth from './oauth'
import proxies from './proxies'
Expand All @@ -17,5 +18,6 @@ export default {
proxies: proxies,
nodes: nodes,
config: config,
donate: donate
donate: donate,
icp: icp
}
4 changes: 2 additions & 2 deletions src/components/UserInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ async function doBindQQ() {
message.error('请求失败: ' + e)
}
if (!rs) return
if (rs.status == 200) {
if (rs.status === 200) {
window.open(rs.data.url)
binding.value = false
}
Expand All @@ -264,7 +264,7 @@ async function unBindQQ() {
}, 1000)
}
if (!rs) return
if (rs.status == 200) {
if (rs.status === 200) {
binding.value = false
bindQQ.value.unBindDisable = true
bindQQ.value.unBindmsg = ref('解绑成功')
Expand Down
2 changes: 1 addition & 1 deletion src/views/AddProxies.vue
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ async function randomPort() {
sendErrorMessage('请求隧道端口失败: ' + e)
}
if (!rs) return
if (rs.status == 200) {
if (rs.status === 200) {
proxyInfo.value.remote_port = rs.data.port
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/views/Donate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ onMounted(async () => {
sendErrorMessage('请求列表失败: ' + e)
}
if (!rs) return
if (rs.status == 200) {
if (rs.status === 200) {
if (rs.data) trade_info.value = rs.data
else sendErrorMessage('返回数据无效')
} else {
Expand All @@ -200,7 +200,7 @@ async function getDonateList() {
sendErrorMessage('请求列表失败: ' + e)
}
if (!rs) return
if (rs.status == 200) {
if (rs.status === 200) {
donateList.value = rs.data
loadingDonateList.value = false
} else {
Expand Down Expand Up @@ -241,7 +241,7 @@ async function submitMessage() {
sendErrorMessage('请求列表失败: ' + e)
}
if (!rs) return
if (rs.status == 200) {
if (rs.status === 200) {
if (rs.data.status) {
sendSuccessDialog(rs.data.message)
getDonateList()
Expand Down
118 changes: 59 additions & 59 deletions src/views/IcpCheck.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
<n-grid-item span="1">
<n-list bordered v-show="showList">
<template #header> 已登记的域名 </template>
<n-list-item v-for="item in IcpList">
<n-list-item v-for="item in icpList">
<n-thing
:title="item.domain"
:description="item.unitName + ' (' + item.natureName + ') - ' + item.icp"
>
</n-thing>
<template #suffix>
<n-button type="error" @click="RemoveIcp(item.id)">删除</n-button>
<n-button type="error" @click="removeICP(item.id)">删除</n-button>
</template>
</n-list-item>
</n-list>
Expand All @@ -43,9 +43,10 @@
import { ref } from 'vue'
import store from '@/utils/stores/store'
import { get, deleteReq } from '@/utils/request'
import { sendErrorMessage, sendSuccessMessage } from '@/utils/message'
import { sendSuccessMessage, sendErrorMessage } from '@/utils/message'
import { sendErrorDialog, sendSuccessDialog } from '@/utils/dialog'
import { useDialog } from 'naive-ui'
import api from '@/api'
const showList = ref(false)
const formRef = ref(null)
Expand All @@ -54,7 +55,7 @@ const loading = ref(false)
const domainInput = ref({
domain: ''
})
const IcpList = ref([
const icpList = ref([
{
id: 0,
icp: '',
Expand All @@ -66,7 +67,7 @@ const IcpList = ref([
}
])
function submit() {
async function submit() {
if (loading.value == true) {
return
}
Expand All @@ -76,52 +77,52 @@ function submit() {
loading.value = false
return
}
const rs = get(
'https://api-v2.locyanfrp.cn/api/v2/icp/check?domain=' +
domainInput.value.domain +
'&token=' +
store.getters.get_token +
'&username=' +
store.getters.get_username
)
rs.finally((res) => {
let rs
try {
rs = await api.v2.icp.check(
store.getters.get_username,
store.getters.get_token,
domainInput.value.domain
)
} catch (e) {
sendErrorMessage('请求审核失败: ' + e)
}
loading.value = false
if (!rs) return
if (rs.status != 200) {
loading.value = false
})
rs.then((res) => {
if (res.status != 200) {
loading.value = false
sendErrorDialog('审核失败,可能是域名没有备案或格式错误!')
} else {
GetList()
loading.value = false
sendSuccessDialog('添加成功!')
}
})
sendErrorDialog('审核失败,可能是域名没有备案或格式错误!')
} else {
getList()
loading.value = false
sendSuccessDialog('添加成功!')
}
}
function RemoveIcp(id) {
async function removeICP(id) {
dialog.warning({
title: '警告',
content: '你确定要删除这个域名吗?(域名 ID: ' + id + '',
positiveText: '确定',
negativeText: '取消',
onPositiveClick: () => {
const rs = deleteReq(
'https://api-v2.locyanfrp.cn/api/v2/icp/remove?id=' +
id +
'&token=' +
store.getters.get_token +
'&username=' +
store.getters.get_username
)
rs.then((res) => {
if (res.status === 200) {
sendSuccessDialog('删除成功!')
GetList()
} else {
sendErrorDialog('删除失败,请联系管理员处理!')
}
})
onPositiveClick: async () => {
let rs
try {
rs = await api.v2.icp.remove(
store.getters.get_username,
store.getters.get_token,
id
)
} catch (e) {
sendErrorMessage('请求移除域名失败: ' + e)
}
if (!rs) return
if (rs.status === 200) {
sendSuccessDialog('删除成功!')
getList()
} else {
sendErrorDialog('删除失败,请联系管理员处理!')
}
},
onNegativeClick: () => {
sendSuccessMessage('你取消了操作!')
Expand All @@ -132,22 +133,21 @@ function RemoveIcp(id) {
})
}
function GetList() {
const rs = get(
'https://api-v2.locyanfrp.cn/api/v2/icp/list?token=' +
store.getters.get_token +
'&username=' +
store.getters.get_username
)
rs.then((res) => {
if (res.status === 200) {
IcpList.value = res.data.list
showList.value = true
} else {
showList.value = false
}
})
async function getList() {
let rs
try {
rs = await api.v2.icp.list(store.getters.get_username, store.getters.get_token)
} catch (e) {
sendErrorMessage('请求移除域名失败: ' + e)
}
if (!rs) return
if (rs.status === 200) {
icpList.value = rs.data.list
showList.value = true
} else {
showList.value = false
}
}
GetList()
getList()
</script>
4 changes: 2 additions & 2 deletions src/views/Proxies.vue
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ async function initList() {
sendErrorMessage('请求节点列表失败: ' + e)
}
if (!rs2) return
if (rs2.status == 200) {
if (rs2.status === 200) {
proxiesList.value = rs2.data.proxies
show.value = false
} else {
Expand Down Expand Up @@ -533,7 +533,7 @@ function deleteProxy(id) {
sendErrorMessage('请求删除隧道失败: ' + e)
}
if (!rs) return
if (rs.status == 200) {
if (rs.status === 200) {
sendSuccessMessage('删除成功!')
proxiesList.value.splice(id, 1)
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/views/Sign.vue
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ async function checkSign() {
loading.value = false
}
if (!rs) return
if (rs.status == 200) {
if (rs.status === 200) {
status.value = rs.data.status
}
loading.value = false
Expand All @@ -137,7 +137,7 @@ async function doSign() {
sendErrorMessage('签到失败: ' + e)
}
if (!rs) return
if (rs.status == 200) {
if (rs.status === 200) {
sendErrorMessage(rs.message)
checkSign()
} else {
Expand Down

0 comments on commit 2da7f0c

Please sign in to comment.