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

fix: 解决登录页跳转错误的问题 (#4470)

This commit is contained in:
ssongliu 2024-04-11 15:53:22 +08:00 committed by GitHub
parent 34498392dc
commit e037b69f52
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 120 additions and 98 deletions

View File

@ -1396,8 +1396,10 @@ const message = {
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?',
noAuthSetting: 'Unauthorized Setting', noAuthSetting: 'Unauthorized Setting',
noAuthSettingHelper:
'When the user is not logged in and has not correctly entered the security gateway, authorized IP, or bound domain, this response can hide panel features.',
responseSetting: 'Response Setting', responseSetting: 'Response Setting',
help200: '200 - Help Page', help200: 'Help Page',
error400: 'Bad Request', error400: 'Bad Request',
error401: 'Unauthorized', error401: 'Unauthorized',
error403: 'Forbidden', error403: 'Forbidden',

View File

@ -1343,8 +1343,9 @@ const message = {
sslDisable: '禁用', sslDisable: '禁用',
sslDisableHelper: '禁用 https 服務需要重啟面板才能生效是否繼續', sslDisableHelper: '禁用 https 服務需要重啟面板才能生效是否繼續',
noAuthSetting: '未认证设置', noAuthSetting: '未认证设置',
noAuthSettingHelper: '當用戶未登錄且未正確輸入安全入口授權 IP 或綁定域名時此回應可以隱藏面板特徵',
responseSetting: '响应设置', responseSetting: '响应设置',
help200: '200 - 幫助頁面', help200: '幫助頁面',
error400: '錯誤請求', error400: '錯誤請求',
error401: '未授權', error401: '未授權',
error403: '禁止訪問', error403: '禁止訪問',

View File

@ -1344,8 +1344,9 @@ const message = {
sslDisable: '禁用', sslDisable: '禁用',
sslDisableHelper: '禁用 https 服务需要重启面板才能生效是否继续', sslDisableHelper: '禁用 https 服务需要重启面板才能生效是否继续',
noAuthSetting: '未认证设置', noAuthSetting: '未认证设置',
noAuthSettingHelper: '用户在未登录且未正确输入安全入口授权 IP或绑定域名时该响应可隐藏面板特征',
responseSetting: '响应设置', responseSetting: '响应设置',
help200: '200 - 帮助页面', help200: '帮助页面',
error400: '错误请求', error400: '错误请求',
error401: '未授权', error401: '未授权',
error403: '禁止访问', error403: '禁止访问',

View File

@ -326,6 +326,7 @@ const acceptParams = (current: Dashboard.CurrentInfo, base: Dashboard.BaseInfo,
data: formatNumber(currentInfo.value.diskData[i].usedPercent), data: formatNumber(currentInfo.value.diskData[i].usedPercent),
}; };
} }
currentInfo.value.gpuData = currentInfo.value.gpuData || [];
for (let i = 0; i < currentInfo.value.gpuData.length; i++) { for (let i = 0; i < currentInfo.value.gpuData.length; i++) {
chartsOption.value['gpu' + i] = { chartsOption.value['gpu' + i] = {
title: 'GPU-' + currentInfo.value.gpuData[i].index, title: 'GPU-' + currentInfo.value.gpuData[i].index,

View File

@ -1,33 +1,41 @@
<template> <template>
<div> <div>
<div class="login-background" v-if="isSafety && !isErr && !isNotFound"> <div v-if="!loading">
<div class="login-wrapper"> <div class="login-background" v-if="errStatus === ''">
<div :class="screenWidth > 1110 ? 'left inline-block' : ''"> <div class="login-wrapper">
<div class="login-title"> <div :class="screenWidth > 1110 ? 'left inline-block' : ''">
<span>{{ globalStore.themeConfig.title || $t('setting.description') }}</span> <div class="login-title">
<span>{{ globalStore.themeConfig.title || $t('setting.description') }}</span>
</div>
<img src="@/assets/images/1panel-login.png" alt="" v-if="screenWidth > 1110" />
</div> </div>
<img src="@/assets/images/1panel-login.png" alt="" v-if="screenWidth > 1110" /> <div :class="screenWidth > 1110 ? 'right inline-block' : ''">
</div> <div class="login-container">
<div :class="screenWidth > 1110 ? 'right inline-block' : ''"> <LoginForm ref="loginRef"></LoginForm>
<div class="login-container"> </div>
<LoginForm ref="loginRef"></LoginForm>
</div> </div>
</div> </div>
</div> </div>
</div>
<div v-if="pageCode === '200' || !pageCode"> <div v-else>
<UnSafe /> <div v-if="!pageCode || pageCode === '200'">
</div> <div v-if="errStatus === 'err-unsafe'">
<UnSafe />
<div v-if="pageCode !== '200' && pageCode"> </div>
<ErrCode :code="pageCode" /> <div v-if="errStatus === 'err-ip'">
</div> <ErrIP />
<div v-if="isErr && mySafetyCode.code === 'err-ip' && !isNotFound"> </div>
<ErrIP /> <div v-if="errStatus === 'err-domain'">
</div> <ErrDomain />
<div v-if="isErr && mySafetyCode.code === 'err-domain' && !isNotFound"> </div>
<ErrDomain /> <div v-if="errStatus === 'not-found'">
<ErrFound />
</div>
</div>
<div v-else>
<ErrCode :code="pageCode" />
</div>
</div>
</div> </div>
</div> </div>
</template> </template>
@ -39,16 +47,15 @@ import UnSafe from '@/components/error-message/unsafe.vue';
import ErrIP from '@/components/error-message/err_ip.vue'; import ErrIP from '@/components/error-message/err_ip.vue';
import ErrCode from '@/components/error-message/error_code.vue'; import ErrCode from '@/components/error-message/error_code.vue';
import ErrDomain from '@/components/error-message/err_domain.vue'; import ErrDomain from '@/components/error-message/err_domain.vue';
import ErrFound from '@/components/error-message/404.vue';
import { ref, onMounted } from 'vue'; import { ref, onMounted } from 'vue';
import { GlobalStore } from '@/store'; import { GlobalStore } from '@/store';
const globalStore = GlobalStore(); const globalStore = GlobalStore();
const isSafety = ref(true);
const screenWidth = ref(null); const screenWidth = ref(null);
const isErr = ref(); const errStatus = ref();
const isNotFound = ref(); const pageCode = ref('');
const loading = ref();
const pageCode = ref();
const mySafetyCode = defineProps({ const mySafetyCode = defineProps({
code: { code: {
@ -59,32 +66,45 @@ const mySafetyCode = defineProps({
}); });
const getStatus = async () => { const getStatus = async () => {
isErr.value = true;
let code = mySafetyCode.code; let code = mySafetyCode.code;
if (code === 'err-ip' || code === 'err-domain') { loading.value = true;
code = globalStore.entrance; await getResponsePage()
} .then(async (res) => {
const res = await checkIsSafety(code); pageCode.value = res.data;
isErr.value = false; if (code === 'err-ip' || code === 'err-domain') {
globalStore.entrance = ''; errStatus.value = code;
if (res.data === 'disable') { loading.value = false;
if (code === '') { return;
isNotFound.value = false; }
} else { await checkIsSafety(code)
isNotFound.value = true; .then((safeRes) => {
} if (safeRes.data === 'disable') {
return; if (code !== '') {
} errStatus.value = 'not-found';
isNotFound.value = false; loading.value = false;
if (res.data !== 'pass') { return;
const resCode = await getResponsePage(); }
pageCode.value = resCode.data; }
isSafety.value = false; if (safeRes.data === 'pass') {
return; globalStore.entrance = code;
} errStatus.value = '';
if (res.data === 'pass') { loading.value = false;
globalStore.entrance = code; return;
} }
loading.value = false;
errStatus.value = 'err-unsafe';
})
.catch(() => {
pageCode.value = '200';
errStatus.value = 'err-unsafe';
loading.value = false;
});
})
.catch(() => {
pageCode.value = '200';
errStatus.value = 'err-found';
loading.value = false;
});
}; };
onMounted(() => { onMounted(() => {

View File

@ -223,40 +223,9 @@ const form = reactive({
mfaInterval: 30, mfaInterval: 30,
allowIPs: '', allowIPs: '',
bindDomain: '', bindDomain: '',
noAuthSetting: i18n.global.t('setting.help200'), noAuthSetting: '200 - ' + i18n.global.t('setting.help200'),
}); });
const noAuthOptions = [
{
value: '200',
label: i18n.global.t('setting.help200'),
},
{
value: '400',
label: '400 - ' + i18n.global.t('setting.error400'),
},
{
value: '401',
label: '401 - ' + i18n.global.t('setting.error401'),
},
{
value: '403',
label: '403 - ' + i18n.global.t('setting.error403'),
},
{
value: '404',
label: '404 - ' + i18n.global.t('setting.error404'),
},
{
value: '408',
label: '408 - ' + i18n.global.t('setting.error408'),
},
{
value: '416',
label: '416 - ' + i18n.global.t('setting.error416'),
},
];
const unset = ref(i18n.global.t('setting.unSetting')); const unset = ref(i18n.global.t('setting.unSetting'));
const search = async () => { const search = async () => {
@ -277,11 +246,10 @@ const search = async () => {
form.mfaInterval = Number(res.data.mfaInterval); form.mfaInterval = Number(res.data.mfaInterval);
form.allowIPs = res.data.allowIPs.replaceAll(',', '\n'); form.allowIPs = res.data.allowIPs.replaceAll(',', '\n');
form.bindDomain = res.data.bindDomain; form.bindDomain = res.data.bindDomain;
if (res.data.noAuthSetting !== '200') {
for (const item of noAuthOptions) { form.noAuthSetting = res.data.noAuthSetting + ' - ' + i18n.global.t('setting.error' + res.data.noAuthSetting);
if (item.value === res.data.noAuthSetting) { } else {
form.noAuthSetting = item.label; form.noAuthSetting = res.data.noAuthSetting + ' - ' + i18n.global.t('setting.help200');
}
} }
}; };
@ -329,7 +297,7 @@ const onChangeBind = () => {
bindRef.value.acceptParams({ ipv6: form.ipv6, bindAddress: form.bindAddress }); bindRef.value.acceptParams({ ipv6: form.ipv6, bindAddress: form.bindAddress });
}; };
const onChangeResponse = () => { const onChangeResponse = () => {
responseRef.value.acceptParams({ noAuthSetting: form.noAuthSetting, noAuthOptions: noAuthOptions }); responseRef.value.acceptParams({ noAuthSetting: form.noAuthSetting });
}; };
const onChangeBindDomain = () => { const onChangeBindDomain = () => {
domainRef.value.acceptParams({ bindDomain: form.bindDomain }); domainRef.value.acceptParams({ bindDomain: form.bindDomain });

View File

@ -12,14 +12,15 @@
prop="noAuthSetting" prop="noAuthSetting"
:rules="Rules.requiredSelect" :rules="Rules.requiredSelect"
> >
<el-select v-model="form.noAuthSetting" filterable> <el-select v-model="form.noAuthSetting">
<el-option <el-option
v-for="item in options" v-for="item in options"
:key="item" :key="item.value"
:label="item.label" :label="item.label"
:value="item.value" :value="item.value"
/> />
</el-select> </el-select>
<span class="input-help">{{ $t('setting.noAuthSettingHelper') }}</span>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
@ -54,7 +55,36 @@ const form = reactive({
noAuthSetting: '', noAuthSetting: '',
}); });
const options = ref([]); const options = [
{
value: '200',
label: '200 - ' + i18n.global.t('setting.help200'),
},
{
value: '400',
label: '400 - ' + i18n.global.t('setting.error400'),
},
{
value: '401',
label: '401 - ' + i18n.global.t('setting.error401'),
},
{
value: '403',
label: '403 - ' + i18n.global.t('setting.error403'),
},
{
value: '404',
label: '404 - ' + i18n.global.t('setting.error404'),
},
{
value: '408',
label: '408 - ' + i18n.global.t('setting.error408'),
},
{
value: '416',
label: '416 - ' + i18n.global.t('setting.error416'),
},
];
interface DialogProps { interface DialogProps {
noAuthSetting: string; noAuthSetting: string;
@ -62,7 +92,6 @@ interface DialogProps {
} }
const acceptParams = (params: DialogProps): void => { const acceptParams = (params: DialogProps): void => {
options.value = params.noAuthOptions;
form.noAuthSetting = params.noAuthSetting; form.noAuthSetting = params.noAuthSetting;
drawerVisible.value = true; drawerVisible.value = true;
}; };