This commit is contained in:
仲么了
2024-02-19 13:44:32 +08:00
commit 361cbb713d
238 changed files with 202544 additions and 0 deletions

304
src/views/user/login.vue Normal file
View File

@@ -0,0 +1,304 @@
<template>
<div @keyup.enter="onSubmit(formRef)">
<div @contextmenu.stop="" id="bubble" class="bubble">
<canvas id="bubble-canvas" class="bubble-canvas"></canvas>
</div>
<div class="login-image"></div>
<div class="login-container-form">
<div class="title-container">
<div class="title">
<span style="font-size: 28px">电能质量数据监测云平台</span>
</div>
</div>
<el-form :rules="rules" ref="formRef" size="large" class="login-form" :model="form">
<el-form-item prop="username">
<el-input
ref="usernameRef"
v-model="form.username"
type="text"
clearable
placeholder="用户名"
autocomplete="off"
>
<template #prefix>
<span class="iconfont icon-yonghu" style="color: #003078"></span>
</template>
</el-input>
</el-form-item>
<el-form-item prop="password">
<el-input
ref="passwordRef"
v-model="form.password"
type="password"
placeholder="密码"
autocomplete="off"
>
<template #prefix>
<span class="iconfont icon-mima" style="color: #003078"></span>
</template>
</el-input>
</el-form-item>
<el-form-item>
<el-button
:loading="state.submitLoading"
class="submit-btn"
round
type="info"
@click="onSubmit(formRef)"
>
登录
</el-button>
</el-form-item>
</el-form>
</div>
<div class="copy-right">
<span>版权所有 @ 南京灿能电力自动化股份有限公司</span>
<br />
<img style="width: 20px; height: 20px; position: absolute" src="@/assets/login/jhui.png" />
<span>  苏公网安备 32011502011902</span>
</div>
<PopupUpdatePwd ref="popupUpdatePwdRef"></PopupUpdatePwd>
</div>
</template>
<script setup lang="ts">
import { onMounted, onBeforeUnmount, reactive, ref, nextTick } from 'vue'
import * as pageBubble from '@/utils/pageBubble'
import { ElMessage } from 'element-plus'
import { gongkey, login } from '@/api/user-boot/user'
import { useAdminInfo } from '@/stores/adminInfo'
import type { FormInstance, InputInstance, FormRules } from 'element-plus'
import { useRouter } from 'vue-router'
import { ADMIN_INFO } from '@/stores/constant/cacheKey'
import { Local } from '@/utils/storage'
import PopupUpdatePwd from './popupUpdatePwd.vue'
const router = useRouter()
let timer: number
const popupUpdatePwdRef = ref()
const formRef = ref<FormInstance>()
const usernameRef = ref<InputInstance>()
const passwordRef = ref<InputInstance>()
const userInfo = useAdminInfo()
Local.remove(ADMIN_INFO)
userInfo.removeToken()
interface RuleForm {
username: string
password: string
}
const state = reactive({
showCaptcha: false,
submitLoading: false
})
const form = reactive({
username: '',
password: ''
})
const rules = reactive<FormRules<RuleForm>>({
username: [{ required: true, trigger: 'blur', message: '请输入用户名' }],
password: [{ required: true, trigger: 'blur', message: '请输入密码' }]
})
const focusInput = () => {
if (form.username === '') {
usernameRef.value!.focus()
} else if (form.password === '') {
passwordRef.value!.focus()
}
}
onMounted(() => {
timer = window.setTimeout(() => {
pageBubble.init()
}, 0)
})
onBeforeUnmount(() => {
clearTimeout(timer)
pageBubble.removeListeners()
})
const onSubmit = async (formEl: FormInstance | undefined) => {
if (!formEl) return
await formEl.validate((valid, fields) => {
if (valid) {
state.submitLoading = true
login({
username: form.username,
password: form.password,
grant_type: 'captcha',
imageCode: '',
verifyCode: 0
})
.then(res => {
userInfo.dataFill(res.data)
state.submitLoading = false
router.push({
path: '/'
})
})
.catch(err => {
if (err.code === 'A0101' && err.message === '登录认证,密码失效,请重置') {
popupUpdatePwdRef.value.open(form.username)
}
})
setTimeout(() => {
state.submitLoading = false
}, 500)
}
})
}
</script>
<style scoped lang="scss">
.bubble {
position: relative;
width: 100%;
min-height: 100%;
overflow: hidden;
background-color: #003078 !important;
background-position: center 110px;
background-repeat: repeat;
background-size: 100%;
background-image: url(https://gw.alipayobjects.com/zos/rmsportal/TVYTbAXWheQpRcWDaDMu.svg);
}
.login-image {
position: absolute;
top: 50%;
left: 20%;
min-width: 45%;
min-height: 80%;
background: url('../../assets/login/login2.png') no-repeat center center;
background-size: contain;
transform: translate(-15%, -50%);
// box-shadow: 0 0 0 #011b2bab;
}
.form-item-icon {
height: auto;
}
.login-container-form {
position: absolute;
top: 50%;
left: 85%;
width: 500px;
height: auto;
border-radius: 30px;
transform: translate(-85%, -50%);
box-shadow: 3px 3px 2px 2px #011b2bab;
.title-container {
position: relative;
width: 398px;
max-width: 100%;
padding: 20px 0 0;
margin: 0 auto;
.title {
margin-bottom: 20px;
font-size: 33px;
font-weight: 600;
color: rgba(255, 255, 255, 0.85);
text-align: center;
& :v-deep .svg-icon {
// color: $;
}
.logo {
width: 46px;
height: 46px;
margin-right: 10px;
vertical-align: middle;
}
}
}
}
.login-form {
position: relative;
width: 368px;
max-width: 100%;
//padding: 20px 0 0;
margin: 0 auto;
margin-bottom: 20px;
overflow: hidden;
&.el-input {
input {
height: 40px;
padding-right: 40px;
padding-left: 40px;
line-height: 40px;
border-radius: 5px;
}
.el-input__prefix,
.el-input__suffix {
width: 40px;
line-height: 40px;
.svg-icon {
font-size: 16px;
vertical-align: -0.25em;
}
}
.el-input__prefix {
left: 0;
}
.el-input__suffix {
right: 0;
}
}
}
.copy-right {
position: absolute;
bottom: 10px;
width: 100%;
font-size: 14px;
color: rgb(233, 229, 229);
text-align: center;
}
:v-deep.el-form-item--large {
margin-bottom: 15px;
}
.submit-btn {
width: 100%;
margin-top: 0px;
margin-bottom: 20px;
background: #4d6ea1;
border-radius: 0;
}
@media screen and (max-width: 720px) {
.login {
display: flex;
align-items: center;
justify-content: center;
.login-box {
width: 340px;
margin-top: 0;
}
}
}
@media screen and (max-height: 800px) {
.login .login-box {
margin-bottom: 0;
}
}
</style>

View File

@@ -0,0 +1,213 @@
<template>
<div>
<div @contextmenu.stop='' id='bubble' class='bubble'>
<canvas id='bubble-canvas' class='bubble-canvas'></canvas>
</div>
<div class='login'>
<div class='login-box'>
<div class='head'>
<img src='@/assets/login-header.png' alt='' />
</div>
<div class='form'>
<img class='profile-avatar' src='@/assets/avatar.png' alt='' />
<div class='content'>
<el-form @keyup.enter='onSubmit()' ref='formRef' size='large' :model='form'>
<el-form-item prop='username'>
<el-input
ref='usernameRef'
type='text'
clearable
v-model='form.username'
placeholder='请输入账号'
>
<template #prefix>
<Icon name='fa fa-user' class='form-item-icon' size='16'
color='var(--el-input-icon-color)' />
</template>
</el-input>
</el-form-item>
<el-form-item prop='password'>
<el-input
ref='passwordRef'
v-model='form.password'
type='password'
placeholder='请输入密码'
show-password
>
<template #prefix>
<Icon name='fa fa-unlock-alt' class='form-item-icon' size='16'
color='var(--el-input-icon-color)' />
</template>
</el-input>
</el-form-item>
<el-form-item>
<el-button
:loading='state.submitLoading'
class='submit-button'
round
type='primary'
size='large'
@click='onSubmit()'
>
登录
</el-button>
</el-form-item>
</el-form>
</div>
</div>
</div>
</div>
</div>
</template>
<script setup lang='ts'>
import { onMounted, onBeforeUnmount, reactive, ref, nextTick } from 'vue'
import * as pageBubble from '@/utils/pageBubble'
import type { FormInstance, InputInstance } from 'element-plus'
let timer: number
const formRef = ref<FormInstance>()
const usernameRef = ref<InputInstance>()
const passwordRef = ref<InputInstance>()
const state = reactive({
showCaptcha: false,
submitLoading: false
})
const form = reactive({
username: '',
password: '',
})
const focusInput = () => {
if (form.username === '') {
usernameRef.value!.focus()
} else if (form.password === '') {
passwordRef.value!.focus()
}
}
onMounted(() => {
timer = window.setTimeout(() => {
pageBubble.init()
}, 1000)
})
onBeforeUnmount(() => {
clearTimeout(timer)
pageBubble.removeListeners()
})
const onSubmit = (captchaInfo = '') => {
state.submitLoading = true
setTimeout(() => {
state.submitLoading = false
}, 3000)
}
</script>
<style scoped lang='scss'>
.switch-language {
position: fixed;
top: 20px;
right: 20px;
z-index: 1;
}
.bubble {
overflow: hidden;
background: url(@/assets/bg.jpg) repeat;
}
.form-item-icon {
height: auto;
}
.login {
position: absolute;
top: 0;
display: flex;
width: 100vw;
height: 100vh;
align-items: center;
justify-content: center;
.login-box {
overflow: hidden;
width: 430px;
padding: 0;
background: var(--ba-bg-color-overlay);
margin-bottom: 80px;
}
.head {
background: #ccccff;
img {
display: block;
width: 430px;
margin: 0 auto;
user-select: none;
}
}
.form {
position: relative;
.profile-avatar {
display: block;
position: absolute;
height: 100px;
width: 100px;
border-radius: 50%;
border: 4px solid var(--ba-bg-color-overlay);
top: -50px;
right: calc(50% - 50px);
z-index: 2;
user-select: none;
}
.content {
padding: 100px 40px 40px 40px;
}
.submit-button {
width: 100%;
letter-spacing: 2px;
font-weight: 300;
margin-top: 15px;
--el-button-bg-color: var(--el-color-primary);
}
}
}
@media screen and (max-width: 720px) {
.login {
display: flex;
align-items: center;
justify-content: center;
.login-box {
width: 340px;
margin-top: 0;
}
}
}
.chang-lang :deep(.el-dropdown-menu__item) {
justify-content: center;
}
.content :deep(.el-input__prefix) {
display: flex;
align-items: center;
}
@media screen and (max-height: 800px) {
.login .login-box {
margin-bottom: 0;
}
}
</style>

View File

@@ -0,0 +1,93 @@
<template>
<el-dialog class="cn-operate-dialog" v-model="dialogVisible" :title="title">
<el-scrollbar>
<el-form :inline="false" :model="form" label-width="120px" :rules="rules" ref="formRef">
<el-form-item label="新密码:" prop="newPwd" style="margin-top: 20px">
<el-input v-model="form.newPwd" type="password" placeholder="请输入新密码" show-password />
</el-form-item>
<el-form-item label="确认密码:" prop="confirmPwd" style="margin-top: 20px">
<el-input v-model="form.confirmPwd" type="password" placeholder="请输入确认密码" show-password />
</el-form-item>
</el-form>
</el-scrollbar>
<template #footer>
<span class="dialog-footer">
<el-button @click="dialogVisible = false">取消</el-button>
<el-button type="primary" @click="submit">确认</el-button>
</span>
</template>
</el-dialog>
</template>
<script lang="ts" setup>
import { ref, inject } from 'vue'
import { reactive } from 'vue'
import { ElMessage } from 'element-plus'
import { updateFirstPassword } from '@/api/user-boot/user'
import { validatePwd } from '@/utils/common'
import { useAdminInfo } from '@/stores/adminInfo'
import { useRouter } from 'vue-router'
const dialogVisible = ref(false)
const title = ref('修改默认密码')
const formRef = ref()
// 注意不要和表单ref的命名冲突
const form = reactive({
newPwd: '',
confirmPwd: '',
loginName: ''
})
const rules = {
newPwd: [
{ required: true, message: '请输入密码', trigger: 'blur' },
{
min: 6,
max: 16,
message: '长度在 6 到 16 个字符',
trigger: 'blur'
},
{ validator: validatePwd, trigger: 'blur' }
],
confirmPwd: [
{ required: true, message: '请确认密码', trigger: 'blur' },
{
min: 6,
max: 16,
message: '长度在 6 到 16 个字符',
trigger: 'blur'
},
{
validator: (rule: any, value: string, callback: any) => {
if (value === '') {
callback(new Error('请再次输入密码'))
} else if (value !== form.newPwd) {
callback(new Error('两次输入密码不一致!'))
} else {
callback()
}
},
trigger: 'blur',
required: true
}
]
}
const open = (loginName: string) => {
form.loginName = loginName
dialogVisible.value = true
}
const submit = () => {
formRef.value.validate(async (valid: boolean) => {
if (valid) {
updateFirstPassword({
name: form.loginName,
password: form.confirmPwd
}).then((res: any) => {
dialogVisible.value = false
ElMessage.success('密码修改成功, 请重新登录')
})
}
})
}
defineExpose({ open })
</script>