feat: 增加登录管理系统
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
||||
IBillRecord,
|
||||
IBillSummaryStats
|
||||
} from '@/types/bill'
|
||||
import { IStatsChart } from 'vue3-common/dist/types'
|
||||
|
||||
export const addBillRecordApi = (billRecord: IBillRecord): Promise<boolean> =>
|
||||
cloudService({
|
||||
@@ -41,7 +42,7 @@ export const queryBillSummaryApi = (query: IBillQuery): Promise<IBillRecord[]> =
|
||||
params: query
|
||||
})
|
||||
|
||||
export const queryBillStatsApi = (type: string, query: IBillQuery): Promise<any> =>
|
||||
export const queryBillStatsApi = (type: string, query: IBillQuery): Promise<IStatsChart[]> =>
|
||||
cloudService({
|
||||
url: `/home-service/bill/stats/${type}`,
|
||||
method: 'get',
|
||||
@@ -73,35 +74,35 @@ export const addBillPayApi = (billPay: IBillPay): Promise<boolean> =>
|
||||
data: billPay
|
||||
})
|
||||
|
||||
export const updateBillPayApi = (id: number, billPay: IBillPay): Promise<any> =>
|
||||
export const updateBillPayApi = (id: number, billPay: IBillPay): Promise<boolean> =>
|
||||
cloudService({
|
||||
url: `/admin-service/bill-manage/pay/${id}`,
|
||||
method: 'put',
|
||||
data: billPay
|
||||
})
|
||||
|
||||
export const addBillBookApi = (billBook: IBillBook): Promise<any> =>
|
||||
export const addBillBookApi = (billBook: IBillBook): Promise<boolean> =>
|
||||
cloudService({
|
||||
url: '/admin-service/bill-manage/book',
|
||||
method: 'post',
|
||||
data: billBook
|
||||
})
|
||||
|
||||
export const updateBillBookApi = (id: number, billBook: IBillBook): Promise<any> =>
|
||||
export const updateBillBookApi = (id: number, billBook: IBillBook): Promise<boolean> =>
|
||||
cloudService({
|
||||
url: `/admin-service/bill-manage/book/${id}`,
|
||||
method: 'put',
|
||||
data: billBook
|
||||
})
|
||||
|
||||
export const addBillCategoryApi = (billCategory: IBillCategory): Promise<any> =>
|
||||
export const addBillCategoryApi = (billCategory: IBillCategory): Promise<boolean> =>
|
||||
cloudService({
|
||||
url: '/admin-service/bill-manage/category',
|
||||
method: 'post',
|
||||
data: billCategory
|
||||
})
|
||||
|
||||
export const updateBillCategoryApi = (id: number, billCategory: IBillCategory): Promise<any> =>
|
||||
export const updateBillCategoryApi = (id: number, billCategory: IBillCategory): Promise<boolean> =>
|
||||
cloudService({
|
||||
url: `/admin-service/bill-manage/category/${id}`,
|
||||
method: 'put',
|
||||
|
||||
@@ -8,3 +8,9 @@ export const loginHomeApi = (name: string, password: string): Promise<ISession>
|
||||
params: { name, password }
|
||||
})
|
||||
|
||||
export const loginAdminApi = (name: string, password: string): Promise<ISession> =>
|
||||
cloudService({
|
||||
url: '/admin-service/session',
|
||||
method: 'post',
|
||||
params: { name, password }
|
||||
})
|
||||
|
||||
@@ -43,7 +43,13 @@
|
||||
<el-button type="primary" style="width: 100%;"
|
||||
:disabled="!authStore.isVerified"
|
||||
:loading="authStore.loginLoading"
|
||||
@click.prevent="handleLogin()">登录
|
||||
@click.prevent="handleLogin('common')">登录
|
||||
</el-button>
|
||||
<div />
|
||||
<el-button type="primary" style="width: 100%;"
|
||||
:disabled="!authStore.isVerified"
|
||||
:loading="authStore.loginLoading"
|
||||
@click.prevent="handleLogin('admin')">登录管理系统
|
||||
</el-button>
|
||||
|
||||
<div class="login-type">
|
||||
@@ -79,6 +85,7 @@ import { onMounted, reactive, ref } from 'vue'
|
||||
import { loginRules } from '@/utils/element/elRules'
|
||||
import { isMobile } from 'vue3-common/utils/layoutUtil'
|
||||
import { getLocalStorage, setLocalStorage } from 'vue3-common/utils/storageUtil'
|
||||
import { ILoginType } from '@/types/auth'
|
||||
|
||||
const rules = reactive<FormRules>(loginRules)
|
||||
const authStore = useAuthStore()
|
||||
@@ -94,13 +101,13 @@ onMounted(() => {
|
||||
}
|
||||
})
|
||||
|
||||
const handleLogin = async () => {
|
||||
const handleLogin = async (type: ILoginType) => {
|
||||
loginFormRef.value.validate(async (valid: any) => {
|
||||
if (valid) {
|
||||
authStore.loginLoading = true
|
||||
|
||||
try {
|
||||
await authStore.handleLogin('common')
|
||||
await authStore.handleLogin(type)
|
||||
userStore.handleSession(authStore.homeSession)
|
||||
|
||||
// 2. 存储账户密码到localStorage中
|
||||
@@ -110,8 +117,10 @@ const handleLogin = async () => {
|
||||
|
||||
if (isMobile()) {
|
||||
await router.push('/mobile-home')
|
||||
} else {
|
||||
} else if (type === 'common') {
|
||||
await router.push('/home')
|
||||
} else {
|
||||
await router.push('/admin')
|
||||
}
|
||||
} finally {
|
||||
authStore.loginLoading = false
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<!-- <img :src="logoInfo.logo" alt="logo">-->
|
||||
</router-link>
|
||||
<router-link v-else key="expand" class="logo" to="/admin/dashboard">
|
||||
<img :src="getAssetsImageFile('logo/vue.png')"
|
||||
<img :src="getAssetsImageFile('logo/logo.png')"
|
||||
alt="logo">
|
||||
</router-link>
|
||||
</transition>
|
||||
|
||||
@@ -37,7 +37,7 @@ const profileClick = () => {
|
||||
|
||||
const logoutClick = () => {
|
||||
commonElMessageBox('请确认是否退出登录?').then(() => {
|
||||
router.push('/login')
|
||||
router.push('/')
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { ILoginType, ISession } from '@/types/auth'
|
||||
import { loginHomeApi } from '@/apis/session'
|
||||
import { loginAdminApi, loginHomeApi } from '@/apis/session'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { emailPattern, phonePattern } from '@/utils/element/elRules'
|
||||
|
||||
@@ -90,6 +90,9 @@ export const useAuthStore = defineStore('auth', {
|
||||
case 'email':
|
||||
this.homeSession = await loginHomeApi(email, emailCode)
|
||||
break
|
||||
case 'admin':
|
||||
this.homeSession = await loginAdminApi(username, password)
|
||||
break
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export type ILoginType = 'common' | 'phone' | 'email'
|
||||
export type ILoginType = 'common' | 'phone' | 'email' | 'admin'
|
||||
|
||||
export type IAccountType = 'QQ' | 'WeChat' | 'Phone' | 'EMail'
|
||||
|
||||
|
||||
@@ -55,11 +55,6 @@ export const homeMeta: IRouteMetaConfig = {
|
||||
order: 4,
|
||||
redirect: '/home/others/admin'
|
||||
},
|
||||
'/home/others/admin': {
|
||||
title: '管理系统',
|
||||
icon: '',
|
||||
redirect: '/admin'
|
||||
},
|
||||
'/home/others/blog': {
|
||||
title: '个人博客',
|
||||
icon: '',
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
<template>
|
||||
<div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
</script>
|
||||
@@ -31,6 +31,7 @@ const loginInfo = reactive({
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
authStore.isVerified = false
|
||||
// authStore.resetLoginForm()
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user