mirror of
https://github.com/certd/certd.git
synced 2026-05-15 20:47:31 +08:00
More translation
This commit is contained in:
@@ -1,54 +1,59 @@
|
||||
<template>
|
||||
<div class="sys-settings-form sys-settings-base">
|
||||
<a-form :model="formState" name="basic" :label-col="{ span: 8 }" :wrapper-col="{ span: 16 }" autocomplete="off" @finish="onFinish" @finish-failed="onFinishFailed">
|
||||
<a-form-item label="ICP备案号" :name="['public', 'icpNo']">
|
||||
<a-input v-model:value="formState.public.icpNo" placeholder="粤ICP备xxxxxxx号" />
|
||||
</a-form-item>
|
||||
<a-form-item label="网安备案号" :name="['public', 'mpsNo']">
|
||||
<a-input v-model:value="formState.public.mpsNo" placeholder="京公网安备xxxxxxx号" />
|
||||
</a-form-item>
|
||||
<div class="sys-settings-form sys-settings-base">
|
||||
<a-form :model="formState" name="basic" :label-col="{ span: 8 }" :wrapper-col="{ span: 16 }" autocomplete="off"
|
||||
@finish="onFinish" @finish-failed="onFinishFailed">
|
||||
<a-form-item :label="t('certd.icpRegistrationNumber')" :name="['public', 'icpNo']">
|
||||
<a-input v-model:value="formState.public.icpNo" :placeholder="t('certd.icpPlaceholder')" />
|
||||
</a-form-item>
|
||||
<a-form-item :label="t('certd.publicSecurityRegistrationNumber')" :name="['public', 'mpsNo']">
|
||||
<a-input v-model:value="formState.public.mpsNo" :placeholder="t('certd.publicSecurityPlaceholder')" />
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="开启小助手" :name="['public', 'aiChatEnabled']">
|
||||
<a-switch v-model:checked="formState.public.aiChatEnabled" />
|
||||
</a-form-item>
|
||||
<a-form-item label="允许爬虫" :name="['public', 'robots']">
|
||||
<a-switch v-model:checked="formState.public.robots" />
|
||||
</a-form-item>
|
||||
<a-form-item :label="t('certd.enableAssistant')" :name="['public', 'aiChatEnabled']">
|
||||
<a-switch v-model:checked="formState.public.aiChatEnabled" />
|
||||
</a-form-item>
|
||||
<a-form-item :label="t('certd.allowCrawlers')" :name="['public', 'robots']">
|
||||
<a-switch v-model:checked="formState.public.robots" />
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="HTTP代理" :name="['private', 'httpProxy']" :rules="urlRules">
|
||||
<a-input v-model:value="formState.private.httpProxy" placeholder="http://192.168.1.2:18010/" />
|
||||
<div class="helper">当某些网站被墙时可以配置</div>
|
||||
</a-form-item>
|
||||
<a-form-item :label="t('certd.httpProxy')" :name="['private', 'httpProxy']" :rules="urlRules">
|
||||
<a-input v-model:value="formState.private.httpProxy" :placeholder="t('certd.httpProxyPlaceholder')" />
|
||||
<div class="helper">{{ t('certd.httpProxyHelper') }}</div>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="HTTPS代理" :name="['private', 'httpsProxy']" :rules="urlRules">
|
||||
<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" :loading="testProxyLoading" title="保存后,再点击测试" @click="testProxy">测试</a-button>
|
||||
</div>
|
||||
<div class="helper">一般这两个代理填一样的,保存后再测试</div>
|
||||
</a-form-item>
|
||||
<a-form-item :label="t('certd.httpsProxy')" :name="['private', 'httpsProxy']" :rules="urlRules">
|
||||
<div class="flex">
|
||||
<a-input v-model:value="formState.private.httpsProxy"
|
||||
:placeholder="t('certd.httpsProxyPlaceholder')" />
|
||||
<a-button class="ml-5" type="primary" :loading="testProxyLoading"
|
||||
:title="t('certd.saveThenTestTitle')" @click="testProxy">{{ t('certd.testButton') }}</a-button>
|
||||
</div>
|
||||
<div class="helper">{{ t('certd.httpsProxyHelper') }}</div>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="双栈网络" :name="['private', 'dnsResultOrder']">
|
||||
<a-select v-model:value="formState.private.dnsResultOrder">
|
||||
<a-select-option value="verbatim">默认</a-select-option>
|
||||
<a-select-option value="ipv4first">IPV4优先</a-select-option>
|
||||
<a-select-option value="ipv6first">IPV6优先</a-select-option>
|
||||
</a-select>
|
||||
<div class="helper">如果选择IPv6优先,需要在docker-compose.yaml中启用ipv6</div>
|
||||
</a-form-item>
|
||||
<a-form-item :label="t('certd.dualStackNetwork')" :name="['private', 'dnsResultOrder']">
|
||||
<a-select v-model:value="formState.private.dnsResultOrder">
|
||||
<a-select-option value="verbatim">{{ t('certd.default') }}</a-select-option>
|
||||
<a-select-option value="ipv4first">{{ t('certd.ipv4Priority') }}</a-select-option>
|
||||
<a-select-option value="ipv6first">{{ t('certd.ipv6Priority') }}</a-select-option>
|
||||
</a-select>
|
||||
<div class="helper">{{ t('certd.dualStackNetworkHelper') }}</div>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="启用公共CNAME服务" :name="['private', 'commonCnameEnabled']">
|
||||
<a-switch v-model:checked="formState.private.commonCnameEnabled" />
|
||||
<div class="helper">是否可以使用公共CNAME服务,如果禁用,且没有设置<router-link to="/sys/cname/provider">自定义CNAME服务</router-link>,则无法使用CNAME代理方式申请证书</div>
|
||||
</a-form-item>
|
||||
<a-form-item :label="t('certd.enableCommonCnameService')" :name="['private', 'commonCnameEnabled']">
|
||||
<a-switch v-model:checked="formState.private.commonCnameEnabled" />
|
||||
<div class="helper" v-html="t('certd.commonCnameHelper')"></div>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label=" " :colon="false" :wrapper-col="{ span: 8 }">
|
||||
<a-button :loading="saveLoading" type="primary" html-type="submit">保存</a-button>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</div>
|
||||
<a-form-item label=" " :colon="false" :wrapper-col="{ span: 8 }">
|
||||
<a-button :loading="saveLoading" type="primary" html-type="submit">{{ t('certd.saveButton')
|
||||
}}</a-button>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
<script setup lang="tsx">
|
||||
import { reactive, ref } from "vue";
|
||||
import { SysSettings } from "/@/views/sys/settings/api";
|
||||
@@ -57,90 +62,94 @@ import { merge } from "lodash-es";
|
||||
import { useSettingStore } from "/@/store/settings";
|
||||
import { notification } from "ant-design-vue";
|
||||
import { util } from "/@/utils";
|
||||
import { useI18n } from "vue-i18n";
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
defineOptions({
|
||||
name: "SettingBase",
|
||||
name: "SettingBase",
|
||||
});
|
||||
|
||||
const formState = reactive<Partial<SysSettings>>({
|
||||
public: {
|
||||
icpNo: "",
|
||||
mpsNo: "",
|
||||
},
|
||||
private: {},
|
||||
public: {
|
||||
icpNo: "",
|
||||
mpsNo: "",
|
||||
},
|
||||
private: {},
|
||||
});
|
||||
|
||||
const urlRules = ref({
|
||||
type: "url",
|
||||
message: "请输入正确的URL",
|
||||
type: "url",
|
||||
message: "请输入正确的URL",
|
||||
});
|
||||
|
||||
async function loadSysSettings() {
|
||||
const data: any = await api.SysSettingsGet();
|
||||
merge(formState, data);
|
||||
const data: any = await api.SysSettingsGet();
|
||||
merge(formState, data);
|
||||
}
|
||||
|
||||
const saveLoading = ref(false);
|
||||
loadSysSettings();
|
||||
const settingsStore = useSettingStore();
|
||||
const onFinish = async (form: any) => {
|
||||
try {
|
||||
saveLoading.value = true;
|
||||
await api.SysSettingsSave(form);
|
||||
await settingsStore.loadSysSettings();
|
||||
notification.success({
|
||||
message: "保存成功",
|
||||
});
|
||||
} finally {
|
||||
saveLoading.value = false;
|
||||
}
|
||||
try {
|
||||
saveLoading.value = true;
|
||||
await api.SysSettingsSave(form);
|
||||
await settingsStore.loadSysSettings();
|
||||
notification.success({
|
||||
message: t('certd.saveSuccess'),
|
||||
});
|
||||
} finally {
|
||||
saveLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const onFinishFailed = (errorInfo: any) => {
|
||||
// console.log("Failed:", errorInfo);
|
||||
// console.log("Failed:", errorInfo);
|
||||
};
|
||||
|
||||
async function stopOtherUserTimer() {
|
||||
await api.stopOtherUserTimer();
|
||||
notification.success({
|
||||
message: "停止成功",
|
||||
});
|
||||
await api.stopOtherUserTimer();
|
||||
notification.success({
|
||||
message: t('certd.stopSuccess'),
|
||||
});
|
||||
}
|
||||
|
||||
const testProxyLoading = ref(false);
|
||||
async function testProxy() {
|
||||
testProxyLoading.value = true;
|
||||
try {
|
||||
const res = await api.TestProxy();
|
||||
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,
|
||||
});
|
||||
} finally {
|
||||
testProxyLoading.value = false;
|
||||
}
|
||||
testProxyLoading.value = true;
|
||||
try {
|
||||
const res = await api.TestProxy();
|
||||
let success = true;
|
||||
if (res.google !== true || res.baidu !== true) {
|
||||
success = false;
|
||||
}
|
||||
const content = () => {
|
||||
return (
|
||||
<div>
|
||||
<div>{t('certd.google')}: {res.google === true ? t('certd.success') : util.maxLength(res.google)}</div>
|
||||
<div>{t('certd.baidu')}: {res.baidu === true ? t('certd.success') : util.maxLength(res.baidu)}</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
if (!success) {
|
||||
notification.error({
|
||||
message: t('certd.testFailed'),
|
||||
description: content,
|
||||
});
|
||||
return;
|
||||
}
|
||||
notification.success({
|
||||
message: t('certd.testCompleted'),
|
||||
description: content,
|
||||
});
|
||||
} finally {
|
||||
testProxyLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
<style lang="less">
|
||||
.sys-settings-base {
|
||||
}
|
||||
.sys-settings-base {}
|
||||
</style>
|
||||
|
||||
@@ -1,67 +1,78 @@
|
||||
<template>
|
||||
<div class="sys-settings-form sys-settings-register">
|
||||
<a-form :model="formState" name="register" :label-col="{ span: 8 }" :wrapper-col="{ span: 16 }" autocomplete="off" @finish="onFinish">
|
||||
<a-form-item label="管理其他用户流水线" :name="['public', 'managerOtherUserPipeline']">
|
||||
<a-switch v-model:checked="formState.public.managerOtherUserPipeline" />
|
||||
</a-form-item>
|
||||
<a-form-item label="限制用户流水线数量" :name="['public', 'limitUserPipelineCount']">
|
||||
<a-input-number v-model:value="formState.public.limitUserPipelineCount" />
|
||||
<div class="helper">0为不限制</div>
|
||||
</a-form-item>
|
||||
<a-form-item label="开启自助注册" :name="['public', 'registerEnabled']">
|
||||
<a-switch v-model:checked="formState.public.registerEnabled" />
|
||||
</a-form-item>
|
||||
<a-form-item label="开启用户有效期" :name="['public', 'userValidTimeEnabled']">
|
||||
<div class="flex-o">
|
||||
<a-switch v-model:checked="formState.public.userValidTimeEnabled" :disabled="!settingsStore.isPlus" />
|
||||
<vip-button class="ml-5" mode="button"></vip-button>
|
||||
</div>
|
||||
<div class="helper">有效期内用户可正常使用,失效后流水线将被停用</div>
|
||||
</a-form-item>
|
||||
<template v-if="formState.public.registerEnabled">
|
||||
<a-form-item label="开启用户名注册" :name="['public', 'usernameRegisterEnabled']">
|
||||
<a-switch v-model:checked="formState.public.usernameRegisterEnabled" />
|
||||
</a-form-item>
|
||||
<div class="sys-settings-form sys-settings-register">
|
||||
<a-form :model="formState" name="register" :label-col="{ span: 8 }" :wrapper-col="{ span: 16 }"
|
||||
autocomplete="off" @finish="onFinish">
|
||||
<a-form-item :label="t('certd.manageOtherUserPipeline')" :name="['public', 'managerOtherUserPipeline']">
|
||||
<a-switch v-model:checked="formState.public.managerOtherUserPipeline" />
|
||||
</a-form-item>
|
||||
<a-form-item :label="t('certd.limitUserPipelineCount')" :name="['public', 'limitUserPipelineCount']">
|
||||
<a-input-number v-model:value="formState.public.limitUserPipelineCount" />
|
||||
<div class="helper">{{ t('certd.limitUserPipelineCountHelper') }}</div>
|
||||
</a-form-item>
|
||||
<a-form-item :label="t('certd.enableSelfRegistration')" :name="['public', 'registerEnabled']">
|
||||
<a-switch v-model:checked="formState.public.registerEnabled" />
|
||||
</a-form-item>
|
||||
<a-form-item :label="t('certd.enableUserValidityPeriod')" :name="['public', 'userValidTimeEnabled']">
|
||||
<div class="flex-o">
|
||||
<a-switch v-model:checked="formState.public.userValidTimeEnabled"
|
||||
:disabled="!settingsStore.isPlus" />
|
||||
<vip-button class="ml-5" mode="button"></vip-button>
|
||||
</div>
|
||||
<div class="helper">{{ t('certd.userValidityPeriodHelper') }}</div>
|
||||
</a-form-item>
|
||||
<template v-if="formState.public.registerEnabled">
|
||||
<a-form-item :label="t('certd.enableUsernameRegistration')"
|
||||
:name="['public', 'usernameRegisterEnabled']">
|
||||
<a-switch v-model:checked="formState.public.usernameRegisterEnabled" />
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="开启邮箱注册" :name="['public', 'emailRegisterEnabled']">
|
||||
<div class="flex-o">
|
||||
<a-switch v-model:checked="formState.public.emailRegisterEnabled" :disabled="!settingsStore.isPlus" title="专业版功能" />
|
||||
<vip-button class="ml-5" mode="button"></vip-button>
|
||||
</div>
|
||||
<div class="helper">需要<router-link to="/sys/settings/email">设置邮箱服务器</router-link></div>
|
||||
</a-form-item>
|
||||
<a-form-item label="开启手机号登录、注册" :name="['public', 'smsLoginEnabled']">
|
||||
<div class="flex-o">
|
||||
<a-switch v-model:checked="formState.public.smsLoginEnabled" :disabled="!settingsStore.isComm" title="商业版功能" />
|
||||
<vip-button class="ml-5" mode="comm"></vip-button>
|
||||
</div>
|
||||
</a-form-item>
|
||||
<template v-if="formState.public.smsLoginEnabled">
|
||||
<a-form-item label="短信提供商" :name="['private', 'sms', 'type']">
|
||||
<a-select v-model:value="formState.private.sms.type" @change="smsTypeChange">
|
||||
<a-select-option value="aliyun">阿里云短信</a-select-option>
|
||||
<a-select-option value="yfysms">易发云短信</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
<template v-for="item of smsTypeDefineInputs" :key="item.simpleKey">
|
||||
<fs-form-item v-model="formState.private.sms.config[item.simpleKey]" :path="'private.sms.config' + item.key" :item="item" />
|
||||
</template>
|
||||
<a-form-item :label="t('certd.enableEmailRegistration')" :name="['public', 'emailRegisterEnabled']">
|
||||
<div class="flex-o">
|
||||
<a-switch v-model:checked="formState.public.emailRegisterEnabled"
|
||||
:disabled="!settingsStore.isPlus" :title="t('certd.proFeature')" />
|
||||
<vip-button class="ml-5" mode="button"></vip-button>
|
||||
</div>
|
||||
<div class="helper">
|
||||
<router-link to="/sys/settings/email">{{ t('certd.emailServerSetup') }}</router-link>
|
||||
</div>
|
||||
</a-form-item>
|
||||
<a-form-item :label="t('certd.enableSmsLoginRegister')" :name="['public', 'smsLoginEnabled']">
|
||||
<div class="flex-o">
|
||||
<a-switch v-model:checked="formState.public.smsLoginEnabled" :disabled="!settingsStore.isComm"
|
||||
:title="t('certd.commFeature')" />
|
||||
<vip-button class="ml-5" mode="comm"></vip-button>
|
||||
</div>
|
||||
</a-form-item>
|
||||
<template v-if="formState.public.smsLoginEnabled">
|
||||
<a-form-item :label="t('certd.smsProvider')" :name="['private', 'sms', 'type']">
|
||||
<a-select v-model:value="formState.private.sms.type" @change="smsTypeChange">
|
||||
<a-select-option value="aliyun">{{ t('certd.aliyunSms') }}</a-select-option>
|
||||
<a-select-option value="yfysms">{{ t('certd.yfySms') }}</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
<template v-for="item of smsTypeDefineInputs" :key="item.simpleKey">
|
||||
<fs-form-item v-model="formState.private.sms.config[item.simpleKey]"
|
||||
:path="'private.sms.config' + item.key" :item="item" />
|
||||
</template>
|
||||
|
||||
<a-form-item label="短信测试">
|
||||
<div class="flex">
|
||||
<a-input v-model:value="testMobile" placeholder="输入测试手机号" />
|
||||
<loading-button class="ml-5" title="保存后再点击测试" type="primary" :click="testSendSms">测试</loading-button>
|
||||
</div>
|
||||
<div class="helper">保存后再点击测试</div>
|
||||
</a-form-item>
|
||||
</template>
|
||||
</template>
|
||||
<a-form-item :label="t('certd.smsTest')">
|
||||
<div class="flex">
|
||||
<a-input v-model:value="testMobile" :placeholder="t('certd.testMobilePlaceholder')" />
|
||||
<loading-button class="ml-5" :title="t('certd.saveThenTest')" type="primary"
|
||||
:click="testSendSms">{{
|
||||
t('certd.testButton') }}</loading-button>
|
||||
</div>
|
||||
<div class="helper">{{ t('certd.saveThenTest') }}</div>
|
||||
</a-form-item>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
<a-form-item label=" " :colon="false" :wrapper-col="{ span: 16 }">
|
||||
<a-button :loading="saveLoading" type="primary" html-type="submit">保存</a-button>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</div>
|
||||
<a-form-item label=" " :colon="false" :wrapper-col="{ span: 16 }">
|
||||
<a-button :loading="saveLoading" type="primary" html-type="submit">{{ t('certd.saveButton')
|
||||
}}</a-button>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="tsx">
|
||||
@@ -71,123 +82,127 @@ import * as api from "/@/views/sys/settings/api";
|
||||
import { merge } from "lodash-es";
|
||||
import { useSettingStore } from "/@/store/settings";
|
||||
import { notification } from "ant-design-vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
defineOptions({
|
||||
name: "SettingRegister",
|
||||
name: "SettingRegister",
|
||||
});
|
||||
|
||||
const testMobile = ref("");
|
||||
async function testSendSms() {
|
||||
if (!testMobile.value) {
|
||||
notification.error({
|
||||
message: "请输入测试手机号",
|
||||
});
|
||||
return;
|
||||
}
|
||||
await api.TestSms({
|
||||
mobile: testMobile.value,
|
||||
});
|
||||
notification.success({
|
||||
message: "发送成功",
|
||||
});
|
||||
if (!testMobile.value) {
|
||||
notification.error({
|
||||
message: t('certd.enterTestMobile'),
|
||||
});
|
||||
return;
|
||||
}
|
||||
await api.TestSms({
|
||||
mobile: testMobile.value,
|
||||
});
|
||||
notification.success({
|
||||
message: t('certd.sendSuccess'),
|
||||
});
|
||||
}
|
||||
|
||||
const formState = reactive<Partial<SysSettings>>({
|
||||
public: {
|
||||
registerEnabled: false,
|
||||
},
|
||||
private: {
|
||||
sms: {
|
||||
type: "aliyun",
|
||||
config: {},
|
||||
},
|
||||
},
|
||||
public: {
|
||||
registerEnabled: false,
|
||||
},
|
||||
private: {
|
||||
sms: {
|
||||
type: "aliyun",
|
||||
config: {},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const rules = {
|
||||
leastOneLogin: {
|
||||
validator: (rule: any, value: any) => {
|
||||
if (!formState.public.passwordLoginEnabled && !formState.public.smsLoginEnabled) {
|
||||
return Promise.reject("密码登录和手机号登录至少开启一个");
|
||||
}
|
||||
return Promise.resolve();
|
||||
},
|
||||
},
|
||||
required: {
|
||||
required: true,
|
||||
trigger: "change",
|
||||
message: "此项必填",
|
||||
},
|
||||
leastOneLogin: {
|
||||
validator: (rule: any, value: any) => {
|
||||
if (!formState.public.passwordLoginEnabled && !formState.public.smsLoginEnabled) {
|
||||
return Promise.reject(t('certd.atLeastOneLoginRequired'));
|
||||
}
|
||||
return Promise.resolve();
|
||||
},
|
||||
},
|
||||
required: {
|
||||
required: true,
|
||||
trigger: "change",
|
||||
message: t('certd.fieldRequired'),
|
||||
},
|
||||
};
|
||||
|
||||
async function smsTypeChange(value: string) {
|
||||
if (formState.private?.sms?.config) {
|
||||
formState.private.sms.config = {};
|
||||
}
|
||||
|
||||
await loadTypeDefine(value);
|
||||
async function smsTypeChange(value: string) {
|
||||
if (formState.private?.sms?.config) {
|
||||
formState.private.sms.config = {};
|
||||
}
|
||||
|
||||
await loadTypeDefine(value);
|
||||
}
|
||||
const smsTypeDefineInputs: Ref = ref({});
|
||||
async function loadTypeDefine(type: string) {
|
||||
const define: any = await api.GetSmsTypeDefine(type);
|
||||
const keys = Object.keys(define.input);
|
||||
const inputs: any = {};
|
||||
keys.forEach(key => {
|
||||
const value = define.input[key];
|
||||
value.simpleKey = key;
|
||||
value.key = "private.sms.config." + key;
|
||||
if (!value.component) {
|
||||
value.component = {
|
||||
name: "a-input",
|
||||
};
|
||||
}
|
||||
if (!value.component.name) {
|
||||
value.component.vModel = "value";
|
||||
}
|
||||
if (!value.rules) {
|
||||
value.rules = [];
|
||||
}
|
||||
if (value.required) {
|
||||
value.rules.push(rules.required);
|
||||
}
|
||||
const define: any = await api.GetSmsTypeDefine(type);
|
||||
const keys = Object.keys(define.input);
|
||||
const inputs: any = {};
|
||||
keys.forEach(key => {
|
||||
const value = define.input[key];
|
||||
value.simpleKey = key;
|
||||
value.key = "private.sms.config." + key;
|
||||
if (!value.component) {
|
||||
value.component = {
|
||||
name: "a-input",
|
||||
};
|
||||
}
|
||||
if (!value.component.name) {
|
||||
value.component.vModel = "value";
|
||||
}
|
||||
if (!value.rules) {
|
||||
value.rules = [];
|
||||
}
|
||||
if (value.required) {
|
||||
value.rules.push(rules.required);
|
||||
}
|
||||
|
||||
inputs[key] = define.input[key];
|
||||
});
|
||||
smsTypeDefineInputs.value = inputs;
|
||||
inputs[key] = define.input[key];
|
||||
});
|
||||
smsTypeDefineInputs.value = inputs;
|
||||
}
|
||||
|
||||
async function loadSysSettings() {
|
||||
const data: any = await api.SysSettingsGet();
|
||||
merge(formState, data);
|
||||
if (data?.private.sms?.type) {
|
||||
await loadTypeDefine(data.private.sms.type);
|
||||
}
|
||||
if (!settingsStore.isPlus) {
|
||||
formState.public.userValidTimeEnabled = false;
|
||||
formState.public.emailRegisterEnabled = false;
|
||||
}
|
||||
const data: any = await api.SysSettingsGet();
|
||||
merge(formState, data);
|
||||
if (data?.private.sms?.type) {
|
||||
await loadTypeDefine(data.private.sms.type);
|
||||
}
|
||||
if (!settingsStore.isPlus) {
|
||||
formState.public.userValidTimeEnabled = false;
|
||||
formState.public.emailRegisterEnabled = false;
|
||||
}
|
||||
|
||||
if (!settingsStore.isComm) {
|
||||
formState.public.smsLoginEnabled = false;
|
||||
}
|
||||
if (!settingsStore.isComm) {
|
||||
formState.public.smsLoginEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
const saveLoading = ref(false);
|
||||
loadSysSettings();
|
||||
const settingsStore = useSettingStore();
|
||||
const onFinish = async (form: any) => {
|
||||
try {
|
||||
saveLoading.value = true;
|
||||
await api.SysSettingsSave(form);
|
||||
await settingsStore.loadSysSettings();
|
||||
notification.success({
|
||||
message: "保存成功",
|
||||
});
|
||||
} finally {
|
||||
saveLoading.value = false;
|
||||
}
|
||||
try {
|
||||
saveLoading.value = true;
|
||||
await api.SysSettingsSave(form);
|
||||
await settingsStore.loadSysSettings();
|
||||
notification.success({
|
||||
message: t('certd.saveSuccess'),
|
||||
});
|
||||
} finally {
|
||||
saveLoading.value = false;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style lang="less">
|
||||
.sys-settings-site {
|
||||
}
|
||||
.sys-settings-site {}
|
||||
</style>
|
||||
|
||||
@@ -1,54 +1,63 @@
|
||||
<template>
|
||||
<div class="sys-settings-form sys-settings-safe">
|
||||
<a-form ref="formRef" :model="formState" :label-col="{ span: 8 }" :wrapper-col="{ span: 16 }" autocomplete="off">
|
||||
<h2>站点隐藏</h2>
|
||||
<a-form-item label="启用站点隐藏" :name="['hidden', 'enabled']" :required="true">
|
||||
<div class="flex">
|
||||
<a-switch v-model:checked="formState.hidden.enabled" />
|
||||
</div>
|
||||
<div class="sys-settings-form sys-settings-safe">
|
||||
<a-form ref="formRef" :model="formState" :label-col="{ span: 8 }" :wrapper-col="{ span: 16 }"
|
||||
autocomplete="off">
|
||||
<h2>{{ t('certd.siteHide') }}</h2>
|
||||
<a-form-item :label="t('certd.enableSiteHide')" :name="['hidden', 'enabled']" :required="true">
|
||||
<div class="flex">
|
||||
<a-switch v-model:checked="formState.hidden.enabled" />
|
||||
</div>
|
||||
|
||||
<div class="helper">
|
||||
可以在平时关闭站点的可访问性,需要时再打开,增强站点安全性
|
||||
<a href="https://certd.docmirror.cn/guide/feature/safe/hidden" class="flex items-center" target="_blank">
|
||||
<span>帮助说明</span>
|
||||
<fs-icon class="ml-1" icon="mingcute:question-line"></fs-icon
|
||||
></a>
|
||||
</div>
|
||||
</a-form-item>
|
||||
<a-form-item v-if="formState.hidden.enabled" label="随机地址" :name="['hidden', 'openPath']" :required="true">
|
||||
<a-input-search v-model:value="formState.hidden.openPath" :allow-clear="true" @search="changeOpenPath">
|
||||
<template #enterButton>
|
||||
<fs-icon icon="ion:refresh"></fs-icon>
|
||||
</template>
|
||||
</a-input-search>
|
||||
<div class="helper">站点被隐藏后,需要访问此URL解锁,才能正常访问</div>
|
||||
</a-form-item>
|
||||
<a-form-item v-if="formState.hidden.enabled" label="完整解除隐藏地址" :name="['hidden', 'openPath']" :required="true">
|
||||
<div class="flex"><fs-copyable v-model="openUrl" class="flex-inline"></fs-copyable></div>
|
||||
<div class="helper red">请保存好此地址</div>
|
||||
</a-form-item>
|
||||
<a-form-item v-if="formState.hidden.enabled" label="解除密码" :name="['hidden', 'openPassword']" :required="false">
|
||||
<a-input-password v-model:value="formState.hidden.openPassword" :allow-clear="true" />
|
||||
<div class="helper">解除隐藏时需要输入密码,第一次需要设置密码,填写则重置密码</div>
|
||||
</a-form-item>
|
||||
<a-form-item v-if="formState.hidden.enabled" label="自动隐藏时间" :name="['hidden', 'autoHiddenTimes']" :required="true">
|
||||
<a-input-number v-model:value="formState.hidden.autoHiddenTimes" :allow-clear="true" />
|
||||
<div class="helper">多少分钟内无请求自动隐藏</div>
|
||||
</a-form-item>
|
||||
<a-form-item v-if="formState.hidden.enabled" label="隐藏开放接口" :name="['hidden', 'hiddenOpenApi']" :required="true">
|
||||
<a-switch v-model:checked="formState.hidden.hiddenOpenApi" />
|
||||
<div class="helper">是否隐藏开放接口,是否放开/api/v1开头的接口</div>
|
||||
</a-form-item>
|
||||
<a-form-item v-if="formState.hidden.enabled" label="立即隐藏站点">
|
||||
<loading-button class="ml-1" type="primary" html-type="button" :click="doHiddenImmediate">立即隐藏</loading-button>
|
||||
</a-form-item>
|
||||
<a-form-item label=" " :colon="false" :wrapper-col="{ span: 16 }">
|
||||
<loading-button type="primary" html-type="button" :click="onClick">保存</loading-button>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</div>
|
||||
<div class="helper">
|
||||
{{ t('certd.siteHideDescription') }}
|
||||
<a href="https://certd.docmirror.cn/guide/feature/safe/hidden" class="flex items-center"
|
||||
target="_blank">
|
||||
<span>{{ t('certd.helpDoc') }}</span>
|
||||
<fs-icon class="ml-1" icon="mingcute:question-line"></fs-icon></a>
|
||||
</div>
|
||||
</a-form-item>
|
||||
<a-form-item v-if="formState.hidden.enabled" :label="t('certd.randomAddress')"
|
||||
:name="['hidden', 'openPath']" :required="true">
|
||||
<a-input-search v-model:value="formState.hidden.openPath" :allow-clear="true" @search="changeOpenPath">
|
||||
<template #enterButton>
|
||||
<fs-icon icon="ion:refresh"></fs-icon>
|
||||
</template>
|
||||
</a-input-search>
|
||||
<div class="helper">{{ t('certd.siteHideUrlHelper') }}</div>
|
||||
</a-form-item>
|
||||
<a-form-item v-if="formState.hidden.enabled" :label="t('certd.fullUnlockUrl')"
|
||||
:name="['hidden', 'openPath']" :required="true">
|
||||
<div class="flex"><fs-copyable v-model="openUrl" class="flex-inline"></fs-copyable></div>
|
||||
<div class="helper red">{{ t('certd.saveThisUrl') }}</div>
|
||||
</a-form-item>
|
||||
<a-form-item v-if="formState.hidden.enabled" :label="t('certd.unlockPassword')"
|
||||
:name="['hidden', 'openPassword']" :required="false">
|
||||
<a-input-password v-model:value="formState.hidden.openPassword" :allow-clear="true" />
|
||||
<div class="helper">{{ t('certd.unlockPasswordHelper') }}</div>
|
||||
</a-form-item>
|
||||
<a-form-item v-if="formState.hidden.enabled" :label="t('certd.autoHideTime')"
|
||||
:name="['hidden', 'autoHiddenTimes']" :required="true">
|
||||
<a-input-number v-model:value="formState.hidden.autoHiddenTimes" :allow-clear="true" />
|
||||
<div class="helper">{{ t('certd.autoHideTimeHelper') }}</div>
|
||||
</a-form-item>
|
||||
<a-form-item v-if="formState.hidden.enabled" :label="t('certd.hideOpenApi')"
|
||||
:name="['hidden', 'hiddenOpenApi']" :required="true">
|
||||
<a-switch v-model:checked="formState.hidden.hiddenOpenApi" />
|
||||
<div class="helper">{{ t('certd.hideOpenApiHelper') }}</div>
|
||||
</a-form-item>
|
||||
<a-form-item v-if="formState.hidden.enabled" :label="t('certd.hideSiteImmediately')">
|
||||
<loading-button class="ml-1" type="primary" html-type="button" :click="doHiddenImmediate">{{
|
||||
t('certd.hideImmediately') }}</loading-button>
|
||||
</a-form-item>
|
||||
<a-form-item label=" " :colon="false" :wrapper-col="{ span: 16 }">
|
||||
<loading-button type="primary" html-type="button" :click="onClick">{{ t('certd.save')
|
||||
}}</loading-button>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
<script setup lang="tsx">
|
||||
import { computed, reactive, ref } from "vue";
|
||||
import { merge } from "lodash-es";
|
||||
@@ -56,106 +65,109 @@ import { Modal, notification } from "ant-design-vue";
|
||||
import { request } from "/@/api/service";
|
||||
import { util, utils } from "/@/utils";
|
||||
import { useSettingStore } from "/@/store/settings";
|
||||
import { useI18n } from "vue-i18n";
|
||||
|
||||
const { t } = useI18n();
|
||||
defineOptions({
|
||||
name: "SettingSafe",
|
||||
name: "SettingSafe",
|
||||
});
|
||||
const settingsStore = useSettingStore();
|
||||
const api = {
|
||||
async SettingGet() {
|
||||
return await request({
|
||||
url: "/sys/settings/safe/get",
|
||||
method: "post",
|
||||
});
|
||||
},
|
||||
async SettingSave(data: any) {
|
||||
return await request({
|
||||
url: "/sys/settings/safe/save",
|
||||
method: "post",
|
||||
data,
|
||||
});
|
||||
},
|
||||
async HiddenImmediate() {
|
||||
return await request({
|
||||
url: "/sys/settings/safe/hidden",
|
||||
method: "post",
|
||||
});
|
||||
},
|
||||
async SettingGet() {
|
||||
return await request({
|
||||
url: "/sys/settings/safe/get",
|
||||
method: "post",
|
||||
});
|
||||
},
|
||||
async SettingSave(data: any) {
|
||||
return await request({
|
||||
url: "/sys/settings/safe/save",
|
||||
method: "post",
|
||||
data,
|
||||
});
|
||||
},
|
||||
async HiddenImmediate() {
|
||||
return await request({
|
||||
url: "/sys/settings/safe/hidden",
|
||||
method: "post",
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
const defaultState = {
|
||||
hidden: {
|
||||
enabled: false,
|
||||
autoHiddenTimes: 5,
|
||||
hiddenOpenApi: false,
|
||||
},
|
||||
hidden: {
|
||||
enabled: false,
|
||||
autoHiddenTimes: 5,
|
||||
hiddenOpenApi: false,
|
||||
},
|
||||
};
|
||||
const formRef = ref<any>(defaultState);
|
||||
type SiteHidden = {
|
||||
enabled: boolean;
|
||||
openPath?: string;
|
||||
autoHiddenTimes?: number;
|
||||
openPassword?: string;
|
||||
hiddenOpenApi?: boolean;
|
||||
enabled: boolean;
|
||||
openPath?: string;
|
||||
autoHiddenTimes?: number;
|
||||
openPassword?: string;
|
||||
hiddenOpenApi?: boolean;
|
||||
};
|
||||
|
||||
const formState = reactive<
|
||||
Partial<{
|
||||
hidden: SiteHidden;
|
||||
}>
|
||||
Partial<{
|
||||
hidden: SiteHidden;
|
||||
}>
|
||||
>({
|
||||
hidden: { enabled: false },
|
||||
hidden: { enabled: false },
|
||||
});
|
||||
|
||||
function changeOpenPath() {
|
||||
formState.hidden.openPath = util.randomString(16);
|
||||
formState.hidden.openPath = util.randomString(16);
|
||||
}
|
||||
|
||||
async function loadSettings() {
|
||||
const data: any = await api.SettingGet();
|
||||
merge(formState, defaultState, formState, data);
|
||||
if (!formState.hidden.openPath) {
|
||||
changeOpenPath();
|
||||
}
|
||||
const data: any = await api.SettingGet();
|
||||
merge(formState, defaultState, formState, data);
|
||||
if (!formState.hidden.openPath) {
|
||||
changeOpenPath();
|
||||
}
|
||||
}
|
||||
|
||||
loadSettings();
|
||||
|
||||
const openUrl = computed(() => {
|
||||
const url = new URL(window.location.href);
|
||||
url.pathname = `/api/unhidden/${formState.hidden?.openPath || ""}`;
|
||||
//@ts-ignore
|
||||
url.query = undefined;
|
||||
url.hash = "";
|
||||
return url.href;
|
||||
const url = new URL(window.location.href);
|
||||
url.pathname = `/api/unhidden/${formState.hidden?.openPath || ""}`;
|
||||
//@ts-ignore
|
||||
url.query = undefined;
|
||||
url.hash = "";
|
||||
return url.href;
|
||||
});
|
||||
|
||||
const onClick = async () => {
|
||||
const form = await formRef.value.validateFields();
|
||||
//密码md5
|
||||
// if (form.hidden?.openPassword) {
|
||||
// form.hidden.openPassword = util.hash.md5(form.hidden.openPassword);
|
||||
// }
|
||||
await api.SettingSave(form);
|
||||
await loadSettings();
|
||||
notification.success({
|
||||
message: "保存成功",
|
||||
});
|
||||
const form = await formRef.value.validateFields();
|
||||
//密码md5
|
||||
// if (form.hidden?.openPassword) {
|
||||
// form.hidden.openPassword = util.hash.md5(form.hidden.openPassword);
|
||||
// }
|
||||
await api.SettingSave(form);
|
||||
await loadSettings();
|
||||
notification.success({
|
||||
message: t('certd.saveSuccess'),
|
||||
});
|
||||
};
|
||||
|
||||
async function doHiddenImmediate() {
|
||||
Modal.confirm({
|
||||
title: "确定要立即隐藏站点吗?",
|
||||
content: "隐藏后,将无法访问站点,请谨慎操作",
|
||||
async onOk() {
|
||||
await api.HiddenImmediate();
|
||||
notification.success({
|
||||
message: "站点已隐藏",
|
||||
});
|
||||
},
|
||||
});
|
||||
Modal.confirm({
|
||||
title: t('certd.confirmHideSiteTitle'),
|
||||
content: t('certd.confirmHideSiteContent'),
|
||||
async onOk() {
|
||||
await api.HiddenImmediate();
|
||||
notification.success({
|
||||
message: t('certd.siteHiddenSuccess'),
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
<style lang="less">
|
||||
.sys-settings-base {
|
||||
}
|
||||
.sys-settings-base {}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user