diff --git a/public/ray.svg b/public/ray.svg index daaef75a..d9564578 100644 --- a/public/ray.svg +++ b/public/ray.svg @@ -1,14 +1,7 @@ - - - - - - - - - - - - - - \ No newline at end of file + + + + + + + diff --git a/src/app-components/app/AppShareLink/index.scss b/src/app-components/app/AppShareLink/index.scss index b9498e64..8d91a0b7 100644 --- a/src/app-components/app/AppShareLink/index.scss +++ b/src/app-components/app/AppShareLink/index.scss @@ -38,6 +38,7 @@ } .r-share-links--compact { + container-type: normal; .r-share-links__grid { display: flex; flex-wrap: wrap; diff --git a/src/assets/images/ray.svg b/src/assets/images/ray.svg index daaef75a..d9564578 100644 --- a/src/assets/images/ray.svg +++ b/src/assets/images/ray.svg @@ -1,14 +1,7 @@ - - - - - - - - - - - - - - \ No newline at end of file + + + + + + + diff --git a/src/icons/logo/ray.svg b/src/icons/logo/ray.svg index daaef75a..d9564578 100644 --- a/src/icons/logo/ray.svg +++ b/src/icons/logo/ray.svg @@ -1,14 +1,7 @@ - - - - - - - - - - - - - - \ No newline at end of file + + + + + + + diff --git a/src/locales/lang/en-US/views/login/index.json b/src/locales/lang/en-US/views/login/index.json index e106c672..26423283 100644 --- a/src/locales/lang/en-US/views/login/index.json +++ b/src/locales/lang/en-US/views/login/index.json @@ -1,14 +1,25 @@ { "Register": "Register", - "Signing": "Signing", - "QRCodeSigning": "QRCode Signing", + "Signing": "Sign in", + "QRCodeSigning": "QR code", "NamePlaceholder": "please enter user name", "PasswordPlaceholder": "please enter password", - "Login": "Login", + "Login": "Sign in", "Name": "User Name", "Password": "User Password", "RayTemplate": "Build your next admin dashboard", "TemplateDescription": "Open-source Vue 3 admin dashboard template with TypeScript and Naive UI.", - "OtherSignInOptions": "Other sign-in options", - "Resources": "Resources" + "OtherSignInOptions": "More sign-in examples", + "Resources": "Resources", + "Language": "Change language", + "Stack": "Technology stack", + "Access": "WORKSPACE ACCESS", + "Welcome": "Welcome to Ray Template", + "AccessDescription": "Explore the workspace and component demos using the demo account.", + "UseDemo": "Continue with demo account", + "SignInError": "Sign-in failed. Please try again.", + "RegisterHint": "This registration example is ready to connect to your account service.", + "Provider": "Sign in with {provider}", + "ProviderHint": "The {provider} sign-in option is a demo.", + "QRHint": "Scan to open the Ray Template source code." } diff --git a/src/locales/lang/zh-CN/views/login/index.json b/src/locales/lang/zh-CN/views/login/index.json index e1395ea4..d5ba0407 100644 --- a/src/locales/lang/zh-CN/views/login/index.json +++ b/src/locales/lang/zh-CN/views/login/index.json @@ -1,14 +1,25 @@ { "Register": "注册", "Signing": "登录", - "QRCodeSigning": "扫码登陆", + "QRCodeSigning": "二维码", "NamePlaceholder": "请输入用户名", "PasswordPlaceholder": "请输入密码", - "Login": "登 陆", + "Login": "登录", "Name": "用户名", "Password": "密码", "RayTemplate": "构建你的中后台管理系统", "TemplateDescription": "基于 Vue 3、TypeScript 和 Naive UI 的开源中后台管理模板。", - "OtherSignInOptions": "其他登录方式", - "Resources": "项目资源" + "OtherSignInOptions": "其他登录方式示例", + "Resources": "项目资源", + "Language": "切换语言", + "Stack": "技术栈", + "Access": "工作台入口", + "Welcome": "欢迎使用 Ray Template", + "AccessDescription": "使用演示账号探索工作台与组件示例。", + "UseDemo": "使用演示账号进入", + "SignInError": "登录失败,请重试。", + "RegisterHint": "此页面是注册流程的接入示例,可连接项目的账号服务。", + "Provider": "通过 {provider} 登录", + "ProviderHint": "{provider} 登录是演示入口。", + "QRHint": "扫码访问 Ray Template 源码。" } diff --git a/src/views/login/components/QRCodeSigning/index.scss b/src/views/login/components/QRCodeSigning/index.scss index baac4967..0e728a0d 100644 --- a/src/views/login/components/QRCodeSigning/index.scss +++ b/src/views/login/components/QRCodeSigning/index.scss @@ -1,5 +1,9 @@ .qrcode-signing { - width: 100%; - height: 240px; - @include flexCenter; + display: grid; + justify-items: center; + gap: 12px; + margin: 0; + padding-block: 8px; + color: var(--r-text-secondary); + text-align: center; } diff --git a/src/views/login/components/QRCodeSigning/index.tsx b/src/views/login/components/QRCodeSigning/index.tsx index 58eca0c5..c19af3fb 100644 --- a/src/views/login/components/QRCodeSigning/index.tsx +++ b/src/views/login/components/QRCodeSigning/index.tsx @@ -2,24 +2,18 @@ import './index.scss' import LOGO from '@/assets/images/ray.svg' import { Vue3NextQrcode } from 'vue3-next-qrcode' -const QRCodeSigning = defineComponent({ +export default defineComponent({ name: 'QRCodeSigning', - setup() { - const qrcodeState = reactive({ - qrcodeValue: 'https://github.com/XiaoDaiGua-Ray/xiaodaigua-ray.github.io', - }) - - return { - ...toRefs(qrcodeState), - } - }, render() { return ( -
- -
+
+ +
{this.$t('views.login.index.QRHint')}
+
) }, }) - -export default QRCodeSigning diff --git a/src/views/login/components/Register/index.tsx b/src/views/login/components/Register/index.tsx index f519e4c3..5257aa48 100644 --- a/src/views/login/components/Register/index.tsx +++ b/src/views/login/components/Register/index.tsx @@ -1,12 +1,12 @@ -import { NResult } from 'naive-ui' +import { NAlert } from 'naive-ui' -const Register = defineComponent({ +export default defineComponent({ name: 'RRegister', render() { return ( - + + {this.$t('views.login.index.RegisterHint')} + ) }, }) - -export default Register diff --git a/src/views/login/components/SSOSigning/index.scss b/src/views/login/components/SSOSigning/index.scss deleted file mode 100644 index e1769d67..00000000 --- a/src/views/login/components/SSOSigning/index.scss +++ /dev/null @@ -1,5 +0,0 @@ -.r-template--light { - & .sso-signing { - color: #878787; - } -} diff --git a/src/views/login/components/SSOSigning/index.tsx b/src/views/login/components/SSOSigning/index.tsx index b0b3fc95..14673fe6 100644 --- a/src/views/login/components/SSOSigning/index.tsx +++ b/src/views/login/components/SSOSigning/index.tsx @@ -1,65 +1,43 @@ -import type { IconName } from '@/icons' -import './index.scss' import { RIcon } from '@/components' -import { NFlex, NPopover } from 'naive-ui' +import type { IconName } from '@/icons' +import { NButton, NFlex, NTooltip } from 'naive-ui' -interface SSOSigningOptions { - icon: IconName - key: string - tooltipLabel: string -} +const providers = [ + ['GitHub', 'logo/github'], + ['Google', 'logo/google'], + ['Twitter', 'logo/twitter'], +] as const satisfies ReadonlyArray -const SSOSigning = defineComponent({ +export default defineComponent({ name: 'SSOSigning', - setup() { - const ssoSigningOptions: SSOSigningOptions[] = [ - { - icon: 'logo/github', - key: 'github', - tooltipLabel: 'Github登陆', - }, - { - icon: 'logo/google', - key: 'google', - tooltipLabel: 'Google登陆', - }, - { - icon: 'logo/twitter', - key: 'twitter', - tooltipLabel: 'Twitter登陆', - }, - ] - - const handleSSOSigningClick = (option: SSOSigningOptions) => { - window.$message.info(`调用${option.tooltipLabel}`) - } - - return { - ssoSigningOptions, - handleSSOSigningClick, - } - }, render() { + const { $t } = this + return ( - - {this.ssoSigningOptions.map((curr) => ( - + + {providers.map(([provider, icon]) => ( + {{ trigger: () => ( - + + window.$message.info( + $t('views.login.index.ProviderHint', { provider }), + ) + } + > + + ), - default: () => curr.tooltipLabel, + default: () => $t('views.login.index.Provider', { provider }), }} - + ))} ) }, }) - -export default SSOSigning diff --git a/src/views/login/components/Signing/index.tsx b/src/views/login/components/Signing/index.tsx index 5c9d77c2..48e6d505 100644 --- a/src/views/login/components/Signing/index.tsx +++ b/src/views/login/components/Signing/index.tsx @@ -1,104 +1,125 @@ import { APP_CATCH_KEY } from '@/app-config' import { RForm, useForm } from '@/components' import { useAppRoot, useI18n } from '@/hooks' +import { resolveLandingPath } from '@/router/utils/resolve-landing-path' import { useSigningActions } from '@/store' import { setStorage } from '@/utils' -import { NButton, NForm, NFormItem, NInput } from 'naive-ui' -import type { FormInst } from 'naive-ui' +import { NButton, NFlex, NFormItem, NInput } from 'naive-ui' export default defineComponent({ name: 'RSigning', setup() { const [register, { validate }] = useForm() - - const { t } = useI18n() + const { t } = useI18n('views.login.index') const { signing } = useSigningActions() const { getRootPath } = useAppRoot() - const loading = ref(false) - - const useSigningForm = () => ({ - name: 'Ray Admin', - pwd: '123456', - }) - const router = useRouter() - const signingForm = ref(useSigningForm()) + const loading = ref(false) + const signingForm = reactive({ name: '', pwd: '' }) + const nameId = useId() + const passwordId = useId() - const rules = { + const rules = computed(() => ({ name: { required: true, - message: t('views.login.index.NamePlaceholder'), + message: t('NamePlaceholder'), trigger: ['blur', 'input'], }, pwd: { required: true, - message: t('views.login.index.PasswordPlaceholder'), + message: t('PasswordPlaceholder'), trigger: ['blur', 'input'], }, + })) + + const handleLogin = async (event?: Event) => { + event?.preventDefault() + + if (loading.value) return + + try { + await validate() + } catch { + return + } + + loading.value = true + + try { + const res = await signing(signingForm) + + if (res.code !== 0) throw new Error(res.message) + + setStorage(APP_CATCH_KEY.token, 'tokenValue', 'localStorage') + setStorage(APP_CATCH_KEY.signing, res.data, 'localStorage') + await router.push(resolveLandingPath(router, getRootPath.value)) + } catch { + window.$message.error(t('SignInError')) + } finally { + loading.value = false + } } - /** 普通登陆形式 */ - const handleLogin = () => { - validate().then(() => { - loading.value = true - - signing(signingForm.value) - .then((res) => { - if (res.code === 0) { - setTimeout(() => { - window.$message.success(`欢迎${signingForm.value.name}登陆~`) - - setStorage(APP_CATCH_KEY.token, 'tokenValue', 'localStorage') - setStorage(APP_CATCH_KEY.signing, res.data, 'localStorage') - - router.push(getRootPath.value) - - loading.value = false - }, 2 * 1000) - } - }) - .catch(() => { - window.$message.error('不可以这样哟, 不可以哟') - }) - }) - } - - return { - signingForm, - register, - handleLogin, - rules, - loading, - } - }, - render() { - const { $t, loading, register } = this - - return ( - - + return () => ( + + - + e.key === 'Enter' && this.handleLogin()} + placeholder={t('PasswordPlaceholder')} /> - - {$t('views.login.index.Login')} - + + + {t('Login')} + + { + signingForm.name = 'Ray Admin' + signingForm.pwd = '123456' + void handleLogin() + }} + > + {t('UseDemo')} + + ) }, diff --git a/src/views/login/index.scss b/src/views/login/index.scss index 75202c29..8d4941be 100644 --- a/src/views/login/index.scss +++ b/src/views/login/index.scss @@ -1,147 +1,169 @@ -$positionX: 24px; -$positionY: 24px; - .login { - width: 100%; - display: flex; - overflow: hidden; + min-block-size: 100vh; + min-block-size: 100dvh; + box-sizing: border-box; + display: grid; + grid-template-rows: auto 1fr auto; + gap: clamp(20px, 4vw, 52px); + padding: clamp(16px, 4vw, 54px); + background: var(--r-canvas); + color: var(--r-text); - .login-heading { - margin: 0; - line-height: 1; + &__header, + &__grid, + &__footer { + width: min(100%, 1120px); + margin-inline: auto; + min-width: 0; } - .login-template-description { - margin: 0 0 12px; - font-size: 14px; + &__header, + &__footer, + &__brand, + &__secondary { + display: flex; + align-items: center; + justify-content: space-between; + gap: 12px; + flex-wrap: wrap; } - & .login-wrapper { - position: relative; - flex: auto; + &__brand { + font-size: 16px; + font-weight: 700; + } - &.login-wrapper--divider { - position: relative; + &__grid { + display: grid; + align-self: center; + grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); + border: 1px solid var(--r-line); + border-radius: 20px; + overflow: clip; + background: var(--r-surface); + box-shadow: var(--r-shadow-soft); + } - &::before { - content: ''; - position: absolute; - width: var(--login-height); - height: 2px; - background: - linear-gradient( - 135deg, - transparent, - transparent 75%, - #2080f0, - transparent 80%, - transparent 100% - ), - linear-gradient( - 45deg, - transparent, - transparent 75%, - #2080f0, - transparent 80%, - transparent 100% - ); - background-size: 1em 1em; - background-repeat: repeat-x, repeat-x; - transform: rotate(90deg); - transform-origin: 0; - left: 50%; - } + &__story, + &__panel { + min-width: 0; + padding: clamp(24px, 4vw, 54px); + } + + &__story { + display: flex; + flex-direction: column; + justify-content: space-between; + gap: 44px; + color: #f1f7ff; + background: + radial-gradient(ellipse at 95% 88%, #204c7e, transparent 64%), #132743; + + .login__eyebrow { + color: #9ce7ff; } - & .login-title__wrapper { - position: absolute; - left: $positionX; - top: $positionY; + h1 { + max-width: 14ch; + margin: 18px 0; + font-size: clamp(2rem, 1.2rem + 2.2vw, 3.6rem); + line-height: 1.12; + letter-spacing: -0.035em; + text-wrap: balance; } - & .login-action__wrapper { - position: absolute; - height: 54.4px; - right: $positionX; - top: $positionY; + h1 + p { + max-width: 36ch; + color: #c6d7eb; + line-height: 1.75; + } + } + + &__stack { + display: flex; + flex-wrap: wrap; + gap: 8px; + list-style: none; + padding: 0; + margin: 24px 0 0; + + li { + border: 1px solid #6983a3; + border-radius: 100px; + padding: 5px 12px; + font-size: 12px; + } + } + + &__mark { + align-self: end; + display: grid; + place-items: center; + width: 196px; + aspect-ratio: 1; + border-radius: 50%; + background: repeating-radial-gradient( + circle, + transparent 0 29px, + rgb(156 231 255 / 20%) 30px 31px + ); + } + + &__eyebrow { + font-size: 11px; + line-height: 1.5; + font-weight: 700; + letter-spacing: 0.12em; + color: var(--r-text-secondary); + } + + &__panel-heading { + margin-bottom: 20px; + + h2 { + font-size: clamp(1.5rem, 1.1rem + 1vw, 2rem); + margin-block: 8px; } - & .login-copyright__wrapper { - position: absolute; - width: 100%; - text-align: center; - bottom: $positionY; - font-size: 14px; + h2 + p { + color: var(--r-text-secondary); + line-height: 1.6; + } + } + + &__secondary { + margin-top: 20px; + padding-top: 16px; + border-top: 1px solid var(--r-line); + } + + &__footer, + &__secondary { + color: var(--r-text-secondary); + font-size: 13px; + } +} + +@media (max-width: 760px) { + .login { + &__grid { + grid-template-columns: minmax(0, 1fr); } - & .login-wrapper__content { - width: 100%; - height: 100%; + &__story h1 { + max-width: 24ch; + } - & .login-grid { - display: grid; - grid-template-columns: repeat(2, minmax(0, 1fr)); - block-size: 100%; - } - - & .login__left-wrapper { - display: flex; - flex-direction: column; - justify-content: center; - align-items: center; - transition: background-color 0.3s var(--r-bezier); - } - - & .login__right-wrapper { - @include flexCenter; - - & .login__right-wrapper__content { - width: 50%; - background-color: transparent; - } - } - - @media screen and (max-width: 1200px) { - & .login-grid { - grid-template-columns: minmax(0, 1fr); - } - - & .login__left-wrapper { - display: none; - } - } + &__mark { + display: none; } } } -.r-template--light { - & .login__left-wrapper { - background-color: rgba(32, 128, 240, 0.22); - } - - & .login__right-wrapper { - background-color: #ffffff; - } -} - -.r-template--dark { - & .login__left-wrapper { - background-color: #2c354b; - } - - & .login__right-wrapper { - background-color: #2a3146; - } -} - -@media screen and (min-width: 768px) and (max-width: 992px) { - .login__right-wrapper .login__right-wrapper__content { - width: 55% !important; - } -} - -@media screen and (max-width: 768px) { - .login__right-wrapper .login__right-wrapper__content { - width: 100% !important; +@media (forced-colors: active) { + .login__story, + .login__story .login__eyebrow, + .login__story h1 + p { + color: CanvasText; } } diff --git a/src/views/login/index.tsx b/src/views/login/index.tsx index 0cc90464..5a9b42ae 100644 --- a/src/views/login/index.tsx +++ b/src/views/login/index.tsx @@ -4,158 +4,93 @@ import { LOCAL_OPTIONS } from '@/app-config' import { RIcon } from '@/components' import ThemeSwitch from '@/layout/components/SiderBar/components/SettingDrawer/components/ThemeSwitch' import { useSettingActions } from '@/store' -import { useWindowSize } from '@vueuse/core' -import { - NCard, - NDivider, - NDropdown, - NFlex, - NGradientText, - NTabPane, - NTabs, -} from 'naive-ui' +import { NButton, NDropdown, NFlex, NTabPane, NTabs } from 'naive-ui' import QRCodeSigning from './components/QRCodeSigning' import Register from './components/Register' import Signing from './components/Signing' import SSOSigning from './components/SSOSigning' -const Login = defineComponent({ +export default defineComponent({ name: 'RLogin', setup() { - const { - layout: { copyright }, - } = __APP_CFG__ - - const state = reactive({ - tabsValue: 'signing', - }) - - const { height: windowHeight, width: windowWidth } = useWindowSize() const { updateLocale } = useSettingActions() + const tabsValue = ref('signing') - return { - ...toRefs(state), - windowHeight, - updateLocale, - copyright, - windowWidth, - } + return { updateLocale, tabsValue, copyright: __APP_CFG__.layout.copyright } }, render() { const { $t } = this + const copy = (key: string) => $t(`views.login.index.${key}`) return ( -
-
= 1440 ? 'login-wrapper--divider' : '', - ]} - > -
- - - - +
+ + + + +
) }, }) - -export default Login