|
|
@@ -576,6 +576,19 @@
|
|
|
</div>
|
|
|
</template>
|
|
|
</a-table-column>
|
|
|
+
|
|
|
+ <a-table-column title="操作" :width="140" fixed="right">
|
|
|
+ <template #cell="{ record }">
|
|
|
+ <a-button
|
|
|
+ type="primary"
|
|
|
+ size="small"
|
|
|
+ :loading="isChangingPublicIp(record.id)"
|
|
|
+ @click="handleChangePublicIp(record)"
|
|
|
+ >
|
|
|
+ 更换公网IP
|
|
|
+ </a-button>
|
|
|
+ </template>
|
|
|
+ </a-table-column>
|
|
|
</template>
|
|
|
</a-table>
|
|
|
</a-card>
|
|
|
@@ -585,7 +598,7 @@
|
|
|
<script lang="ts" setup>
|
|
|
import { computed, reactive, ref } from 'vue';
|
|
|
import dayjs from 'dayjs';
|
|
|
- import { Message, Modal } from '@arco-design/web-vue';
|
|
|
+ import { Message, Modal, Notification } from '@arco-design/web-vue';
|
|
|
import useLoading from '@/hooks/loading';
|
|
|
import {
|
|
|
ProxyCheckChannelResult,
|
|
|
@@ -594,6 +607,7 @@
|
|
|
ProxyNodeRecord,
|
|
|
ProxyNodeUsageAccount,
|
|
|
checkProxyNode,
|
|
|
+ changePublicIp,
|
|
|
queryProxyNodeList,
|
|
|
updateProxyNode,
|
|
|
} from '@/api/proxy';
|
|
|
@@ -622,6 +636,7 @@
|
|
|
const expandedIds = ref<number[]>([]);
|
|
|
const checkingKeys = ref<string[]>([]);
|
|
|
const updatingIds = ref<number[]>([]);
|
|
|
+ const changingPublicIpIds = ref<number[]>([]);
|
|
|
const checkResults = ref<Record<number, ProxyCheckState>>({});
|
|
|
|
|
|
const statusOptions = [
|
|
|
@@ -886,6 +901,43 @@
|
|
|
const removeLoadingId = (ids: number[], id: number) =>
|
|
|
ids.filter((item) => item !== id);
|
|
|
|
|
|
+ const isChangingPublicIp = (id: number) =>
|
|
|
+ changingPublicIpIds.value.includes(id);
|
|
|
+
|
|
|
+ const handleChangePublicIp = async (record: ProxyNodeRecord) => {
|
|
|
+ if (isChangingPublicIp(record.id)) return;
|
|
|
+
|
|
|
+ changingPublicIpIds.value = addLoadingId(
|
|
|
+ changingPublicIpIds.value,
|
|
|
+ record.id
|
|
|
+ );
|
|
|
+ try {
|
|
|
+ const response = await changePublicIp(record.id);
|
|
|
+ const result = response.data;
|
|
|
+ if (result.success === 'ok' && result.code === 200) {
|
|
|
+ Notification.success({
|
|
|
+ title: '更换公网IP成功',
|
|
|
+ content: `节点 ${record.id} 的公网IP已更换`,
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ Notification.error({
|
|
|
+ title: '更换公网IP失败',
|
|
|
+ content: result.msg || '接口返回异常',
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } catch {
|
|
|
+ Notification.error({
|
|
|
+ title: '更换公网IP失败',
|
|
|
+ content: '请求失败,请稍后重试',
|
|
|
+ });
|
|
|
+ } finally {
|
|
|
+ changingPublicIpIds.value = removeLoadingId(
|
|
|
+ changingPublicIpIds.value,
|
|
|
+ record.id
|
|
|
+ );
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
const getCheckKey = (id: number, target: ProxyCheckTarget) =>
|
|
|
`${id}-${target}`;
|
|
|
|