chore: ipv6支持

This commit is contained in:
xiaojunnuo
2024-11-13 22:42:11 +08:00
parent 70db327eda
commit a38ff69cbd
6 changed files with 64 additions and 26 deletions

View File

@@ -7,6 +7,8 @@ export * from './util.promise.js';
export * from './util.hash.js';
export * from './util.merge.js';
export * from './util.cache.js';
export * from './util.string.js';
import { stringUtils } from './util.string.js';
import sleep from './util.sleep.js';
import { http, download } from './util.request.js';
@@ -38,4 +40,5 @@ export const utils = {
dayjs,
domain: domainUtils,
options: optionsUtils,
string: stringUtils,
};

View File

@@ -0,0 +1,8 @@
export const stringUtils = {
maxLength(str?: string, length = 100) {
if (str) {
return str.length > length ? str.slice(0, length) + '...' : str;
}
return '';
},
};

View File

@@ -3,7 +3,7 @@ import * as sites from "./util.site";
import * as storages from "./util.storage";
import commons from "./util.common";
import * as mitt from "./util.mitt";
import router from "/util.router";
import { routerUtils } from "./util.router";
import { treeUtils } from "./util.tree";
export const util = {
...envs,
@@ -11,6 +11,6 @@ export const util = {
...storages,
...commons,
...mitt,
...router,
router: routerUtils,
tree: treeUtils
};

View File

@@ -33,5 +33,12 @@ export default {
async sleep(ms: number) {
return new Promise((resolve) => setTimeout(resolve, ms));
},
maxLength(str?: string, length = 100) {
if (str) {
return str.length > length ? str.slice(0, length) + "..." : str;
}
return "";
}
};

View File

@@ -47,13 +47,14 @@
</fs-page>
</template>
<script setup lang="ts">
<script setup lang="tsx">
import { reactive, ref } from "vue";
import * as api from "./api";
import { SysSettings } from "./api";
import { notification } from "ant-design-vue";
import { useSettingStore } from "/@/store/modules/settings";
import { merge } from "lodash-es";
import { util } from "/@/utils";
defineOptions({
name: "SysSettings"
@@ -111,7 +112,25 @@ async function testProxy() {
testProxyLoading.value = true;
try {
const res = await api.TestProxy();
const content = `测试google:${res.google === true ? "成功" : "失败" + res.google},测试百度:${res.baidu === true ? "成功" : "失败:" + res.baidu}`;
let success = true;
if (res.google !== true || res.baidu !== true) {
success = false;
}
const content = () => {
return (
<div>
<div>Google: {res.google === true ? "成功" : util.maxLength(res.google)}</div>
<div>Baidu: {res.baidu === true ? "成功" : util.maxLength(res.google)}</div>
</div>
);
};
if (!success) {
notification.error({
message: "测试失败",
description: content
});
return;
}
notification.success({
message: "测试完成",
description: content