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:
@@ -1,15 +0,0 @@
|
||||
<template>
|
||||
<div>button</div>
|
||||
</template>
|
||||
|
||||
<script lang='ts'>
|
||||
export default {
|
||||
name: "permissionButton",
|
||||
setup() {
|
||||
return {};
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
</style>
|
||||
38
src/views/permission/button/index.vue
Normal file
38
src/views/permission/button/index.vue
Normal file
@@ -0,0 +1,38 @@
|
||||
<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>
|
||||
|
||||
<script lang='ts'>
|
||||
import { ref, unref } from "vue";
|
||||
import { storageSession } from "/@/utils/storage";
|
||||
export default {
|
||||
name: "permissionButton",
|
||||
setup() {
|
||||
const auth = ref(storageSession.getItem("info").username || "admin");
|
||||
|
||||
function changRole(value) {
|
||||
storageSession.setItem("info", {
|
||||
username: value,
|
||||
accessToken: `eyJhbGciOiJIUzUxMiJ9.${value}`
|
||||
});
|
||||
|
||||
window.location.reload();
|
||||
}
|
||||
|
||||
return {
|
||||
auth,
|
||||
changRole
|
||||
};
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
</style>
|
||||
@@ -27,7 +27,7 @@ export default {
|
||||
} else {
|
||||
storageSession.setItem("info", {
|
||||
username: "admin",
|
||||
accessToken: "eyJhbGciOiJIUzUxMiJ9.test"
|
||||
accessToken: "eyJhbGciOiJIUzUxMiJ9.admin"
|
||||
});
|
||||
window.location.reload();
|
||||
}
|
||||
@@ -40,6 +40,3 @@ export default {
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
</style>
|
||||
Reference in New Issue
Block a user