6.13提交
This commit is contained in:
parent
fa1ecdafbc
commit
0f0240bc45
@ -1,2 +1,2 @@
|
||||
BASE_URL= "https://vue3.go-admin.dev"
|
||||
VITE_BASE_URL= "http://dev.hospital.admin.igandanyiyuan.com"
|
||||
VITE_BASE_URL= "http://dev.hospital.admin.api.igandanyiyuan.com"
|
||||
|
||||
@ -24,7 +24,7 @@ export function getAppConfig() {
|
||||
// 根据角色获取菜单
|
||||
export function getUserMenuRole() {
|
||||
return request({
|
||||
url:'/api/v1/menurole',
|
||||
url:'https://www.fastmock.site/mock/ebb1956b65d6078940cacb295a06be27/mock/menu',//'https://www.fastmock.site/mock/ebb1956b65d6078940cacb295a06be27/mock/menu',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
@ -5,7 +5,7 @@
|
||||
<img alt="avatar" :src="userInfo.avatar" />
|
||||
</a-avatar>
|
||||
<div class="user-info">
|
||||
<div class="user-info-name">{{ userInfo.name }}</div>
|
||||
<div class="user-info-name">{{ userInfo.nick_name }}</div>
|
||||
<!-- <div class="user-info-desc">{{ userInfo.introduction }}</div> -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -45,6 +45,8 @@ const keepDefaultSelect = () => {
|
||||
};
|
||||
|
||||
const handleMenuClick = (key) => {
|
||||
console.log(key)
|
||||
console.log(router.getRoutes())
|
||||
router.push(key);
|
||||
};
|
||||
|
||||
|
||||
@ -1,22 +1,21 @@
|
||||
<template>
|
||||
<template v-for="menu in props.menuList" :key="menu.menuId">
|
||||
<template v-for="menu in props.menuList" :key="menu.menu_id">
|
||||
<a-sub-menu
|
||||
v-if="menu.children && menu.menuType == 'M' && menu.visible == 0"
|
||||
v-if="menu.parent_id==0"
|
||||
:key="menu.path"
|
||||
>
|
||||
<!-- <template #icon>
|
||||
<component :is="menu.icon" />
|
||||
</template> -->
|
||||
<template #title>{{ menu.title }}</template>
|
||||
<template #icon>
|
||||
<component :is="menu.icon" v-if="menu.icon"/>
|
||||
</template>
|
||||
<template #title>{{ menu.title }}1</template>
|
||||
<sub-menu :menuList="menu.children" />
|
||||
</a-sub-menu>
|
||||
<a-menu-item
|
||||
v-if="menu.menuType == 'C' && menu.visible && isRouteParams(menu.path)"
|
||||
v-if="menu.parent_id!=0 && isRouteParams(menu.path)"
|
||||
:key="menu.path"
|
||||
>{{ menu.title }}</a-menu-item>
|
||||
>{{ menu.title }}2</a-menu-item>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
</template>
|
||||
<script setup>
|
||||
import { computed } from 'vue'
|
||||
|
||||
|
||||
@ -8,7 +8,7 @@ import router from './router/';
|
||||
import { parseTime } from '@/utils/parseTime';
|
||||
|
||||
// Directive
|
||||
import permission from '@/directive/permission/permission';
|
||||
//import permission from '@/directive/permission/permission';
|
||||
|
||||
// 引入 Arco 图标库
|
||||
import * as ArcoIconModules from '@arco-design/web-vue/es/icon';
|
||||
@ -19,7 +19,7 @@ console.log(import.meta.env);
|
||||
const pinia = createPinia();
|
||||
const app = createApp(App);
|
||||
|
||||
app.directive('has', permission.checkPermission);
|
||||
// app.directive('has', permission.checkPermission);
|
||||
|
||||
// 挂载全局变量
|
||||
app.config.globalProperties.message = Message;
|
||||
|
||||
@ -3,7 +3,6 @@ import Layout from '../layout/index.vue';
|
||||
import { useUserStore } from '../store/userInfo';
|
||||
import { usePermissionStore } from '../store/permission';
|
||||
import Watermark from '@/utils/watermark.js';
|
||||
|
||||
const routes = [
|
||||
{
|
||||
path: '/',
|
||||
@ -67,22 +66,23 @@ router.beforeEach(async (to, from, next) => {
|
||||
|
||||
// 获取系统配置信息
|
||||
await store.getSysConfig();
|
||||
|
||||
console.log(permissionStore.addRouters.length)
|
||||
// 判断用户Token是否获取
|
||||
if (to.name !== 'login' && !store.token) {
|
||||
next({ name: 'login' });
|
||||
next({ name: 'login' });
|
||||
} else {
|
||||
// 判断判断权限有无获取
|
||||
if (store.token && store.roles.length === 0) {
|
||||
store.getUserInfo();
|
||||
console.log(store.token,permissionStore.addRouters.length)
|
||||
if (store.token && permissionStore.addRouters.length==0) {
|
||||
//store.getUserInfo();
|
||||
await permissionStore.getMenuRole();
|
||||
|
||||
permissionStore.addRouters.forEach((route) => {
|
||||
permissionStore.addRouters.forEach((route) => {
|
||||
router.addRoute('/', route);
|
||||
});
|
||||
|
||||
// next(to.fullPath);
|
||||
// 如果 addRoute 并未完成,路由守卫会一层一层的执行执行,直到 addRoute 完成,找到对应的路由
|
||||
next({ ...to, replace: true })
|
||||
next({ ...to, replace: true });
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
|
||||
@ -23,20 +23,18 @@ export const usePermissionStore = defineStore('permisson', {
|
||||
|
||||
routeList.forEach((item) => {
|
||||
const route = {};
|
||||
// if (item.visible == 0) {
|
||||
if (item.menuType === 'M' || item.menuType === 'C') {
|
||||
route.path = item.path;
|
||||
route.name = item.menuName;
|
||||
if (item.menuType === 'M') {
|
||||
route.name = item.menu_name;
|
||||
if (item.parent_id==0) {
|
||||
route.component = modules[`../views/index.vue`];
|
||||
} else if (item.menuType === 'C') {
|
||||
} else{
|
||||
route.component = modules[`../views${item.component}.vue`] || modules['../views/error-page/888.vue'];
|
||||
}
|
||||
route.meta = {
|
||||
title: item.title,
|
||||
permission: item.permission,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
if (item.children) {
|
||||
route.children = this.GenerateRoutes(item.children);
|
||||
@ -44,7 +42,7 @@ export const usePermissionStore = defineStore('permisson', {
|
||||
routes.push(route);
|
||||
// }
|
||||
});
|
||||
|
||||
|
||||
return routes;
|
||||
},
|
||||
async getMenuRole() {
|
||||
@ -52,6 +50,9 @@ export const usePermissionStore = defineStore('permisson', {
|
||||
console.log(res.data);
|
||||
this.setMenuList(res.data);
|
||||
this.addRouters = await this.GenerateRoutes(res.data);
|
||||
console.log("--------this.addRouters");
|
||||
console.log(this.addRouters);
|
||||
|
||||
},
|
||||
ClearMenuList() {
|
||||
this.menuList = [];
|
||||
|
||||
@ -9,33 +9,40 @@ export const useUserStore = defineStore('user', {
|
||||
token: window.sessionStorage.getItem('token') || '',
|
||||
uid: window.sessionStorage.getItem('uid') || '',
|
||||
sysConfig: getLocalStorage('sysConfig'),
|
||||
userInfo: '',
|
||||
userInfo:window.sessionStorage.getItem('manage-userInfo')?JSON.parse(window.sessionStorage.getItem('manage-userInfo')):''
|
||||
}
|
||||
},
|
||||
getters: {
|
||||
roles: (state) => state.userInfo.roles || [],
|
||||
},
|
||||
// getters: {
|
||||
// roles: (state) => state.userInfo.roles || [],
|
||||
// },
|
||||
actions: {
|
||||
setToken(token) {
|
||||
setInfo(token,user) {
|
||||
this.token = token;
|
||||
|
||||
this.userInfo=user;
|
||||
window.sessionStorage.setItem('token', token);
|
||||
window.localStorage.setItem('uid',user.user_id);
|
||||
window.sessionStorage.setItem('manage-userInfo',JSON.stringify(user));
|
||||
},
|
||||
async getUserInfo() {
|
||||
try {
|
||||
const res = await getInfo();
|
||||
// window.sessionStorage.setItem('uid', res.data.userId);
|
||||
window.localStorage.setItem('uid', res.data.userId);
|
||||
this.userInfo = res.data;
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
},
|
||||
// async getUserInfo() {
|
||||
// try {
|
||||
// const res = await getInfo();
|
||||
// // window.sessionStorage.setItem('uid', res.data.userId);
|
||||
// this.userInfo = res.data;
|
||||
|
||||
|
||||
|
||||
// } catch (err) {
|
||||
// console.error(err);
|
||||
// }
|
||||
// },
|
||||
async getSysConfig() {
|
||||
try {
|
||||
// const res = await getAppConfig();
|
||||
// setLocalStorage('sysConfig', res.data);
|
||||
this.sysConfig ={sys_app_logo: "https://doc-image.zhangwj.com/img/go-admin.png", sys_app_name: "go-admin管理系统"} //res.data;
|
||||
//res.data;
|
||||
let data={sys_app_logo: "https://doc-image.zhangwj.com/img/go-admin.png", sys_app_name: "go-admin管理系统"};
|
||||
setLocalStorage('sysConfig', data);
|
||||
this.sysConfig =data
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
|
||||
@ -8,7 +8,7 @@ const service = axios.create({
|
||||
baseURL:import.meta.env.VITE_BASE_URL,
|
||||
timeout: 8000,
|
||||
headers:{
|
||||
'Content-Type':'application/json',
|
||||
'Content-Type':'application/x-www-form-urlencoded',
|
||||
'Authorization':''
|
||||
}
|
||||
});
|
||||
|
||||
18
src/views/admin/menu/index.vue
Normal file
18
src/views/admin/menu/index.vue
Normal file
@ -0,0 +1,18 @@
|
||||
<template>
|
||||
<div>我是菜单ye</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onMounted } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
onMounted(() => {
|
||||
|
||||
const Router = useRouter()
|
||||
console.log( "22")
|
||||
console.log(Router.options.routes)
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang='scss' scoped>
|
||||
|
||||
</style>
|
||||
12
src/views/admin/role/index.vue
Normal file
12
src/views/admin/role/index.vue
Normal file
@ -0,0 +1,12 @@
|
||||
<template>
|
||||
<div>我是角色ye</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
</script>
|
||||
|
||||
<style lang='scss' scoped>
|
||||
|
||||
</style>
|
||||
|
||||
@ -246,8 +246,8 @@ onMounted(() => {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
// Table 操作列样式
|
||||
/*
|
||||
Table 操作列样式 */
|
||||
.arco-table-th:last-child > span {
|
||||
margin-left: 15px;
|
||||
}
|
||||
|
||||
@ -26,9 +26,9 @@
|
||||
layout="vertical"
|
||||
@keyup.enter="handleLogin"
|
||||
>
|
||||
<a-form-item field="userName" hide-asterisk>
|
||||
<a-form-item field="access" hide-asterisk>
|
||||
<a-input
|
||||
v-model="loginForm.userName"
|
||||
v-model="loginForm.access"
|
||||
placeholder="请输入用户名"
|
||||
>
|
||||
<template #prefix>
|
||||
@ -36,9 +36,9 @@
|
||||
</template>
|
||||
</a-input>
|
||||
</a-form-item>
|
||||
<a-form-item field="passWord" hide-asterisk>
|
||||
<a-form-item field="password" hide-asterisk>
|
||||
<a-input-password
|
||||
v-model="loginForm.passWord"
|
||||
v-model="loginForm.password"
|
||||
placeholder="请输入密码"
|
||||
>
|
||||
<template #prefix>
|
||||
@ -48,9 +48,9 @@
|
||||
</a-form-item>
|
||||
<div style="display: flex">
|
||||
<div style="width: 65%">
|
||||
<a-form-item field="code" hide-asterisk>
|
||||
<a-form-item field="captcha" hide-asterisk>
|
||||
<a-input
|
||||
v-model="loginForm.code"
|
||||
v-model="loginForm.captcha"
|
||||
placeholder="请输入验证码"
|
||||
>
|
||||
<template #prefix>
|
||||
@ -106,16 +106,16 @@ const loading = ref(false);
|
||||
|
||||
// rules
|
||||
const loginRules = {
|
||||
userName: [{ required: true, message: '请输入用户名' }],
|
||||
passWord: [{ required: true, message: '请输入密码' }],
|
||||
code: [{ required: true, message: '请输入验证码' }],
|
||||
access: [{ required: true, message: '请输入用户名' }],
|
||||
password: [{ required: true, message: '请输入密码' }],
|
||||
captcha: [{ required: true, message: '请输入验证码' }],
|
||||
};
|
||||
|
||||
// 获取验证码
|
||||
const loadCaptcha = async () => {
|
||||
const res = await getCaptcha();
|
||||
captchUrl.value = res.data;
|
||||
loginForm.uuid = res.id;
|
||||
captchUrl.value = res.data.b64s;
|
||||
loginForm.captchaId = res.data.id;
|
||||
};
|
||||
|
||||
// 登陆
|
||||
@ -125,19 +125,25 @@ const handleLogin = () => {
|
||||
proxy.$refs.loginFormRef.validate(async (valid) => {
|
||||
if (!valid) {
|
||||
try {
|
||||
const { code, token, msg } = await login(loginForm);
|
||||
const { code, data, msg } = await login(loginForm);
|
||||
if ( code == 200 ) {
|
||||
await store.setToken(token);
|
||||
const {avatar,nick_name,token,user_id}=data;
|
||||
const userInfo={
|
||||
nick_name,
|
||||
avatar,
|
||||
user_id
|
||||
}
|
||||
await store.setInfo(token,userInfo);
|
||||
proxy.$message.success({
|
||||
content: '登陆成功',
|
||||
duration: 2000,
|
||||
});
|
||||
setTimeout(() => {
|
||||
proxy.$router.push('/admin/sys-api');
|
||||
loading.value = false;
|
||||
proxy.$router.push('/admin/role');
|
||||
loading.value = false;
|
||||
}, 500);
|
||||
} else {
|
||||
proxy.$message.error(`登陆失败:${msg}`);
|
||||
proxy.$message.error(`登陆失败:${message}`);
|
||||
}
|
||||
} catch (err) {
|
||||
// 登录失败 重新获取验证码
|
||||
@ -170,14 +176,14 @@ onMounted(async () => {
|
||||
border-color: #e5e7eb;
|
||||
}
|
||||
|
||||
// 输入框重写
|
||||
|
||||
.arco-input-wrapper {
|
||||
border-radius: 20px;
|
||||
height: 40px;
|
||||
border: 1px solid #ddd;
|
||||
background: #fff;
|
||||
}
|
||||
// 输入框 重写框颜色
|
||||
|
||||
.arco-input-wrapper:hover {
|
||||
background: #fff;
|
||||
border: 1px solid #1e6fff;
|
||||
@ -201,13 +207,13 @@ onMounted(async () => {
|
||||
.account-wrap-login {
|
||||
width: 960px;
|
||||
height: 554px;
|
||||
// background: #fff;
|
||||
/* background: #fff; */
|
||||
border-radius: 10px;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
// justify-content:space-between;
|
||||
// padding:30px 95px 33px
|
||||
/* justify-content:space-between;
|
||||
padding:30px 95px 33px */
|
||||
}
|
||||
.account-wrap-login .login-pic {
|
||||
background-color: #0259e6 !important;
|
||||
@ -283,7 +289,7 @@ onMounted(async () => {
|
||||
}
|
||||
}
|
||||
|
||||
// 20230105 自动填充背景色问题
|
||||
/* 20230105 自动填充背景色问题 */
|
||||
:deep(.arco-input-wrapper .arco-input.arco-input-size-medium) {
|
||||
box-shadow: 0 0 0px 1000px #fff inset;
|
||||
}
|
||||
|
||||
@ -28,7 +28,8 @@ export default defineConfig({
|
||||
}
|
||||
},
|
||||
server: {
|
||||
|
||||
host: true,
|
||||
port: 1798,
|
||||
//secure: false,
|
||||
proxy: {
|
||||
// '/api': {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user