351 lines
8.7 KiB
Vue
Raw Normal View History

2021-12-10 14:11:49 +08:00
<template>
2022-01-26 15:46:25 +08:00
<!-- 登录 -->
2021-12-14 20:00:20 +08:00
<div class="go-login-box">
2021-12-15 14:25:28 +08:00
<div class="go-login-box-bg">
<aside class="bg-slot"></aside>
<aside class="bg-img-box">
<transition-group name="list-complete">
<template v-for="item in bgList" :key="item">
<div class="bg-img-box-li list-complete-item">
2021-12-18 16:36:43 +08:00
<n-collapse-transition :appear="true" :show="showBg">
2022-02-28 21:15:57 +08:00
<img :src="getImageUrl(item, 'chart/charts')" alt="chart" />
2021-12-15 14:25:28 +08:00
</n-collapse-transition>
</div>
</template>
</transition-group>
</aside>
</div>
2022-03-14 19:52:01 +08:00
<layout-header>
2021-12-16 20:08:05 +08:00
<template #left></template>
<template #right>
2022-04-14 10:05:57 +08:00
<go-lang-select></go-lang-select>
<go-theme-select></go-theme-select>
2021-12-16 20:08:05 +08:00
</template>
2022-03-14 19:52:01 +08:00
</layout-header>
2021-12-14 20:00:20 +08:00
<div class="go-login">
<div class="go-login-carousel">
<n-carousel
autoplay
dot-type="line"
:interval="Number(carouselInterval)"
>
2021-12-14 20:00:20 +08:00
<img
2021-12-15 14:25:28 +08:00
v-for="(item, i) in carouselImgList"
2021-12-14 20:00:20 +08:00
:key="i"
class="go-login-carousel-img"
2021-12-15 14:25:28 +08:00
:src="getImageUrl(item, 'login')"
alt="image"
2021-12-14 20:00:20 +08:00
/>
</n-carousel>
</div>
<div class="login-account">
<div class="login-account-container">
2021-12-14 20:32:22 +08:00
<n-collapse-transition :appear="true" :show="show">
<n-card class="login-account-card" :title="$t('login.desc')">
2021-12-14 20:32:22 +08:00
<div class="login-account-top">
<img
class="login-account-top-logo"
src="~@/assets/images/login/input.png"
alt="展示图片"
/>
2021-12-10 14:11:49 +08:00
</div>
2021-12-14 20:32:22 +08:00
<n-form
ref="formRef"
label-placement="left"
size="large"
:model="formInline"
:rules="rules"
>
<n-form-item path="username">
<n-input
v-model:value="formInline.username"
:placeholder="$t('global.form_account')"
2021-12-14 20:32:22 +08:00
>
<template #prefix>
<n-icon size="18">
<PersonOutlineIcon></PersonOutlineIcon>
2021-12-14 20:32:22 +08:00
</n-icon>
</template>
</n-input>
</n-form-item>
<n-form-item path="password">
<n-input
v-model:value="formInline.password"
type="password"
2022-01-09 19:22:55 +08:00
show-password-on="click"
:placeholder="$t('global.form_password')"
2021-12-14 20:32:22 +08:00
>
<template #prefix>
<n-icon size="18">
<LockClosedOutlineIcon></LockClosedOutlineIcon>
2021-12-14 20:32:22 +08:00
</n-icon>
</template>
</n-input>
</n-form-item>
<n-form-item>
<div class="flex justify-between">
<div class="flex-initial">
<n-checkbox v-model:checked="autoLogin">{{
$t('login.form_auto')
}}</n-checkbox>
2021-12-14 20:32:22 +08:00
</div>
2021-12-14 20:00:20 +08:00
</div>
2021-12-14 20:32:22 +08:00
</n-form-item>
<n-form-item>
<n-button
type="primary"
@click="handleSubmit"
size="large"
:loading="loading"
block
>{{ $t('login.form_button') }}</n-button
>
2021-12-14 20:32:22 +08:00
</n-form-item>
</n-form>
</n-card>
</n-collapse-transition>
</div>
2021-12-10 14:11:49 +08:00
</div>
</div>
2021-12-15 14:25:28 +08:00
2021-12-14 20:32:22 +08:00
<div class="go-login-box-footer">
2022-03-14 19:52:01 +08:00
<layout-footer></layout-footer>
2021-12-14 20:32:22 +08:00
</div>
2021-12-10 14:11:49 +08:00
</div>
</template>
<script lang="ts" setup>
2021-12-14 20:32:22 +08:00
import { reactive, ref, onMounted } from 'vue'
2021-12-15 22:16:16 +08:00
import shuffle from 'lodash/shuffle'
2021-12-15 14:25:28 +08:00
import { carouselInterval } from '@/settings/designSetting'
2021-12-15 22:16:16 +08:00
import { useDesignStore } from '@/store/modules/designStore/designStore'
2022-04-14 10:05:57 +08:00
import { GoThemeSelect } from '@/components/GoThemeSelect'
import { GoLangSelect } from '@/components/GoLangSelect'
2022-03-14 19:52:01 +08:00
import { LayoutHeader } from '@/layout/components/LayoutHeader'
import { LayoutFooter } from '@/layout/components/LayoutFooter'
import { PageEnum } from '@/enums/pageEnum'
import { icon } from '@/plugins'
import { StorageEnum } from '@/enums/storageEnum'
import { routerTurnByName, cryptoEncode, setLocalStorage } from '@/utils'
const { GO_LOGIN_INFO_STORE } = StorageEnum
2022-01-09 19:22:55 +08:00
const { PersonOutlineIcon, LockClosedOutlineIcon } = icon.ionicons5
2021-12-10 14:11:49 +08:00
interface FormState {
username: string
password: string
}
const formRef = ref()
const loading = ref(false)
const autoLogin = ref(true)
2021-12-14 20:32:22 +08:00
const show = ref(false)
2021-12-18 16:36:43 +08:00
const showBg = ref(false)
2021-12-15 22:16:16 +08:00
const designStore = useDesignStore()
2022-01-09 19:22:55 +08:00
2021-12-22 15:31:20 +08:00
const t = window['$t']
2021-12-14 20:32:22 +08:00
onMounted(() => {
setTimeout(() => {
show.value = true
2021-12-18 16:36:43 +08:00
}, 300)
setTimeout(() => {
showBg.value = true
2021-12-14 20:32:22 +08:00
}, 100)
})
2021-12-10 14:11:49 +08:00
const formInline = reactive({
username: 'admin',
password: '123456',
2021-12-10 14:11:49 +08:00
})
const rules = {
username: {
required: true,
message: t('global.form_account'),
trigger: 'blur',
},
password: {
required: true,
message: t('global.form_password'),
trigger: 'blur',
},
2021-12-10 14:11:49 +08:00
}
2021-12-15 14:25:28 +08:00
// 定时器
const shuffleTimiing = ref()
2021-12-14 20:00:20 +08:00
2021-12-15 14:25:28 +08:00
// 轮播图
const carouselImgList = ['one', 'two', 'three']
// 背景图
const bgList = ref([
'bar_y',
'bar_x',
'line_gradient',
'line',
'funnel',
'heatmap',
'map',
'pie',
'radar',
2021-12-15 14:25:28 +08:00
])
// 处理url获取
const getImageUrl = (name: string, folder: string) => {
return new URL(`../../assets/images/${folder}/${name}.png`, import.meta.url).href
2021-12-15 14:25:28 +08:00
}
2021-12-10 14:11:49 +08:00
2021-12-15 14:25:28 +08:00
// 打乱
const shuffleHandle = () => {
shuffleTimiing.value = setInterval(() => {
bgList.value = shuffle(bgList.value)
}, carouselInterval)
}
// 点击事件
2021-12-10 14:11:49 +08:00
const handleSubmit = (e: Event) => {
e.preventDefault()
formRef.value.validate(async (errors: any) => {
if (!errors) {
const { username, password } = formInline
loading.value = true
setLocalStorage(
GO_LOGIN_INFO_STORE,
cryptoEncode(
JSON.stringify({
username,
password,
})
)
)
2022-01-20 21:25:35 +08:00
window['$message'].success(`${t('login.login_success')}!`)
routerTurnByName(PageEnum.BASE_HOME_NAME, true)
2021-12-10 14:11:49 +08:00
} else {
2022-01-20 21:25:35 +08:00
window['$message'].error(`${t('login.login_message')}!`)
2021-12-10 14:11:49 +08:00
}
})
}
2021-12-15 14:25:28 +08:00
onMounted(() => {
shuffleHandle()
})
2021-12-10 14:11:49 +08:00
</script>
<style lang="scss" scoped>
2021-12-14 20:00:20 +08:00
$width: 450px;
2021-12-15 14:25:28 +08:00
$go-login-height: 100vh;
2022-05-04 20:20:09 +08:00
$account-img-height: 210px;
2021-12-14 20:32:22 +08:00
$footer-height: 50px;
2021-12-15 14:25:28 +08:00
$carousel-width: 30%;
$carousel-image-height: 60vh;
2021-12-14 20:32:22 +08:00
* {
box-sizing: border-box;
}
2021-12-14 20:00:20 +08:00
@include go(login-box) {
2021-12-15 14:25:28 +08:00
height: $go-login-height;
2021-12-14 20:00:20 +08:00
overflow: hidden;
@include background-image('background-image');
2021-12-14 20:00:20 +08:00
&-header {
2021-12-15 22:16:16 +08:00
display: flex;
justify-content: space-between;
align-items: center;
padding: 0 40px;
height: $--header-height;
}
&-divider {
margin: 0;
padding-top: 0;
2021-12-14 20:00:20 +08:00
}
2021-12-14 20:32:22 +08:00
2021-12-14 20:00:20 +08:00
@include go(login) {
2021-12-15 14:25:28 +08:00
z-index: 2;
display: flex;
2021-12-15 14:25:28 +08:00
justify-content: space-around;
2021-12-14 20:00:20 +08:00
align-items: center;
margin-top: -$--header-height;
2021-12-15 14:25:28 +08:00
height: $go-login-height;
width: 100vw;
2021-12-14 20:00:20 +08:00
&-carousel {
2021-12-15 14:25:28 +08:00
width: $carousel-width;
margin-top: 100px;
min-width: 500px;
2021-12-14 20:00:20 +08:00
&-img {
2021-12-15 14:25:28 +08:00
display: block;
margin: 0 auto;
height: $carousel-image-height;
}
2021-12-10 14:11:49 +08:00
}
2021-12-14 20:00:20 +08:00
.login-account {
display: flex;
flex-direction: column;
2021-12-15 14:25:28 +08:00
margin: 0 160px;
2021-12-14 20:00:20 +08:00
&-container {
width: $width;
}
2021-12-10 14:11:49 +08:00
2021-12-14 21:28:32 +08:00
&-card {
@extend .go-background-filter;
2022-05-02 17:18:18 +08:00
@include fetch-bg-color('filter-color');
2022-05-04 20:20:09 +08:00
box-shadow: 0 0 20px 5px rgba(40, 40, 40, 0.3);
2021-12-14 21:28:32 +08:00
}
2021-12-14 20:00:20 +08:00
&-top {
2021-12-14 20:32:22 +08:00
padding-top: 10px;
2021-12-14 20:00:20 +08:00
text-align: center;
2021-12-14 20:32:22 +08:00
height: $account-img-height;
margin-bottom: 20px;
}
2021-12-10 14:11:49 +08:00
}
}
2021-12-14 20:32:22 +08:00
&-footer {
2021-12-15 14:25:28 +08:00
z-index: 2;
position: fixed;
width: 100%;
2021-12-17 14:19:55 +08:00
bottom: 0;
2021-12-14 20:32:22 +08:00
}
2021-12-14 21:28:32 +08:00
&-bg {
z-index: 0;
position: fixed;
2021-12-15 14:25:28 +08:00
display: flex;
justify-content: space-around;
align-items: center;
width: 100vw;
2021-12-14 21:28:32 +08:00
height: 100vh;
2022-04-14 10:05:57 +08:00
background: url('../../assets/images/login/login-bg.png') no-repeat 0 -120px;
2021-12-15 22:16:16 +08:00
.bg-slot {
2021-12-15 14:25:28 +08:00
width: $carousel-width;
2021-12-14 20:00:20 +08:00
}
2021-12-15 14:25:28 +08:00
.bg-img-box {
position: relative;
display: flex;
flex-wrap: wrap;
width: 770px;
margin-right: -20px;
&-li {
img {
margin-right: 20px;
margin-top: 20px;
2022-01-15 12:50:00 +08:00
width: 230px;
2021-12-15 14:25:28 +08:00
border-radius: 2 * $--border-radius-base;
opacity: 0.9;
}
}
2021-12-14 20:00:20 +08:00
}
2021-12-10 14:11:49 +08:00
}
}
2021-12-15 14:25:28 +08:00
@media only screen and (max-width: 1200px) {
.bg-img-box,
.bg-slot,
.go-login-carousel {
display: none !important;
}
.go-login-box-footer {
position: relative;
}
}
2021-12-10 14:11:49 +08:00
</style>