Browse Source

fix: 1

master
zhangli 12 months ago
parent
commit
c2812d15a2
  1. 31
      .env.development
  2. 31
      .env.production
  3. 31
      .env.test
  4. 5468
      package-lock.json
  5. 15
      src/api/path/system.api.ts
  6. 134
      src/views/login/index.vue

31
.env.development

@ -0,0 +1,31 @@
# 开发环境
NODE_ENV=development
VITE_DEV=false
# 请求路径
VITE_BASE_URL='http://localhost:12080'
# 上传路径
VITE_UPLOAD_URL='http://localhost:12080/admin-api/infra/file/upload'
# 接口前缀
VITE_API_BASEPATH=/dev-api
# 接口地址
VITE_API_URL=/admin-api
# 打包路径
VITE_BASE_PATH=/
# 是否删除debugger
VITE_DROP_DEBUGGER=true
# 是否删除console.log
VITE_DROP_CONSOLE=false
# 是否sourcemap
VITE_SOURCEMAP=false
# 输出路径
VITE_OUT_DIR=dist

31
.env.production

@ -0,0 +1,31 @@
# 生产环境
NODE_ENV=production
VITE_DEV=false
# 请求路径
VITE_BASE_URL='http://localhost:12080'
# 上传路径
VITE_UPLOAD_URL='http://localhost:12080/admin-api/infra/file/upload'
# 接口前缀
VITE_API_BASEPATH=
# 接口地址
VITE_API_URL=/admin-api
# 是否删除debugger
VITE_DROP_DEBUGGER=true
# 是否删除console.log
VITE_DROP_CONSOLE=true
# 是否sourcemap
VITE_SOURCEMAP=false
# 打包路径
VITE_BASE_PATH=/
# 输出路径
VITE_OUT_DIR=dist-pro

31
.env.test

@ -0,0 +1,31 @@
# 生产环境
NODE_ENV=test
VITE_DEV=false
# 请求路径
VITE_BASE_URL='http://dev.ccwin-in.com:25100/api'
# 上传路径
VITE_UPLOAD_URL='http://dev.ccwin-in.com:25100/api/admin-api/infra/file/upload'
# 接口前缀
VITE_API_BASEPATH=
# 接口地址
VITE_API_URL=/admin-api
# 是否删除debugger
VITE_DROP_DEBUGGER=true
# 是否删除console.log
VITE_DROP_CONSOLE=true
# 是否sourcemap
VITE_SOURCEMAP=false
# 打包路径
VITE_BASE_PATH=/
# 输出路径
VITE_OUT_DIR=dist-test

5468
package-lock.json

File diff suppressed because it is too large

15
src/api/path/system.api.ts

@ -45,6 +45,21 @@ export const getCodeApi = async (data: any) => {
} }
} }
// 获取验证码
export const getCodeImg = async () => {
// return request.get({
// url: 'system/captcha/captchaImage', headers: {
// isToken: false
// }
// })
try {
const res = await http(RequestHttpEnum.GET)(`${ModuleTypeEnum.SYSTEM}/captcha/captchaImage`)
return res
} catch (err) {
httpErrorHandle()
}
}
// 滑动或者点选验证 // 滑动或者点选验证
export const reqCheckApi = async (data: any) => { export const reqCheckApi = async (data: any) => {
try { try {

134
src/views/login/index.vue

@ -24,18 +24,9 @@
</layout-header> </layout-header>
<div class="go-login"> <div class="go-login">
<div class="go-login-carousel"> <div class="go-login-carousel">
<n-carousel <n-carousel autoplay dot-type="line" :interval="Number(carouselInterval)">
autoplay <img v-for="(item, i) in carouselImgList" :key="i" class="go-login-carousel-img"
dot-type="line" :src="getImageUrl(item, 'login')" alt="image" />
:interval="Number(carouselInterval)"
>
<img
v-for="(item, i) in carouselImgList"
:key="i"
class="go-login-carousel-img"
:src="getImageUrl(item, 'login')"
alt="image"
/>
</n-carousel> </n-carousel>
</div> </div>
<div class="login-account"> <div class="login-account">
@ -43,24 +34,11 @@
<n-collapse-transition :appear="true" :show="show"> <n-collapse-transition :appear="true" :show="show">
<n-card class="login-account-card" :title="$t('login.desc')"> <n-card class="login-account-card" :title="$t('login.desc')">
<div class="login-account-top"> <div class="login-account-top">
<img <img class="login-account-top-logo" src="~@/assets/images/login/input.png" alt="展示图片" />
class="login-account-top-logo"
src="~@/assets/images/login/input.png"
alt="展示图片"
/>
</div> </div>
<n-form <n-form ref="formRef" label-placement="left" size="large" :model="formInline" :rules="rules">
ref="formRef" <n-form-item path="tenantId" v-if="tenantEnable === 'true'">
label-placement="left" <n-input v-model:value="formInline.tenantName" :placeholder="$t('global.form_tenant')">
size="large"
:model="formInline"
:rules="rules"
>
<n-form-item path="tenantId" v-if="tenantEnable ==='true'">
<n-input
v-model:value="formInline.tenantName"
:placeholder="$t('global.form_tenant')"
>
<template #prefix> <template #prefix>
<n-icon size="18"> <n-icon size="18">
<TvOutlineIcon></TvOutlineIcon> <TvOutlineIcon></TvOutlineIcon>
@ -69,10 +47,7 @@
</n-input> </n-input>
</n-form-item> </n-form-item>
<n-form-item path="username"> <n-form-item path="username">
<n-input <n-input v-model:value="formInline.username" :placeholder="$t('global.form_account')">
v-model:value="formInline.username"
:placeholder="$t('global.form_account')"
>
<template #prefix> <template #prefix>
<n-icon size="18"> <n-icon size="18">
<PersonOutlineIcon></PersonOutlineIcon> <PersonOutlineIcon></PersonOutlineIcon>
@ -81,12 +56,8 @@
</n-input> </n-input>
</n-form-item> </n-form-item>
<n-form-item path="password"> <n-form-item path="password">
<n-input <n-input v-model:value="formInline.password" type="password" show-password-on="click"
v-model:value="formInline.password" :placeholder="$t('global.form_password')">
type="password"
show-password-on="click"
:placeholder="$t('global.form_password')"
>
<template #prefix> <template #prefix>
<n-icon size="18"> <n-icon size="18">
<LockClosedOutlineIcon></LockClosedOutlineIcon> <LockClosedOutlineIcon></LockClosedOutlineIcon>
@ -94,6 +65,24 @@
</template> </template>
</n-input> </n-input>
</n-form-item> </n-form-item>
<n-form-item prop="code">
<div class="flex w-[100%]">
<n-input v-model="formInline.code" placeholder="请输入验证码"
style="width: 76%;margin-right: 10px;height: 42px;" :prefix-icon="iconLock"
@keyup.enter="getCode()" >
<template #prefix>
<n-icon size="18">
<LockClosedOutlineIcon></LockClosedOutlineIcon>
</n-icon>
</template>
</n-input>
<div class="login-code flex-1">
<img :src="codeUrl" @click="getCode" class="login-code-img" />
</div>
</div>
</n-form-item>
<n-form-item> <n-form-item>
<div class="flex justify-between"> <div class="flex justify-between">
<div class="flex-initial"> <div class="flex-initial">
@ -104,22 +93,11 @@
</div> </div>
</n-form-item> </n-form-item>
<n-form-item> <n-form-item>
<n-button <n-button type="primary" @click="getCode" size="large" :loading="loading" block>{{
type="primary" $t('login.form_button') }}</n-button>
@click="getCode"
size="large"
:loading="loading"
block
>{{ $t('login.form_button') }}</n-button
>
</n-form-item> </n-form-item>
<Verify <Verify ref="verify" mode="pop" :captchaType="captchaType" :imgSize="{ width: '400px', height: '200px' }"
ref="verify" @success="handleSubmit" />
mode="pop"
:captchaType="captchaType"
:imgSize="{ width: '400px', height: '200px' }"
@success="handleSubmit"
/>
</n-form> </n-form>
</n-card> </n-card>
</n-collapse-transition> </n-collapse-transition>
@ -147,7 +125,7 @@ import { PageEnum } from '@/enums/pageEnum'
import { StorageEnum } from '@/enums/storageEnum' import { StorageEnum } from '@/enums/storageEnum'
import { icon } from '@/plugins' import { icon } from '@/plugins'
import { routerTurnByName } from '@/utils' import { routerTurnByName } from '@/utils'
import {getTenantIdByNameApi, getUserProfileApi, loginApi} from '@/api/path' import { getTenantIdByNameApi, getUserProfileApi, loginApi, getCodeImg } from '@/api/path'
import { Verify } from '@/components/Verifition' import { Verify } from '@/components/Verifition'
interface FormState { interface FormState {
@ -171,7 +149,10 @@ const formInline = reactive({
tenantName: '闻荫源码', tenantName: '闻荫源码',
username: 'admin', username: 'admin',
password: 'admin123', password: 'admin123',
code:'',
uuid:''
}) })
const codeUrl = ref("");
const rules = { const rules = {
username: { username: {
@ -227,15 +208,22 @@ const verify = ref()
const captchaType = ref('blockPuzzle') // blockPuzzle clickWord const captchaType = ref('blockPuzzle') // blockPuzzle clickWord
const captchaEnable = import.meta.env.VITE_APP_CAPTCHA_ENABLE const captchaEnable = import.meta.env.VITE_APP_CAPTCHA_ENABLE
// //
const getCode = async () => { // const getCode = async () => {
// // //
if (captchaEnable === 'false') { // if (captchaEnable === 'false') {
await handleSubmit({}) // await handleSubmit({})
} else { // } else {
// // //
// // //
verify.value.show() // verify.value.show()
} // }
// }
function getCode() {
getCodeImg().then(res => {
codeUrl.value = "data:image/gif;base64," + res.img;
formInline.uuid = res.uuid;
});
} }
// //
@ -253,6 +241,7 @@ const getTenantId = async () => {
} }
} }
// //
const handleSubmit = async (params: any) => { const handleSubmit = async (params: any) => {
formRef.value.validate(async (errors: any) => { formRef.value.validate(async (errors: any) => {
@ -268,7 +257,7 @@ const handleSubmit = async (params: any) => {
password, password,
captchaVerification: params.captchaVerification captchaVerification: params.captchaVerification
}) })
if(loginRes && loginRes.data) { if (loginRes && loginRes.data) {
// Token // Token
const tokenValue = loginRes.data.accessToken const tokenValue = loginRes.data.accessToken
const tokenName = 'Authorization' const tokenName = 'Authorization'
@ -309,7 +298,7 @@ onMounted(() => {
setTimeout(() => { setTimeout(() => {
showBg.value = true showBg.value = true
}, 100) }, 100)
getCode()
shuffleHandle() shuffleHandle()
}) })
</script> </script>
@ -325,10 +314,12 @@ $carousel-image-height: 60vh;
* { * {
box-sizing: border-box; box-sizing: border-box;
} }
@include go(login-box) { @include go(login-box) {
height: $go-login-height; height: $go-login-height;
overflow: hidden; overflow: hidden;
@include background-image('background-image'); @include background-image('background-image');
&-header { &-header {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
@ -336,6 +327,7 @@ $carousel-image-height: 60vh;
padding: 0 40px; padding: 0 40px;
height: $--header-height; height: $--header-height;
} }
&-divider { &-divider {
margin: 0; margin: 0;
padding-top: 0; padding-top: 0;
@ -349,20 +341,24 @@ $carousel-image-height: 60vh;
margin-top: -$--header-height; margin-top: -$--header-height;
height: $go-login-height; height: $go-login-height;
width: 100vw; width: 100vw;
&-carousel { &-carousel {
width: $carousel-width; width: $carousel-width;
margin-top: 100px; margin-top: 100px;
min-width: 500px; min-width: 500px;
&-img { &-img {
display: block; display: block;
margin: 0 auto; margin: 0 auto;
height: $carousel-image-height; height: $carousel-image-height;
} }
} }
.login-account { .login-account {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
margin: 0 160px; margin: 0 160px;
&-container { &-container {
width: $width; width: $width;
} }
@ -398,15 +394,18 @@ $carousel-image-height: 60vh;
width: 100vw; width: 100vw;
height: 100vh; height: 100vh;
background: url('@/assets/images/login/login-bg.png') no-repeat 0 -120px; background: url('@/assets/images/login/login-bg.png') no-repeat 0 -120px;
.bg-slot { .bg-slot {
width: $carousel-width; width: $carousel-width;
} }
.bg-img-box { .bg-img-box {
position: relative; position: relative;
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
width: 770px; width: 770px;
margin-right: -20px; margin-right: -20px;
&-li { &-li {
img { img {
margin-right: 20px; margin-right: 20px;
@ -419,12 +418,15 @@ $carousel-image-height: 60vh;
} }
} }
} }
@media only screen and (max-width: 1200px) { @media only screen and (max-width: 1200px) {
.bg-img-box, .bg-img-box,
.bg-slot, .bg-slot,
.go-login-carousel { .go-login-carousel {
display: none !important; display: none !important;
} }
.go-login-box-footer { .go-login-box-footer {
position: relative; position: relative;
} }

Loading…
Cancel
Save