mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-11-03 13:44:47 +08:00
feat: 模拟后台返回不同角色路由生成动态路由
This commit is contained in:
15
src/views/permission/button.vue
Normal file
15
src/views/permission/button.vue
Normal file
@@ -0,0 +1,15 @@
|
||||
<template>
|
||||
<div>button</div>
|
||||
</template>
|
||||
|
||||
<script lang='ts'>
|
||||
export default {
|
||||
name: "permissionButton",
|
||||
setup() {
|
||||
return {};
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
</style>
|
||||
45
src/views/permission/page.vue
Normal file
45
src/views/permission/page.vue
Normal file
@@ -0,0 +1,45 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<h4>
|
||||
当前角色:
|
||||
<span style="font-size:26px">{{ purview }}</span>
|
||||
<p style="color: #FFA500">查看左侧菜单变化(系统管理),模拟后台根据不同角色返回对应路由</p>
|
||||
</h4>
|
||||
<el-button type="primary" @click="changRole">切换角色</el-button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang='ts'>
|
||||
import { ref, unref } from "vue";
|
||||
import { storageSession } from "/@/utils/storage";
|
||||
export default {
|
||||
name: "permissionPage",
|
||||
setup() {
|
||||
let purview: string = ref(storageSession.getItem("info").username);
|
||||
|
||||
function changRole() {
|
||||
if (unref(purview) === "admin") {
|
||||
storageSession.setItem("info", {
|
||||
username: "test",
|
||||
accessToken: "eyJhbGciOiJIUzUxMiJ9.test"
|
||||
});
|
||||
window.location.reload();
|
||||
} else {
|
||||
storageSession.setItem("info", {
|
||||
username: "admin",
|
||||
accessToken: "eyJhbGciOiJIUzUxMiJ9.test"
|
||||
});
|
||||
window.location.reload();
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
purview,
|
||||
changRole
|
||||
};
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
</style>
|
||||
@@ -96,6 +96,7 @@ import {
|
||||
import Config from "./config.vue";
|
||||
|
||||
export default {
|
||||
name: "dict",
|
||||
components: {
|
||||
Config
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user