1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-01-31 22:18:07 +08:00

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(clientCertBlock)...)
pemBytes = append(pemBytes, pem.EncodeToMemory(interCertBlock)...) pemBytes = append(pemBytes, pem.EncodeToMemory(interCertBlock)...)
pemBytes = append(pemBytes, pem.EncodeToMemory(rootCertBlock)...) 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 { if err != nil {
return err return err
} }
@ -99,7 +99,7 @@ func GenerateSSL(domain string) error {
return err 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 { if err != nil {
return err 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', mfaHelper2: 'Scan the following QR code using the mobile app to obtain the 6-digit verification code',
mfaHelper3: 'Enter six digits from the app', mfaHelper3: 'Enter six digits from the app',
mfaCode: 'Code', mfaCode: 'Code',
sslChangeHelper: 'Modify the https setting and restart the service. Do you want to continue?',
sslDisable: 'Disable', sslDisable: 'Disable',
sslDisableHelper: sslDisableHelper:
'If the https service is disabled, you need to restart the panel for it to take effect. Do you want to continue?', '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 位验证码', mfaHelper2: '使用手机应用扫描以下二维码获取 6 位验证码',
mfaHelper3: '输入手机应用上的 6 位数字', mfaHelper3: '输入手机应用上的 6 位数字',
mfaCode: '验证码', mfaCode: '验证码',
sslChangeHelper: 'https 设置修改需要重启服务是否继续',
sslDisable: '禁用', sslDisable: '禁用',
sslDisableHelper: '禁用 https 服务需要重启面板才能生效是否继续', sslDisableHelper: '禁用 https 服务需要重启面板才能生效是否继续',

View File

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