perf: update

This commit is contained in:
xiaoxian521
2021-10-16 21:17:18 +08:00
parent f4b5150b03
commit a05d0fbbe8
11 changed files with 418 additions and 39 deletions

View File

@@ -0,0 +1,25 @@
<script setup lang="ts">
import { ref } from "vue";
import { storageSession } from "/@/utils/storage";
const auth = ref<boolean>(storageSession.getItem("info").username || "admin");
function changRole(value) {
storageSession.setItem("info", {
username: value,
accessToken: `eyJhbGciOiJIUzUxMiJ9.${value}`
});
window.location.reload();
}
</script>
<template>
<div class="app-container">
<el-radio-group v-model="auth" @change="changRole">
<el-radio-button label="admin"></el-radio-button>
<el-radio-button label="test"></el-radio-button>
</el-radio-group>
<p v-auth="'v-admin'">只有admin可看</p>
<p v-auth="'v-test'">只有test可看</p>
</div>
</template>

View File

@@ -0,0 +1,33 @@
<script setup lang="ts">
import { ref, unref } from "vue";
import { storageSession } from "/@/utils/storage";
let purview = ref<string>(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.admin"
});
window.location.reload();
}
}
</script>
<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>