pull/213/head
xiaojunnuo 2024-10-12 18:30:40 +08:00
parent 67ba17286c
commit 5601bc4ab2
4 changed files with 55 additions and 5 deletions

View File

@ -72,3 +72,10 @@ export async function SysSettingsSave(data: SysSettings) {
data: data
});
}
export async function TestProxy() {
return await request({
url: apiPrefix + "/testProxy",
method: "post"
});
}

View File

@ -28,7 +28,10 @@
</a-form-item>
<a-form-item label="HTTPS代理" :name="['private', 'httpsProxy']" :rules="urlRules">
<a-input v-model:value="formState.private.httpsProxy" placeholder="http://192.168.1.2:18010/" />
<div class="flex">
<a-input v-model:value="formState.private.httpsProxy" placeholder="http://192.168.1.2:18010/" />
<a-button class="ml-5" type="primary" title="保存后,再点击测试" @click="testProxy"></a-button>
</div>
<div class="helper">一般这两个代理填一样的</div>
</a-form-item>
<a-form-item :wrapper-col="{ offset: 8, span: 16 }">
@ -96,6 +99,15 @@ async function stopOtherUserTimer() {
message: "停止成功"
});
}
async function testProxy() {
const res = await api.TestProxy();
const content = `测试google:${res.google === true ? "成功" : "失败" + res.google},测试百度:${res.baidu === true ? "成功" : "失败:" + res.baidu}`;
notification.success({
message: "测试完成",
description: content
});
}
</script>
<style lang="less">

View File

@ -35,10 +35,6 @@ export class AutoInitSite {
installInfo.siteId = nanoid();
await this.sysSettingsService.saveSetting(installInfo);
}
if (!installInfo.siteId) {
installInfo.siteId = nanoid();
await this.sysSettingsService.saveSetting(installInfo);
}
//private信息
const privateInfo = await this.sysSettingsService.getSetting<SysPrivateSettings>(SysPrivateSettings);

View File

@ -5,6 +5,7 @@ import * as _ from 'lodash-es';
import { PipelineService } from '../../../pipeline/service/pipeline-service.js';
import { UserSettingsService } from '../../../mine/service/user-settings-service.js';
import { getEmailSettings } from '../fix.js';
import { http, logger } from '@certd/pipeline';
/**
*/
@ -101,4 +102,38 @@ export class SysSettingsController extends CrudController<SysSettingsService> {
await this.pipelineService.stopOtherUserPipeline(1);
return this.ok({});
}
@Post('/testProxy', { summary: 'sys:settings:view' })
async testProxy(@Body(ALL) body) {
const google = 'https://www.google.com/';
const baidu = 'https://www.baidu.com/';
let googleRes = false;
try {
await http.request({
url: google,
method: 'GET',
timeout: 4000,
});
googleRes = true;
} catch (e) {
googleRes = e.message;
logger.info('test google error:', e);
}
let baiduRes = false;
try {
await http.request({
url: baidu,
method: 'GET',
timeout: 4000,
});
baiduRes = true;
} catch (e) {
baiduRes = e.message;
logger.info('test baidu error:', e);
}
return this.ok({
google: googleRes,
baidu: baiduRes,
});
}
}