角色弹框
This commit is contained in:
19
src/App.vue
19
src/App.vue
@@ -4,6 +4,7 @@
|
||||
<LockScreen v-if="themeConfig.isLockScreen" />
|
||||
<Settings ref="settingsRef" v-show="themeConfig.lockScreenTime > 1" />
|
||||
<CloseFull v-if="!themeConfig.isLockScreen" />
|
||||
<ChangeRoleFir ref="changeRoleFirRef" />
|
||||
</el-config-provider>
|
||||
</template>
|
||||
|
||||
@@ -14,16 +15,19 @@ import { useThemeConfig } from '/@/stores/themeConfig';
|
||||
import other from '/@/utils/other';
|
||||
import { Local, Session } from '/@/utils/storage';
|
||||
import mittBus from '/@/utils/mitt';
|
||||
import { needRoleSelection, isRoleDialogTriggered, setRoleDialogTriggered } from '/@/utils/roleSelect';
|
||||
import setIntroduction from '/@/utils/setIconfont';
|
||||
|
||||
// 引入组件
|
||||
const LockScreen = defineAsyncComponent(() => import('/@/layout/lockScreen/index.vue'));
|
||||
const Settings = defineAsyncComponent(() => import('./layout/navBars/breadcrumb/settings.vue'));
|
||||
const CloseFull = defineAsyncComponent(() => import('/@/layout/navBars/breadcrumb/closeFull.vue'));
|
||||
const ChangeRoleFir = defineAsyncComponent(() => import('/@/views/admin/system/role/changeRole-fir.vue'));
|
||||
|
||||
// 定义变量内容
|
||||
const { messages, locale } = useI18n();
|
||||
const settingsRef = ref();
|
||||
const changeRoleFirRef = ref<{ open: () => void }>();
|
||||
const route = useRoute();
|
||||
const stores = useTagsViewRoutes();
|
||||
const storesThemeConfig = useThemeConfig();
|
||||
@@ -44,6 +48,7 @@ const getGlobalComponentSize = computed(() => {
|
||||
const getGlobalI18n = computed(() => {
|
||||
return messages.value[locale.value];
|
||||
});
|
||||
|
||||
// 设置初始化,防止刷新时恢复默认
|
||||
onBeforeMount(() => {
|
||||
// 设置批量第三方 icon 图标
|
||||
@@ -67,11 +72,23 @@ onMounted(() => {
|
||||
if (Session.get('isTagsViewCurrenFull')) {
|
||||
stores.setCurrenFullscreen(Session.get('isTagsViewCurrenFull'));
|
||||
}
|
||||
// 全局判断:已登录但 Local 缺少角色信息时弹出角色选择;弹框已触发则不再重复弹出
|
||||
if (Session.getToken() && needRoleSelection() && !isRoleDialogTriggered()) {
|
||||
setRoleDialogTriggered(true);
|
||||
setTimeout(() => {
|
||||
changeRoleFirRef.value?.open();
|
||||
}, 300);
|
||||
}
|
||||
// 请求拦截器里也会在发送请求时判断并 emit,此处统一监听打开弹框
|
||||
mittBus.on('openRoleSelectDialog', () => {
|
||||
changeRoleFirRef.value?.open();
|
||||
});
|
||||
});
|
||||
});
|
||||
// 页面销毁时,关闭监听布局配置/i18n监听
|
||||
// 页面销毁时,关闭监听
|
||||
onUnmounted(() => {
|
||||
mittBus.off('openSettingsDrawer', () => {});
|
||||
mittBus.off('openRoleSelectDialog');
|
||||
});
|
||||
// 监听路由的变化,设置网站标题
|
||||
watch(
|
||||
|
||||
Reference in New Issue
Block a user