All checks were successful
Build and Deploy Front / deploy (push) Successful in 6m41s
对齐登录、工作台、H5、官网与充值页的轻压 inset;监控改胶囊 Tab 减闪;充值页去步骤条并收窄布局。 Co-authored-by: Cursor <cursoragent@cursor.com>
305 lines
7.4 KiB
Vue
305 lines
7.4 KiB
Vue
<template>
|
||
<div class="h5-login-page">
|
||
<header class="h5-login-nav">
|
||
<span class="h5-login-nav__spacer" aria-hidden="true" />
|
||
<h1 class="h5-login-nav__title">{{ t('h5Admin.login.title') }}</h1>
|
||
<LoginLangToggle />
|
||
</header>
|
||
|
||
<main class="h5-login-main">
|
||
<section class="h5-login-card">
|
||
<header class="h5-login-card__brand">
|
||
<div class="h5-login-card__brand-row">
|
||
<img :src="logoImg" alt="" class="h5-login-card__logo" />
|
||
<h2 class="h5-login-card__title">{{ t('h5Admin.login.brandName') }}</h2>
|
||
</div>
|
||
<p class="h5-login-card__hint">{{ t('h5Admin.login.brandHint') }}</p>
|
||
</header>
|
||
|
||
<form class="h5-login-form" @submit.prevent="handleSubmit">
|
||
<a-input
|
||
v-model="form.account"
|
||
size="large"
|
||
allow-clear
|
||
class="h5-login-input"
|
||
:placeholder="t('h5Admin.login.accountPlaceholder')"
|
||
autocomplete="username"
|
||
/>
|
||
<a-input-password
|
||
v-model="form.password"
|
||
size="large"
|
||
allow-clear
|
||
class="h5-login-input"
|
||
:placeholder="t('h5Admin.login.passwordPlaceholder')"
|
||
autocomplete="current-password"
|
||
/>
|
||
|
||
<p v-if="errorBox" class="h5-login-error">{{ errorBox }}</p>
|
||
|
||
<a-button
|
||
type="primary"
|
||
html-type="submit"
|
||
long
|
||
size="large"
|
||
class="h5-login-submit"
|
||
:loading="loading"
|
||
>
|
||
{{ loading ? t('h5Admin.login.submitting') : t('h5Admin.login.submit') }}
|
||
</a-button>
|
||
</form>
|
||
</section>
|
||
</main>
|
||
|
||
<H5LoginPortalSwitch target="customer" />
|
||
</div>
|
||
</template>
|
||
|
||
<script lang="ts" setup>
|
||
import { nextTick, onMounted, reactive, ref } from 'vue';
|
||
import { useRoute, useRouter } from 'vue-router';
|
||
import { useI18n } from 'vue-i18n';
|
||
import { Message } from '@arco-design/web-vue';
|
||
import { OmsLoginType } from '@/api/rbac';
|
||
import { isLogin, setToken } from '@/utils/auth';
|
||
import { applyRbacUserToUserStore } from '@/utils/enter-system';
|
||
import { ensureFullLocaleMessages } from '@/locale';
|
||
import { useRbacUserStore } from '@/store/modules/rbac-user';
|
||
import { ADMIN_H5_HOME_PATH, isAdminH5Path } from '@/utils/login-portal';
|
||
import logoImg from '@/assets/logo2.png';
|
||
import LoginLangToggle from '@/views/login/components/LoginLangToggle.vue';
|
||
import H5LoginPortalSwitch from '@/views/h5/components/H5LoginPortalSwitch.vue';
|
||
|
||
defineOptions({ name: 'H5AdminLogin' });
|
||
|
||
const { t } = useI18n();
|
||
const route = useRoute();
|
||
const router = useRouter();
|
||
const rbacUserStore = useRbacUserStore();
|
||
|
||
const form = reactive({ account: '', password: '' });
|
||
const loading = ref(false);
|
||
const errorBox = ref('');
|
||
|
||
function resolveRedirectPath() {
|
||
const redirect = route.query.redirect;
|
||
if (typeof redirect === 'string' && isAdminH5Path(redirect) && redirect !== '/h5/admin/login') {
|
||
return redirect;
|
||
}
|
||
return `${ADMIN_H5_HOME_PATH}/workplace`;
|
||
}
|
||
|
||
async function finishLogin() {
|
||
if (!rbacUserStore.userInfo) return;
|
||
if (rbacUserStore.token) {
|
||
setToken(rbacUserStore.token);
|
||
}
|
||
applyRbacUserToUserStore(rbacUserStore.userInfo, form.account.trim());
|
||
void ensureFullLocaleMessages();
|
||
await nextTick();
|
||
const target = resolveRedirectPath();
|
||
try {
|
||
await router.replace({ path: target, query: {} });
|
||
} catch (navErr) {
|
||
console.error('管理端 H5 登录跳转失败', navErr);
|
||
await router.replace(`${ADMIN_H5_HOME_PATH}/workplace`).catch(() => undefined);
|
||
}
|
||
}
|
||
|
||
async function handleSubmit() {
|
||
if (loading.value) return;
|
||
errorBox.value = '';
|
||
|
||
if (!form.account.trim()) {
|
||
errorBox.value = t('h5Admin.login.accountRequired');
|
||
return;
|
||
}
|
||
if (!form.password) {
|
||
errorBox.value = t('h5Admin.login.passwordRequired');
|
||
return;
|
||
}
|
||
|
||
loading.value = true;
|
||
try {
|
||
const success = await rbacUserStore.login(
|
||
form.account.trim(),
|
||
form.password,
|
||
OmsLoginType.User,
|
||
);
|
||
|
||
if (!success || !rbacUserStore.userInfo) {
|
||
errorBox.value = t('h5Admin.login.failed');
|
||
Message.error(t('h5Admin.login.failed'));
|
||
return;
|
||
}
|
||
|
||
Message.success(t('h5Admin.login.success'));
|
||
await finishLogin();
|
||
} catch (e: any) {
|
||
errorBox.value = e?.message || t('h5Admin.login.failed');
|
||
} finally {
|
||
loading.value = false;
|
||
}
|
||
}
|
||
|
||
onMounted(() => {
|
||
if (isLogin() && rbacUserStore.loginPortalType === OmsLoginType.User) {
|
||
router.replace(resolveRedirectPath());
|
||
}
|
||
});
|
||
</script>
|
||
|
||
<style lang="less" scoped>
|
||
.h5-login-page {
|
||
--login-ease: cubic-bezier(0.22, 1, 0.36, 1);
|
||
box-sizing: border-box;
|
||
min-height: 100vh;
|
||
min-height: 100dvh;
|
||
display: flex;
|
||
flex-direction: column;
|
||
background: var(--app-page-bg, #f0f3f4);
|
||
overflow-x: hidden;
|
||
-webkit-overflow-scrolling: touch;
|
||
}
|
||
|
||
.h5-login-nav {
|
||
position: sticky;
|
||
top: 0;
|
||
z-index: 20;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
height: 48px;
|
||
padding: 0 8px 0 4px;
|
||
background: transparent;
|
||
color: #4e5969;
|
||
}
|
||
|
||
.h5-login-nav__spacer {
|
||
width: 40px;
|
||
height: 40px;
|
||
}
|
||
|
||
.h5-login-nav__title {
|
||
position: absolute;
|
||
width: 1px;
|
||
height: 1px;
|
||
padding: 0;
|
||
margin: -1px;
|
||
overflow: hidden;
|
||
clip: rect(0, 0, 0, 0);
|
||
white-space: nowrap;
|
||
border: 0;
|
||
}
|
||
|
||
.h5-login-main {
|
||
flex: 1;
|
||
width: 100%;
|
||
max-width: 420px;
|
||
margin: 0 auto;
|
||
padding: 20px 16px calc(28px + env(safe-area-inset-bottom, 0px));
|
||
box-sizing: border-box;
|
||
display: flex;
|
||
flex-direction: column;
|
||
justify-content: center;
|
||
}
|
||
|
||
.h5-login-card {
|
||
/* 对齐官网/PC 登录 pressed:白底 + inset 凹陷 */
|
||
background: #ffffff;
|
||
border: none;
|
||
border-radius: 20px;
|
||
padding: 28px 20px 22px;
|
||
box-shadow:
|
||
inset 0 2px 8px rgba(15, 23, 42, 0.07),
|
||
inset 0 1px 1px rgba(15, 23, 42, 0.04);
|
||
backdrop-filter: none;
|
||
-webkit-backdrop-filter: none;
|
||
}
|
||
|
||
.h5-login-card__brand {
|
||
text-align: center;
|
||
margin: 0 0 22px;
|
||
}
|
||
|
||
.h5-login-card__brand-row {
|
||
display: inline-flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
gap: 10px;
|
||
}
|
||
|
||
.h5-login-card__logo {
|
||
display: block;
|
||
width: 36px;
|
||
height: 36px;
|
||
object-fit: contain;
|
||
pointer-events: none;
|
||
user-select: none;
|
||
}
|
||
|
||
.h5-login-card__title {
|
||
margin: 0;
|
||
font-size: 22px;
|
||
font-weight: 700;
|
||
color: #1d2129;
|
||
letter-spacing: 0.04em;
|
||
line-height: 1.2;
|
||
}
|
||
|
||
.h5-login-card__hint {
|
||
margin: 10px 0 0;
|
||
font-size: 13px;
|
||
line-height: 1.45;
|
||
color: #86909c;
|
||
}
|
||
|
||
.h5-login-form {
|
||
display: flex;
|
||
flex-direction: column;
|
||
}
|
||
|
||
.h5-login-input {
|
||
margin-bottom: 12px;
|
||
}
|
||
|
||
.h5-login-form :deep(.arco-input-wrapper),
|
||
.h5-login-form :deep(.arco-input-password) {
|
||
border-radius: 12px;
|
||
background: #f0f3f4;
|
||
border: none;
|
||
min-height: 48px;
|
||
backdrop-filter: none;
|
||
-webkit-backdrop-filter: none;
|
||
box-shadow: inset 0 2px 8px rgba(15, 23, 42, 0.08);
|
||
transition: box-shadow 0.2s ease, background 0.2s ease;
|
||
|
||
&:hover {
|
||
background: #f0f3f4;
|
||
box-shadow: inset 0 3px 10px rgba(15, 23, 42, 0.1);
|
||
}
|
||
|
||
&.arco-input-wrapper-focus,
|
||
&.arco-input-focus {
|
||
background: #f0f3f4;
|
||
border: none;
|
||
box-shadow:
|
||
inset 0 3px 10px rgba(15, 23, 42, 0.1),
|
||
0 0 0 3px color-mix(in srgb, var(--app-primary-color) 12%, transparent);
|
||
}
|
||
}
|
||
|
||
.h5-login-error {
|
||
margin: 0 0 10px;
|
||
font-size: 13px;
|
||
color: #f53f3f;
|
||
}
|
||
|
||
.h5-login-submit {
|
||
margin-top: 4px;
|
||
height: 52px !important;
|
||
border-radius: 12px !important;
|
||
font-size: 16px !important;
|
||
font-weight: 600;
|
||
}
|
||
</style>
|