mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-08-26 16:46:19 +08:00
perf: supplement login interface documents and add configuration parameters (#4175)
This commit is contained in:
@@ -6,9 +6,26 @@ import { preferences, usePreferences } from '@vben/preferences';
|
||||
|
||||
import AuthenticationFormView from './form.vue';
|
||||
import SloganIcon from './icons/slogan.vue';
|
||||
import Toolbar from './toolbar.vue';
|
||||
|
||||
interface Props {
|
||||
pageTitle?: string;
|
||||
pageDescription?: string;
|
||||
sloganImage?: string;
|
||||
toolbar?: boolean;
|
||||
toolbarList?: ('color' | 'language' | 'layout' | 'theme')[];
|
||||
}
|
||||
|
||||
defineOptions({ name: 'Authentication' });
|
||||
|
||||
withDefaults(defineProps<Props>(), {
|
||||
pageDescription: '',
|
||||
pageTitle: '',
|
||||
sloganImage: '',
|
||||
toolbar: true,
|
||||
toolbarList: () => ['color', 'language', 'layout', 'theme'],
|
||||
});
|
||||
|
||||
const { authPanelCenter, authPanelLeft, authPanelRight } = usePreferences();
|
||||
const appName = computed(() => preferences.app.name);
|
||||
const logoSource = computed(() => preferences.logo.source);
|
||||
@@ -21,7 +38,11 @@ const logoSource = computed(() => preferences.logo.source);
|
||||
v-if="authPanelLeft"
|
||||
class="min-h-full w-2/5"
|
||||
transition-name="slide-left"
|
||||
/>
|
||||
>
|
||||
<template v-if="toolbar" #toolbar>
|
||||
<Toolbar :toolbar-list="toolbarList" />
|
||||
</template>
|
||||
</AuthenticationFormView>
|
||||
|
||||
<!-- 头部 Logo 和应用名称 -->
|
||||
<div class="absolute left-0 top-0 z-10 flex flex-1">
|
||||
@@ -41,12 +62,19 @@ const logoSource = computed(() => preferences.logo.source);
|
||||
<div class="absolute inset-0 h-full w-full bg-[#070709]">
|
||||
<div class="login-background absolute left-0 top-0 size-full"></div>
|
||||
<div class="flex-col-center -enter-x mr-20 h-full">
|
||||
<SloganIcon :alt="appName" class="animate-float h-64 w-2/5" />
|
||||
<template v-if="sloganImage">
|
||||
<img
|
||||
:alt="appName"
|
||||
:src="sloganImage"
|
||||
class="animate-float h-64 w-2/5"
|
||||
/>
|
||||
</template>
|
||||
<SloganIcon v-else :alt="appName" class="animate-float h-64 w-2/5" />
|
||||
<div class="text-1xl mt-6 font-sans text-white lg:text-2xl">
|
||||
{{ $t('authentication.pageTitle') }}
|
||||
{{ pageTitle || $t('authentication.pageTitle') }}
|
||||
</div>
|
||||
<div class="dark:text-muted-foreground mt-2 text-white/60">
|
||||
{{ $t('authentication.pageDesc') }}
|
||||
{{ pageDescription || $t('authentication.pageDesc') }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -57,14 +85,22 @@ const logoSource = computed(() => preferences.logo.source);
|
||||
<div class="login-background absolute left-0 top-0 size-full"></div>
|
||||
<AuthenticationFormView
|
||||
class="md:bg-background shadow-primary/10 w-full rounded-3xl pb-20 shadow-2xl md:w-2/3 lg:w-1/2 xl:w-[36%]"
|
||||
/>
|
||||
>
|
||||
<template v-if="toolbar" #toolbar>
|
||||
<Toolbar :toolbar-list="toolbarList" />
|
||||
</template>
|
||||
</AuthenticationFormView>
|
||||
</div>
|
||||
|
||||
<!-- 右侧认证面板 -->
|
||||
<AuthenticationFormView
|
||||
v-if="authPanelRight"
|
||||
class="min-h-full w-2/5 flex-1"
|
||||
/>
|
||||
>
|
||||
<template v-if="toolbar" #toolbar>
|
||||
<Toolbar :toolbar-list="toolbarList" />
|
||||
</template>
|
||||
</AuthenticationFormView>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
@@ -2,7 +2,6 @@
|
||||
import { preferences } from '@vben/preferences';
|
||||
|
||||
import { Copyright } from '../basic/copyright';
|
||||
import Toolbar from './toolbar.vue';
|
||||
|
||||
defineOptions({
|
||||
name: 'AuthenticationFormView',
|
||||
@@ -14,9 +13,7 @@ defineOptions({
|
||||
class="flex-col-center bg-background-deep relative px-6 py-10 lg:flex-initial lg:px-8"
|
||||
>
|
||||
<!-- Toolbar Slot -->
|
||||
<slot name="toolbar">
|
||||
<Toolbar />
|
||||
</slot>
|
||||
<slot name="toolbar"> </slot>
|
||||
|
||||
<!-- Router View with Transition and KeepAlive -->
|
||||
<RouterView v-slot="{ Component, route }">
|
||||
|
@@ -1,4 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
|
||||
import {
|
||||
AuthenticationColorToggle,
|
||||
AuthenticationLayoutToggle,
|
||||
@@ -6,22 +8,39 @@ import {
|
||||
ThemeToggle,
|
||||
} from '../widgets';
|
||||
|
||||
interface Props {
|
||||
toolbarList?: ('color' | 'language' | 'layout' | 'theme')[];
|
||||
}
|
||||
|
||||
defineOptions({
|
||||
name: 'AuthenticationToolbar',
|
||||
});
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
toolbarList: () => ['color', 'language', 'layout', 'theme'],
|
||||
});
|
||||
|
||||
const showColor = computed(() => props.toolbarList.includes('color'));
|
||||
const showLayout = computed(() => props.toolbarList.includes('layout'));
|
||||
const showLanguage = computed(() => props.toolbarList.includes('language'));
|
||||
const showTheme = computed(() => props.toolbarList.includes('theme'));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
class="flex-center bg-background dark:bg-accent absolute right-2 top-4 rounded-3xl px-3 py-1"
|
||||
:class="{
|
||||
'bg-background dark:bg-accent rounded-3xl px-3 py-1':
|
||||
toolbarList.length > 1,
|
||||
}"
|
||||
class="flex-center absolute right-2 top-4"
|
||||
>
|
||||
<!-- Only show on medium and larger screens -->
|
||||
<div class="hidden md:flex">
|
||||
<AuthenticationColorToggle />
|
||||
<AuthenticationLayoutToggle />
|
||||
<AuthenticationColorToggle v-if="showColor" />
|
||||
<AuthenticationLayoutToggle v-if="showLayout" />
|
||||
</div>
|
||||
<!-- Always show Language and Theme toggles -->
|
||||
<LanguageToggle />
|
||||
<ThemeToggle />
|
||||
<LanguageToggle v-if="showLanguage" />
|
||||
<ThemeToggle v-if="showTheme" />
|
||||
</div>
|
||||
</template>
|
||||
|
@@ -139,7 +139,7 @@ watch(
|
||||
async (val) => {
|
||||
if (val) {
|
||||
await updateWatermark({
|
||||
content: `${preferences.app.name} 用户名: ${userStore.userInfo?.username}`,
|
||||
content: `${userStore.userInfo?.username}`,
|
||||
});
|
||||
}
|
||||
},
|
||||
|
@@ -1,50 +0,0 @@
|
||||
import { ref } from 'vue';
|
||||
|
||||
type El = HTMLElement | null | undefined;
|
||||
|
||||
export function useTabViewScroll(scrollDistance: number = 150) {
|
||||
const scrollbarEl = ref<El>(null);
|
||||
const scrollViewportEl = ref<El>(null);
|
||||
|
||||
function setScrollBarEl(el: El) {
|
||||
scrollbarEl.value = el;
|
||||
}
|
||||
|
||||
function setScrollViewEl(el: El) {
|
||||
scrollViewportEl.value = el;
|
||||
}
|
||||
|
||||
function getScrollClientWidth() {
|
||||
if (!scrollbarEl.value || !scrollViewportEl.value) return {};
|
||||
|
||||
const scrollbarWidth = scrollbarEl.value.clientWidth;
|
||||
const scrollViewWidth = scrollViewportEl.value.clientWidth;
|
||||
|
||||
return {
|
||||
scrollbarWidth,
|
||||
scrollViewWidth,
|
||||
};
|
||||
}
|
||||
|
||||
function scrollDirection(
|
||||
direction: 'left' | 'right',
|
||||
distance: number = scrollDistance,
|
||||
) {
|
||||
const { scrollbarWidth, scrollViewWidth } = getScrollClientWidth();
|
||||
|
||||
if (!scrollbarWidth || !scrollViewWidth) return;
|
||||
|
||||
if (scrollbarWidth > scrollViewWidth) return;
|
||||
|
||||
scrollViewportEl.value?.scrollBy({
|
||||
behavior: 'smooth',
|
||||
left: direction === 'left' ? -distance : +distance,
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
scrollDirection,
|
||||
setScrollBarEl,
|
||||
setScrollViewEl,
|
||||
};
|
||||
}
|
@@ -1,6 +1,3 @@
|
||||
<script lang="ts" setup>
|
||||
defineOptions({ name: 'IFrameView' });
|
||||
</script>
|
||||
<template>
|
||||
<div></div>
|
||||
</template>
|
||||
|
Reference in New Issue
Block a user