更新密码找回uniapp
This commit is contained in:
1 parent
7f9a66da0f
commit
3fdda89833
1304 files changed
+3503
-26132
No files matched your search
@@ -1,5 +1,4 @@
|
||||
<template>
|
||||
<!-- 当前企业 + 切换:企业名右侧带箭头,点击弹出该账号可进入的企业列表 -->
|
||||
<el-dropdown
|
||||
v-if="companyName"
|
||||
trigger="click"
|
||||
@@ -45,23 +44,12 @@ import { ArrowDown, Check, OfficeBuilding } from "@element-plus/icons-vue";
|
||||
import { useAuthStore } from "@/stores/auth";
|
||||
import { fetchUserInfo, resolveTenantName, switchTenant } from "@/utils/authClient";
|
||||
|
||||
/**
|
||||
* 当前企业名 + 多企业切换。
|
||||
*
|
||||
* variant:
|
||||
* chip —— 浅色标签样式(顶部栏使用)
|
||||
* plain —— 无底色 + 楼宇图标(home 门户顶部使用)
|
||||
*
|
||||
* 只要拿到企业列表(≥1 家)就渲染「企业名 + 箭头」的可点击下拉,
|
||||
* 只有一家时列表内给出说明;列表为空时退化为纯文本企业名。
|
||||
*/
|
||||
const props = withDefaults(defineProps<{ variant?: "chip" | "plain" }>(), {
|
||||
variant: "chip",
|
||||
});
|
||||
|
||||
const authStore = useAuthStore();
|
||||
|
||||
// 下拉里「重新拉取企业列表」的命令值
|
||||
const RELOAD_COMMAND = "__reload__";
|
||||
|
||||
const tenantOptions = ref<Array<{ tid: number | string; tenant_name: string }>>([]);
|
||||
@@ -80,8 +68,6 @@ async function loadTenants() {
|
||||
if (!authStore.token) return;
|
||||
loading.value = true;
|
||||
try {
|
||||
// 用认证中心 userinfo 取「可进入的企业」;同时兜底:本地缓存缺企业名时补上,
|
||||
// 避免顶部企业名为空白(老会话、缓存被清等场景)
|
||||
const info = await fetchUserInfo();
|
||||
const list = Array.isArray(info?.tenants) ? info.tenants : [];
|
||||
tenantOptions.value = list.map((t: any) => ({
|
||||
@@ -98,7 +84,6 @@ async function loadTenants() {
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
// 拉取失败不影响展示,下拉里会给出「点击重试」
|
||||
tenantOptions.value = [];
|
||||
console.error("加载可进入企业列表失败:", e);
|
||||
} finally {
|
||||
@@ -106,10 +91,6 @@ async function loadTenants() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 企业切换后,上一家的菜单 / 标签页 / 企业信息缓存都必须失效。
|
||||
* 菜单虽然是按 tid 建 key,但旧 key 仍会留在本地,顺手清掉可避免脏数据累积。
|
||||
*/
|
||||
function clearTenantScopedCache() {
|
||||
try {
|
||||
const removeKeys: string[] = [];
|
||||
@@ -139,10 +120,6 @@ async function handleSwitch(tid: number | string) {
|
||||
await switchTenant(tid);
|
||||
clearTenantScopedCache();
|
||||
ElMessage.success(`已切换到「${target?.tenant_name || "新企业"}」`);
|
||||
// 切企业后必须离开当前页:当前页可能属于上一家才开通的模块,
|
||||
// 停留在原地会让新企业未开通的功能继续可用。回到首页(门户)锁死入口,
|
||||
// 菜单/权限/套餐再按新企业整页初始化。
|
||||
// 用 replaceState 改 hash(不触发路由跳转),避免用旧企业状态多渲染一次
|
||||
setTimeout(() => {
|
||||
window.history.replaceState({}, document.title, `${window.location.pathname}#/home`);
|
||||
window.location.reload();
|
||||
@@ -198,12 +175,10 @@ onMounted(loadTenants);
|
||||
}
|
||||
}
|
||||
|
||||
// 顶部栏:与右侧圆形操作按钮等高对齐
|
||||
.tenant-chip.is-chip {
|
||||
height: 35px;
|
||||
}
|
||||
|
||||
// home 门户顶部:无底色,图标 + 常规文字色(跟随主题变量自动适配暗色)
|
||||
.tenant-chip.is-plain {
|
||||
gap: 6px;
|
||||
padding: 0;
|
||||
@@ -220,7 +195,6 @@ onMounted(loadTenants);
|
||||
}
|
||||
</style>
|
||||
|
||||
<!-- 下拉弹层由 el-dropdown 挂到 body,scoped 样式够不到,故用 popper 类名前缀限定 -->
|
||||
<style lang="less">
|
||||
.tenant-switcher-popper {
|
||||
.tenant-option {
|
||||
|
||||
Reference in new issue
Block a user