mirror of
https://gitee.com/dromara/go-view.git
synced 2026-05-12 00:00:01 +08:00
feat: 新增退出登录接口,新增全局接口封装,修改登录接口内容
This commit is contained in:
@@ -1,13 +0,0 @@
|
||||
import { http } from '@/api/http'
|
||||
import { httpErrorHandle } from '@/utils'
|
||||
import { RequestHttpEnum, ModuleTypeEnum } from '@/enums/httpEnum'
|
||||
|
||||
// 登录
|
||||
export const loginRequest = async (data: object) => {
|
||||
try {
|
||||
const res = await http(RequestHttpEnum.POST)(`${ModuleTypeEnum.SYSTEM}/login`, data);
|
||||
return res;
|
||||
} catch {
|
||||
httpErrorHandle();
|
||||
}
|
||||
}
|
||||
@@ -128,7 +128,7 @@ import { PageEnum } from '@/enums/pageEnum'
|
||||
import { icon } from '@/plugins'
|
||||
import { StorageEnum } from '@/enums/storageEnum'
|
||||
import { routerTurnByName } from '@/utils'
|
||||
import { loginRequest } from './api/index'
|
||||
import { loginApi } from '@/api/path/system.api'
|
||||
|
||||
interface FormState {
|
||||
username: string
|
||||
@@ -213,17 +213,22 @@ const handleSubmit = async (e: Event) => {
|
||||
const { username, password } = formInline
|
||||
loading.value = true
|
||||
// 提交请求
|
||||
const res:any = await loginRequest({
|
||||
const res:any = await loginApi({
|
||||
username,
|
||||
password
|
||||
})
|
||||
if(res.data) {
|
||||
const { tokenValue, loginId } = res.data
|
||||
const { tokenValue } = res.data.token
|
||||
const { nickname, username, id } = res.data.userinfo
|
||||
|
||||
// 存储到 pinia
|
||||
systemStore.setItem(SystemStoreEnum.USER_INFO, {
|
||||
userToken: tokenValue,
|
||||
userId: loginId,
|
||||
userId: id,
|
||||
userName: username,
|
||||
nickName: nickname,
|
||||
})
|
||||
|
||||
window['$message'].success(`${t('login.login_success')}!`)
|
||||
routerTurnByName(PageEnum.BASE_HOME_NAME, true)
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ export const useDataListInit = () => {
|
||||
onPositiveCallback: () =>
|
||||
new Promise(res => setTimeout(() => res(1), 1000)),
|
||||
promiseResCallback: (e: any) => {
|
||||
window.$message.success('删除成功')
|
||||
window['$message'].success('删除成功')
|
||||
list.value.splice(index, 1)
|
||||
}
|
||||
})
|
||||
|
||||
+12
-8
@@ -18,7 +18,7 @@
|
||||
:disabled="item.disabled"
|
||||
v-for="item in typeList"
|
||||
:key="item.key"
|
||||
@click="btnHandle"
|
||||
@click="btnHandle(item.key)"
|
||||
>
|
||||
<component :is="item.title"></component>
|
||||
<template #icon>
|
||||
@@ -35,7 +35,7 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { watch, reactive } from 'vue'
|
||||
import { watch } from 'vue'
|
||||
import { icon } from '@/plugins'
|
||||
import { PageEnum, ChartEnum } from '@/enums/pageEnum'
|
||||
import { fetchPathByName, routerTurnByPath, renderLang, getUUID } from '@/utils'
|
||||
@@ -48,7 +48,7 @@ const props = defineProps({
|
||||
show: Boolean
|
||||
})
|
||||
|
||||
const typeList = reactive([
|
||||
const typeList = [
|
||||
{
|
||||
title: renderLang('project.new_project'),
|
||||
key: ChartEnum.CHART_HOME_NAME,
|
||||
@@ -67,7 +67,7 @@ const typeList = reactive([
|
||||
icon: StoreIcon,
|
||||
disabled: true
|
||||
}
|
||||
])
|
||||
]
|
||||
|
||||
// 解决点击模态层不会触发 @on-after-leave 的问题
|
||||
watch(props, newValue => {
|
||||
@@ -83,10 +83,14 @@ const closeHandle = () => {
|
||||
|
||||
// 处理按钮点击
|
||||
const btnHandle = (key: string) => {
|
||||
closeHandle()
|
||||
const id = getUUID()
|
||||
const path = fetchPathByName(ChartEnum.CHART_HOME_NAME, 'href')
|
||||
routerTurnByPath(path, [id], undefined, true)
|
||||
switch (key) {
|
||||
case ChartEnum.CHART_HOME_NAME:
|
||||
const id = getUUID()
|
||||
const path = fetchPathByName(ChartEnum.CHART_HOME_NAME, 'href')
|
||||
routerTurnByPath(path, [id], undefined, true)
|
||||
closeHandle()
|
||||
break;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
|
||||
Reference in New Issue
Block a user