index.vue 937 B

1234567891011121314151617181920212223242526272829303132333435
  1. <script setup lang="ts">
  2. import { ref, unref } from "vue";
  3. import { storageSession } from "/@/utils/storage";
  4. let purview: string = ref(storageSession.getItem("info").username);
  5. function changRole() {
  6. if (unref(purview) === "admin") {
  7. storageSession.setItem("info", {
  8. username: "test",
  9. accessToken: "eyJhbGciOiJIUzUxMiJ9.test"
  10. });
  11. window.location.reload();
  12. } else {
  13. storageSession.setItem("info", {
  14. username: "admin",
  15. accessToken: "eyJhbGciOiJIUzUxMiJ9.admin"
  16. });
  17. window.location.reload();
  18. }
  19. }
  20. </script>
  21. <template>
  22. <div class="app-container">
  23. <h4>
  24. 当前角色:
  25. <span style="font-size: 26px">{{ purview }}</span>
  26. <p style="color: #ffa500">
  27. 查看左侧菜单变化(系统管理),模拟后台根据不同角色返回对应路由
  28. </p>
  29. </h4>
  30. <el-button type="primary" @click="changRole">切换角色</el-button>
  31. </div>
  32. </template>