1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-03-17 03:04:46 +08:00

feat: 登录增加社区软件许可协议同意选项 (#322)

This commit is contained in:
zhengkunwang223 2023-03-20 19:26:27 +08:00 committed by GitHub
parent 0c5a5a6454
commit 8b058a873e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 37 additions and 0 deletions

View File

@ -121,6 +121,9 @@ const message = {
'Note: [Closing the security entrance] will make your panel login address directly exposed to the Internet, very dangerous, please exercise caution', 'Note: [Closing the security entrance] will make your panel login address directly exposed to the Internet, very dangerous, please exercise caution',
codeInput: 'Please enter the 6-digit verification code of the MFA validator', codeInput: 'Please enter the 6-digit verification code of the MFA validator',
title: 'Linux Server Management Panel', title: 'Linux Server Management Panel',
licenseHelper:
'Agree to FIT2CLOUD &laquo; <a href="https://www.fit2cloud.com/legal/licenses.html" target="_blank">Community Software License Agreement</a> &raquo;',
errorAgree: 'Please click to agree to the Community Software License Agreement',
}, },
rule: { rule: {
username: 'Please enter a username', username: 'Please enter a username',

View File

@ -125,6 +125,9 @@ const message = {
codeInput: '请输入 MFA 验证器的 6 位验证码', codeInput: '请输入 MFA 验证器的 6 位验证码',
mfaTitle: 'MFA认证', mfaTitle: 'MFA认证',
title: 'Linux 服务器运维管理面板', title: 'Linux 服务器运维管理面板',
licenseHelper:
'同意 FIT2CLOUD 飞致云 &laquo; <a href="https://www.fit2cloud.com/legal/licenses.html" target="_blank"> 社区软件许可协议</a> &raquo;',
errorAgree: '请点击同意社区软件许可协议',
}, },
rule: { rule: {
username: '请输入用户名', username: '请输入用户名',

View File

@ -20,6 +20,7 @@ export const GlobalStore = defineStore({
footer: true, footer: true,
}, },
isFullScreen: false, isFullScreen: false,
agreeLicense: false,
}), }),
getters: {}, getters: {},
actions: { actions: {
@ -45,6 +46,9 @@ export const GlobalStore = defineStore({
setThemeConfig(themeConfig: ThemeConfigProp) { setThemeConfig(themeConfig: ThemeConfigProp) {
this.themeConfig = themeConfig; this.themeConfig = themeConfig;
}, },
setAgreeLicense(agree: boolean) {
this.agreeLicense = agree;
},
}, },
persist: piniaPersistConfig('GlobalState'), persist: piniaPersistConfig('GlobalState'),
}); });

View File

@ -16,6 +16,7 @@ export interface GlobalState {
// assemblySize: string; // small | default | large // assemblySize: string; // small | default | large
themeConfig: ThemeConfigProp; themeConfig: ThemeConfigProp;
isFullScreen: boolean; isFullScreen: boolean;
agreeLicense: boolean;
} }
export interface MenuState { export interface MenuState {

View File

@ -157,6 +157,20 @@
{{ $t('commons.button.login') }} {{ $t('commons.button.login') }}
</el-button> </el-button>
</el-form-item> </el-form-item>
<el-form-item prop="agreeLicense">
<el-checkbox v-model="loginForm.agreeLicense">
<template #default>
<span v-html="$t('commons.login.licenseHelper')"></span>
</template>
</el-checkbox>
<span
v-if="errAgree && loginForm.agreeLicense === false"
class="input-error"
style="line-height: 14px"
>
{{ $t('commons.login.errorAgree') }}
</span>
</el-form-item>
</el-form> </el-form>
<div class="demo"> <div class="demo">
<span v-if="isDemo"> <span v-if="isDemo">
@ -186,6 +200,7 @@ const errAuthInfo = ref(false);
const errCaptcha = ref(false); const errCaptcha = ref(false);
const errMfaInfo = ref(false); const errMfaInfo = ref(false);
const isDemo = ref(false); const isDemo = ref(false);
const errAgree = ref(false);
const isFirst = ref(); const isFirst = ref();
@ -212,6 +227,7 @@ const loginForm = reactive({
captcha: '', captcha: '',
captchaID: '', captchaID: '',
authMethod: '', authMethod: '',
agreeLicense: false,
}); });
const loginRules = reactive({ const loginRules = reactive({
name: [{ required: true, message: i18n.global.t('commons.rule.username'), trigger: 'blur' }], name: [{ required: true, message: i18n.global.t('commons.rule.username'), trigger: 'blur' }],
@ -259,6 +275,14 @@ const login = (formEl: FormInstance | undefined) => {
captchaID: captcha.captchaID, captchaID: captcha.captchaID,
authMethod: '', authMethod: '',
}; };
if (requestLoginForm.captcha == '') {
errCaptcha.value = true;
return;
}
if (loginForm.agreeLicense == false) {
errAgree.value = true;
return;
}
const res = await loginApi(requestLoginForm); const res = await loginApi(requestLoginForm);
if (res.code === 406) { if (res.code === 406) {
if (res.message === 'ErrCaptchaCode') { if (res.message === 'ErrCaptchaCode') {
@ -280,6 +304,7 @@ const login = (formEl: FormInstance | undefined) => {
return; return;
} }
globalStore.setLogStatus(true); globalStore.setLogStatus(true);
globalStore.setAgreeLicense(true);
menuStore.setMenuList([]); menuStore.setMenuList([]);
MsgSuccess(i18n.global.t('commons.msg.loginSuccess')); MsgSuccess(i18n.global.t('commons.msg.loginSuccess'));
router.push({ name: 'home' }); router.push({ name: 'home' });
@ -335,6 +360,7 @@ function checkPassword(rule: any, value: any, callback: any) {
onMounted(() => { onMounted(() => {
document.title = globalStore.themeConfig.panelName; document.title = globalStore.themeConfig.panelName;
loginForm.agreeLicense = globalStore.agreeLicense;
checkStatus(); checkStatus();
checkIsSystemDemo(); checkIsSystemDemo();
document.onkeydown = (e: any) => { document.onkeydown = (e: any) => {