提交 dad7d12b authored 作者: inroi's avatar inroi
......@@ -5,6 +5,7 @@ import { ElNotification } from 'element-plus';
import router from '@/router/index'
export default function useLogin(loginModel: LoginParm) {
const { proxy } = getCurrentInstance() as any;
const num = ref(0)
//登录提交
const login = async () => {
//表单验证
......@@ -24,6 +25,7 @@ export default function useLogin(loginModel: LoginParm) {
router.push({ path: '/' })
}, 1500)
} else {
num.value++
// ElNotification({
// title:'登陆失败',
// message:res.msg,
......@@ -45,6 +47,7 @@ export default function useLogin(loginModel: LoginParm) {
const loginState = ref(false)
return {
login,
num,
loginState
}
}
\ No newline at end of file
......@@ -2,6 +2,7 @@ import { getMenuListApi } from "@/services/api/menu/menuAPI";
import { RouteRecordRaw } from "vue-router";
import { ActionContext } from "vuex";
import { RootState } from "..";
import { ElNotification } from "element-plus";
import Layout from "@/layout/index.vue";
const modules = import.meta.glob("../../views/**/*.vue");
//定义state
......@@ -50,11 +51,15 @@ export const actions = {
return new Promise((resolve, reject) => {
getMenuListApi()
.then((res) => {
/* res.data.forEach(item => {
if (item.meta.title === '部门') {
item.children = []
}
}) */
if (res.data.length === 0) {
ElNotification({
title: '获取权限失败',
message: '该账号没有后台权限,请联系管理员授权',
type: 'error',
})
sessionStorage.clear()
return window.location.href = "/#/login";
} else {
let accessedRoutes;
if (res.code == 200) {
//动态生成路由
......@@ -64,6 +69,7 @@ export const actions = {
}
//返回
resolve(accessedRoutes);
}
})
.catch((error) => {
reject(error);
......
......@@ -47,6 +47,7 @@
</div>
</template>
<script setup lang="ts">
import { watch } from "vue";
import useImage from "@/services/business/login/useImage";
import useBaseLogin from "@/services/business/login/useBaseLogin";
import useLogin from "@/services/business/login/useLogin";
......@@ -57,7 +58,10 @@ const { loginModel, rules, loginFormRef } = useBaseLogin();
const { imgSrc, getImage } = useImage();
//登录
const { login, loginState } = useLogin(loginModel);
const { login, loginState, num } = useLogin(loginModel);
watch(num, () => getImage(), { deep: true })
</script>
<style scoped lang="scss">
.logincontainer {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论