feat: ssl 设置增加重启提示信息 (#905)

This commit is contained in:
ssongliu 2023-05-06 16:51:34 +08:00 committed by GitHub
parent 2a1e60da44
commit 5a8deddc63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 17 deletions

View File

@ -90,7 +90,7 @@ func GenerateSSL(domain string) error {
pemBytes = append(pemBytes, pem.EncodeToMemory(clientCertBlock)...)
pemBytes = append(pemBytes, pem.EncodeToMemory(interCertBlock)...)
pemBytes = append(pemBytes, pem.EncodeToMemory(rootCertBlock)...)
certOut, err := os.OpenFile(global.CONF.System.BaseDir+"/1panel/secret/server.crt", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600)
certOut, err := os.OpenFile(global.CONF.System.BaseDir+"/1panel/secret/server.crt.tmp", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600)
if err != nil {
return err
}
@ -99,7 +99,7 @@ func GenerateSSL(domain string) error {
return err
}
keyOut, err := os.OpenFile(global.CONF.System.BaseDir+"/1panel/secret/server.key", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600)
keyOut, err := os.OpenFile(global.CONF.System.BaseDir+"/1panel/secret/server.key.tmp", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600)
if err != nil {
return err
}

View File

@ -896,6 +896,7 @@ const message = {
mfaHelper2: 'Scan the following QR code using the mobile app to obtain the 6-digit verification code',
mfaHelper3: 'Enter six digits from the app',
mfaCode: 'Code',
sslChangeHelper: 'Modify the https setting and restart the service. Do you want to continue?',
sslDisable: 'Disable',
sslDisableHelper:
'If the https service is disabled, you need to restart the panel for it to take effect. Do you want to continue?',

View File

@ -931,6 +931,7 @@ const message = {
mfaHelper2: '使用手机应用扫描以下二维码获取 6 位验证码',
mfaHelper3: '输入手机应用上的 6 位数字',
mfaCode: '验证码',
sslChangeHelper: 'https 设置修改需要重启服务是否继续',
sslDisable: '禁用',
sslDisableHelper: '禁用 https 服务需要重启面板才能生效是否继续',

View File

@ -110,7 +110,7 @@ import { MsgSuccess } from '@/utils/message';
import { updateSSL } from '@/api/modules/setting';
import { DownloadByPath } from '@/api/modules/files';
import { Rules } from '@/global/form-rules';
import { FormInstance } from 'element-plus';
import { ElMessageBox, FormInstance } from 'element-plus';
import { Setting } from '@/api/interface/setting';
const loading = ref();
@ -189,21 +189,27 @@ const onSaveSSL = async (formEl: FormInstance | undefined) => {
if (!formEl) return;
formEl.validate(async (valid) => {
if (!valid) return;
let param = {
ssl: 'enable',
sslType: form.sslType,
domain: '',
sslID: form.sslID,
cert: form.cert,
key: form.key,
};
let href = window.location.href;
param.domain = href.split('//')[1].split(':')[0];
await updateSSL(param).then(() => {
MsgSuccess(i18n.global.t('commons.msg.operationSuccess'));
ElMessageBox.confirm(i18n.global.t('setting.sslChangeHelper'), 'https', {
confirmButtonText: i18n.global.t('commons.button.confirm'),
cancelButtonText: i18n.global.t('commons.button.cancel'),
type: 'info',
}).then(async () => {
let param = {
ssl: 'enable',
sslType: form.sslType,
domain: '',
sslID: form.sslID,
cert: form.cert,
key: form.key,
};
let href = window.location.href;
let address = href.split('://')[1];
window.open(`https://${address}/`, '_self');
param.domain = href.split('//')[1].split(':')[0];
await updateSSL(param).then(() => {
MsgSuccess(i18n.global.t('commons.msg.operationSuccess'));
let href = window.location.href;
let address = href.split('://')[1];
window.open(`https://${address}/`, '_self');
});
});
});
};