Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: refactor AuthLayout to configure the login page more freely #4294

Merged
merged 2 commits into from
Aug 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions apps/web-antd/src/layouts/auth.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<script lang="ts" setup>
import { computed } from 'vue';
import { AuthPageLayout } from '@vben/layouts';
import { preferences } from '@vben/preferences';
import { $t } from '#/locales';
const appName = computed(() => preferences.app.name);
const logo = computed(() => preferences.logo.source);
</script>

<template>
<AuthPageLayout
:app-name="appName"
:logo="logo"
:page-description="$t('authentication.pageDesc')"
:page-title="$t('authentication.pageTitle')"
>
<!-- 自定义工具栏 -->
<!-- <template #toolbar></template> -->
</AuthPageLayout>
</template>
4 changes: 1 addition & 3 deletions apps/web-antd/src/layouts/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
const BasicLayout = () => import('./basic.vue');
const AuthPageLayout = () => import('./auth.vue');

const IFrameView = () => import('@vben/layouts').then((m) => m.IFrameView);

const AuthPageLayout = () =>
import('@vben/layouts').then((m) => m.AuthPageLayout);

export { AuthPageLayout, BasicLayout, IFrameView };
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,27 @@ onMounted(() => {
},
trigger: 'axis',
},
// xAxis: {
// axisTick: {
// show: false,
// },
// boundaryGap: false,
// data: Array.from({ length: 18 }).map((_item, index) => `${index + 6}:00`),
// type: 'category',
// },
xAxis: {
axisTick: {
show: false,
},
boundaryGap: false,
data: Array.from({ length: 18 }).map((_item, index) => `${index + 6}:00`),
splitLine: {
lineStyle: {
type: 'solid',
width: 1,
},
show: true,
},
type: 'category',
},
yAxis: [
Expand All @@ -69,7 +84,10 @@ onMounted(() => {
show: false,
},
max: 80_000,

splitArea: {
show: true,
},
splitNumber: 4,
type: 'value',
},
],
Expand Down
23 changes: 23 additions & 0 deletions apps/web-ele/src/layouts/auth.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<script lang="ts" setup>
import { computed } from 'vue';
import { AuthPageLayout } from '@vben/layouts';
import { preferences } from '@vben/preferences';
import { $t } from '#/locales';
const appName = computed(() => preferences.app.name);
const logo = computed(() => preferences.logo.source);
</script>

<template>
<AuthPageLayout
:app-name="appName"
:logo="logo"
:page-description="$t('authentication.pageDesc')"
:page-title="$t('authentication.pageTitle')"
>
<!-- 自定义工具栏 -->
<!-- <template #toolbar></template> -->
</AuthPageLayout>
</template>
4 changes: 1 addition & 3 deletions apps/web-ele/src/layouts/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
const BasicLayout = () => import('./basic.vue');
const AuthPageLayout = () => import('./auth.vue');

const IFrameView = () => import('@vben/layouts').then((m) => m.IFrameView);

const AuthPageLayout = () =>
import('@vben/layouts').then((m) => m.AuthPageLayout);

export { AuthPageLayout, BasicLayout, IFrameView };
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,27 @@ onMounted(() => {
},
trigger: 'axis',
},
// xAxis: {
// axisTick: {
// show: false,
// },
// boundaryGap: false,
// data: Array.from({ length: 18 }).map((_item, index) => `${index + 6}:00`),
// type: 'category',
// },
xAxis: {
axisTick: {
show: false,
},
boundaryGap: false,
data: Array.from({ length: 18 }).map((_item, index) => `${index + 6}:00`),
splitLine: {
lineStyle: {
type: 'solid',
width: 1,
},
show: true,
},
type: 'category',
},
yAxis: [
Expand All @@ -69,7 +84,10 @@ onMounted(() => {
show: false,
},
max: 80_000,

splitArea: {
show: true,
},
splitNumber: 4,
type: 'value',
},
],
Expand Down
23 changes: 23 additions & 0 deletions apps/web-naive/src/layouts/auth.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<script lang="ts" setup>
import { computed } from 'vue';
import { AuthPageLayout } from '@vben/layouts';
import { preferences } from '@vben/preferences';
import { $t } from '#/locales';
const appName = computed(() => preferences.app.name);
const logo = computed(() => preferences.logo.source);
</script>

<template>
<AuthPageLayout
:app-name="appName"
:logo="logo"
:page-description="$t('authentication.pageDesc')"
:page-title="$t('authentication.pageTitle')"
>
<!-- 自定义工具栏 -->
<!-- <template #toolbar></template> -->
</AuthPageLayout>
</template>
4 changes: 1 addition & 3 deletions apps/web-naive/src/layouts/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
const BasicLayout = () => import('./basic.vue');
const AuthPageLayout = () => import('./auth.vue');

const IFrameView = () => import('@vben/layouts').then((m) => m.IFrameView);

const AuthPageLayout = () =>
import('@vben/layouts').then((m) => m.AuthPageLayout);

export { AuthPageLayout, BasicLayout, IFrameView };
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,27 @@ onMounted(() => {
},
trigger: 'axis',
},
// xAxis: {
// axisTick: {
// show: false,
// },
// boundaryGap: false,
// data: Array.from({ length: 18 }).map((_item, index) => `${index + 6}:00`),
// type: 'category',
// },
xAxis: {
axisTick: {
show: false,
},
boundaryGap: false,
data: Array.from({ length: 18 }).map((_item, index) => `${index + 6}:00`),
splitLine: {
lineStyle: {
type: 'solid',
width: 1,
},
show: true,
},
type: 'category',
},
yAxis: [
Expand All @@ -69,7 +84,10 @@ onMounted(() => {
show: false,
},
max: 80_000,

splitArea: {
show: true,
},
splitNumber: 4,
type: 'value',
},
],
Expand Down
2 changes: 1 addition & 1 deletion docs/src/en/guide/essentials/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ const defaultPreferences: Preferences = {
theme: {
builtinType: 'default',
colorDestructive: 'hsl(348 100% 61%)',
colorPrimary: 'hsl(231 98% 65%)',
colorPrimary: 'hsl(212 100% 45%)',
colorSuccess: 'hsl(144 57% 58%)',
colorWarning: 'hsl(42 84% 61%)',
mode: 'dark',
Expand Down
2 changes: 1 addition & 1 deletion docs/src/en/guide/in-depth/login.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ You just need to configure the `props` parameter of `AuthPageLayout` in `src/rou
pageTitle: "开箱即用的大型中后台管理系统",
pageDescription: "工程化、高性能、跨组件库的前端模版",
toolbar: true,
toolbarList: () => ['color', 'language', 'layout', 'theme'],
toolbarList: ['color', 'language', 'layout', 'theme'],
}
// ...
},
Expand Down
6 changes: 3 additions & 3 deletions docs/src/en/guide/in-depth/theme.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ You can check the list below to understand all the available variables.

/* Theme Colors */

--primary: 231 98% 65%;
--primary: 212 100% 45%;
--primary-foreground: 0 0% 98%;

/* Used for destructive actions such as <Button variant="destructive"> */
Expand Down Expand Up @@ -264,7 +264,7 @@ export const overridesPreferences = defineOverridesPreferences({
// Error color
colorDestructive: 'hsl(348 100% 61%)',
// Primary color
colorPrimary: 'hsl(231 98% 65%)',
colorPrimary: 'hsl(212 100% 45%)',
// Success color
colorSuccess: 'hsl(144 57% 58%)',
// Warning color
Expand Down Expand Up @@ -351,7 +351,7 @@ type BuiltinThemeType =

/* Theme Colors */

--primary: 231 98% 65%;
--primary: 212 100% 45%;
--primary-foreground: 0 0% 98%;

/* Used for destructive actions such as <Button variant="destructive"> */
Expand Down
2 changes: 1 addition & 1 deletion docs/src/guide/essentials/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ const defaultPreferences: Preferences = {
theme: {
builtinType: 'default',
colorDestructive: 'hsl(348 100% 61%)',
colorPrimary: 'hsl(231 98% 65%)',
colorPrimary: 'hsl(212 100% 45%)',
colorSuccess: 'hsl(144 57% 58%)',
colorWarning: 'hsl(42 84% 61%)',
mode: 'dark',
Expand Down
33 changes: 13 additions & 20 deletions docs/src/guide/in-depth/login.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,21 @@

![login](/guide/login.png)

只需要在应用下的 `src/router/routes/core.ts` 内,配置`AuthPageLayout`的 `props`参数即可:

```ts {4-8}
{
component: AuthPageLayout,
props: {
sloganImage: "xxx/xxx.png",
pageTitle: "开箱即用的大型中后台管理系统",
pageDescription: "工程化、高性能、跨组件库的前端模版",
toolbar: true,
toolbarList: () => ['color', 'language', 'layout', 'theme'],
}
// ...
},
只需要在应用下的 `src/layouts/auth.vue` 内,配置`AuthPageLayout`的 `props`参数即可:

```vue {2-7}
<AuthPageLayout
:copyright="true"
:toolbar="true"
:toolbarList="['color', 'language', 'layout', 'theme']"
:app-name="appName"
:logo="logo"
:page-description="$t('authentication.pageDesc')"
:page-title="$t('authentication.pageTitle')"
>
</AuthPageLayout>
```

::: tip

如果这些配置不能满足你的需求,你可以自行实现登录页面。直接实现自己的 `AuthPageLayout`即可。

:::

## 登录表单调整

如果你想调整登录表单的相关内容,你可以在应用下的 `src/views/_core/authentication/login.vue` 内,配置`AuthenticationLogin` 组件参数即可:
Expand Down
6 changes: 3 additions & 3 deletions docs/src/guide/in-depth/theme.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ css 变量内的颜色,必须使用 `hsl` 格式,如 `0 0% 100%`,不需要

/* 主题颜色 */

--primary: 231 98% 65%;
--primary: 212 100% 45%;
--primary-foreground: 0 0% 98%;

/* Used for destructive actions such as <Button variant="destructive"> */
Expand Down Expand Up @@ -264,7 +264,7 @@ export const overridesPreferences = defineOverridesPreferences({
// 错误色
colorDestructive: 'hsl(348 100% 61%)',
// 主题色
colorPrimary: 'hsl(231 98% 65%)',
colorPrimary: 'hsl(212 100% 45%)',
// 成功色
colorSuccess: 'hsl(144 57% 58%)',
// 警告色
Expand Down Expand Up @@ -351,7 +351,7 @@ type BuiltinThemeType =

/* 主题颜色 */

--primary: 231 98% 65%;
--primary: 212 100% 45%;
--primary-foreground: 0 0% 98%;

/* Used for destructive actions such as <Button variant="destructive"> */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

/* 主题颜色 */

--primary: 231 98% 65%;
--primary: 212 100% 45%;
--primary-foreground: 0 0% 98%;

/* Used for destructive actions such as <Button variant="destructive"> */
Expand Down Expand Up @@ -78,6 +78,7 @@

/* 遮罩颜色 */
--overlay: 0 0% 0% / 45%;
--overlay-light: 0 0% 95% / 45%;

/* 基本文字大小 */
--font-size-base: 16px;
Expand Down
2 changes: 1 addition & 1 deletion packages/@core/preferences/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const defaultPreferences: Preferences = {
theme: {
builtinType: 'default',
colorDestructive: 'hsl(348 100% 61%)',
colorPrimary: 'hsl(231 98% 65%)',
colorPrimary: 'hsl(212 100% 45%)',
colorSuccess: 'hsl(144 57% 58%)',
colorWarning: 'hsl(42 84% 61%)',
mode: 'dark',
Expand Down
4 changes: 2 additions & 2 deletions packages/@core/preferences/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface BuiltinThemePreset {

const BUILT_IN_THEME_PRESETS: BuiltinThemePreset[] = [
{
color: 'hsl(231 98% 65%)',
color: 'hsl(212 100% 45%)',
type: 'default',
},
{
Expand All @@ -25,7 +25,7 @@ const BUILT_IN_THEME_PRESETS: BuiltinThemePreset[] = [
type: 'yellow',
},
{
color: 'hsl(212 100% 45%)',
color: 'hsl(231 98% 65%)',
type: 'sky-blue',
},
{
Expand Down
Loading
Loading