All checks were successful
Build and Deploy Front / deploy (push) Successful in 5m52s
仓租费率改为单页三段矩阵编辑(合并相同值/批量填价/计算公式);同步收敛侧栏、顶栏与官网头像/语言为圆形芯片。 Co-authored-by: Cursor <cursoragent@cursor.com>
909 lines
25 KiB
Vue
909 lines
25 KiB
Vue
<template>
|
||
<a-dropdown
|
||
v-model:popup-visible="menuVisible"
|
||
:trigger="dropdownTrigger"
|
||
:position="dropdownPosition"
|
||
:content-class="contentClass"
|
||
:popup-translate="popupTranslate"
|
||
@select="onDropdownSelect"
|
||
>
|
||
<div class="user-dropdown-trigger" :class="{ 'is-compact': compact }">
|
||
<img
|
||
v-if="showCustomerAvatar"
|
||
:src="customerAvatarUrl"
|
||
alt=""
|
||
class="user-avatar"
|
||
/>
|
||
<span v-else class="user-avatar user-avatar--fallback">{{ displayNameInitial }}</span>
|
||
<span v-if="!compact" class="user-name">{{ displayName }}</span>
|
||
</div>
|
||
|
||
<!-- Linear / Notion / GitHub 式:身份头 + 分组菜单 + 底栏退出 -->
|
||
<template v-if="isSiderVariant" #content>
|
||
<div class="csr-user-panel" @click.stop>
|
||
<div class="csr-user-panel__body">
|
||
<section v-if="primaryAccountMenus.length" class="csr-user-panel__section">
|
||
<div class="csr-user-panel__section-label">账户</div>
|
||
<button
|
||
v-for="item in primaryAccountMenus"
|
||
:key="accountMenuKey(item)"
|
||
type="button"
|
||
class="csr-user-panel__item"
|
||
@click="onPanelAction(accountMenuKey(item))"
|
||
>
|
||
<span class="csr-user-panel__item-icon">
|
||
<component :is="getSubMenuIcon(item, undefined, MENU_NAME_TO_LOCALE_KEY)" />
|
||
</span>
|
||
<span class="csr-user-panel__item-label">{{ formatAccountTitle(item) }}</span>
|
||
</button>
|
||
</section>
|
||
|
||
<section class="csr-user-panel__section">
|
||
<div class="csr-user-panel__section-label">设置</div>
|
||
<button
|
||
v-if="isCustomerPortal && !hasAccountProfileItem"
|
||
type="button"
|
||
class="csr-user-panel__item"
|
||
@click="onPanelAction('userinfo')"
|
||
>
|
||
<span class="csr-user-panel__item-icon"><i class="fa fa-user" /></span>
|
||
<span class="csr-user-panel__item-label">{{ t('menu.user.profile') }}</span>
|
||
</button>
|
||
<button
|
||
type="button"
|
||
class="csr-user-panel__item"
|
||
@click="onPanelAction('changePassword')"
|
||
>
|
||
<span class="csr-user-panel__item-icon"><i class="fa fa-lock" /></span>
|
||
<span class="csr-user-panel__item-label">{{ t('profile.changePassword') }}</span>
|
||
</button>
|
||
<button
|
||
type="button"
|
||
class="csr-user-panel__item"
|
||
@click="onPanelAction('settings')"
|
||
>
|
||
<span class="csr-user-panel__item-icon"><i class="fa fa-cog" /></span>
|
||
<span class="csr-user-panel__item-label">{{ t('nav.userMenu.pageSettings') }}</span>
|
||
</button>
|
||
<button
|
||
type="button"
|
||
class="csr-user-panel__item"
|
||
:title="langToggleTitle"
|
||
@click="toggleLanguage"
|
||
>
|
||
<span class="csr-user-panel__item-icon"><i class="fa fa-language" /></span>
|
||
<span class="csr-user-panel__item-label">{{ t('nav.userMenu.switchLanguage') }}</span>
|
||
<span class="csr-user-panel__item-extra">{{ langToggleLabel }}</span>
|
||
</button>
|
||
<button
|
||
v-for="item in trailingAccountMenus"
|
||
:key="accountMenuKey(item)"
|
||
type="button"
|
||
class="csr-user-panel__item"
|
||
@click="onPanelAction(accountMenuKey(item))"
|
||
>
|
||
<span class="csr-user-panel__item-icon">
|
||
<component :is="getSubMenuIcon(item, undefined, MENU_NAME_TO_LOCALE_KEY)" />
|
||
</span>
|
||
<span class="csr-user-panel__item-label">{{ formatAccountTitle(item) }}</span>
|
||
</button>
|
||
</section>
|
||
</div>
|
||
|
||
<div class="csr-user-panel__footer">
|
||
<button
|
||
type="button"
|
||
class="csr-user-panel__item is-danger"
|
||
@click="onPanelAction('logout')"
|
||
>
|
||
<span class="csr-user-panel__item-icon"><i class="fa fa-sign-out" /></span>
|
||
<span class="csr-user-panel__item-label">{{ t('nav.userMenu.logout') }}</span>
|
||
</button>
|
||
</div>
|
||
</div>
|
||
</template>
|
||
|
||
<template v-else #content>
|
||
<a-doption
|
||
v-for="item in primaryAccountMenus"
|
||
:key="accountMenuKey(item)"
|
||
:value="accountMenuKey(item)"
|
||
>
|
||
<span class="user-menu-item">
|
||
<span class="user-menu-item__icon">
|
||
<component :is="getSubMenuIcon(item, undefined, MENU_NAME_TO_LOCALE_KEY)" />
|
||
</span>
|
||
<span class="user-menu-item__label">{{ formatAccountTitle(item) }}</span>
|
||
</span>
|
||
</a-doption>
|
||
<a-doption v-if="isCustomerPortal && !hasAccountProfileItem" value="userinfo">
|
||
<span class="user-menu-item">
|
||
<span class="user-menu-item__icon"><i class="fa fa-user" /></span>
|
||
<span class="user-menu-item__label">{{ t('menu.user.profile') }}</span>
|
||
</span>
|
||
</a-doption>
|
||
<a-doption v-if="!isCustomerPortal" value="settings">
|
||
<span class="user-menu-item">
|
||
<span class="user-menu-item__icon"><i class="fa fa-cog" /></span>
|
||
<span class="user-menu-item__label">{{ t('nav.userMenu.pageSettings') }}</span>
|
||
</span>
|
||
</a-doption>
|
||
<a-doption value="changePassword">
|
||
<span class="user-menu-item">
|
||
<span class="user-menu-item__icon"><i class="fa fa-lock" /></span>
|
||
<span class="user-menu-item__label">{{ t('profile.changePassword') }}</span>
|
||
</span>
|
||
</a-doption>
|
||
<a-doption v-if="isCustomerPortal" value="settings">
|
||
<span class="user-menu-item">
|
||
<span class="user-menu-item__icon"><i class="fa fa-cog" /></span>
|
||
<span class="user-menu-item__label">{{ t('nav.userMenu.pageSettings') }}</span>
|
||
</span>
|
||
</a-doption>
|
||
<a-doption
|
||
v-for="item in trailingAccountMenus"
|
||
:key="accountMenuKey(item)"
|
||
:value="accountMenuKey(item)"
|
||
>
|
||
<span class="user-menu-item">
|
||
<span class="user-menu-item__icon">
|
||
<component :is="getSubMenuIcon(item, undefined, MENU_NAME_TO_LOCALE_KEY)" />
|
||
</span>
|
||
<span class="user-menu-item__label">{{ formatAccountTitle(item) }}</span>
|
||
</span>
|
||
</a-doption>
|
||
<template v-if="showLanguageMenu">
|
||
<a-doption
|
||
v-for="item in languageOptions"
|
||
:key="item.value"
|
||
:value="`lang:${item.value}`"
|
||
>
|
||
<span class="user-menu-item">
|
||
<span class="user-menu-item__icon user-menu-item__lang">{{ item.short }}</span>
|
||
<span class="user-menu-item__label">
|
||
{{ item.label }}
|
||
<span v-if="locale === item.value" class="user-menu-item__hint">✓</span>
|
||
</span>
|
||
</span>
|
||
</a-doption>
|
||
</template>
|
||
<a-doption value="logout">
|
||
<span class="user-menu-item is-danger">
|
||
<span class="user-menu-item__icon"><i class="fa fa-sign-out" /></span>
|
||
<span class="user-menu-item__label">{{ t('nav.userMenu.logout') }}</span>
|
||
</span>
|
||
</a-doption>
|
||
</template>
|
||
</a-dropdown>
|
||
|
||
<a-modal
|
||
v-model:visible="changePasswordVisible"
|
||
:title="t('profile.changePassword')"
|
||
:mask-closable="false"
|
||
:confirm-loading="changePasswordLoading"
|
||
@ok="handleChangePasswordSubmit"
|
||
@cancel="handleChangePasswordCancel"
|
||
>
|
||
<a-form
|
||
ref="pwdFormRef"
|
||
:model="pwdForm"
|
||
:label-col-props="{ span: 6 }"
|
||
:wrapper-col-props="{ span: 16 }"
|
||
>
|
||
<a-form-item
|
||
field="oldPassword"
|
||
:label="t('profile.oldPassword')"
|
||
:rules="[{ required: true, message: t('profile.oldPassword') }]"
|
||
>
|
||
<a-input-password
|
||
v-model="pwdForm.oldPassword"
|
||
:placeholder="t('profile.oldPassword')"
|
||
allow-clear
|
||
/>
|
||
</a-form-item>
|
||
<a-form-item
|
||
field="newPassword"
|
||
:label="t('profile.newPassword')"
|
||
:rules="[{ required: true, message: t('profile.newPassword') }]"
|
||
>
|
||
<a-input-password
|
||
v-model="pwdForm.newPassword"
|
||
:placeholder="t('profile.newPassword')"
|
||
allow-clear
|
||
/>
|
||
</a-form-item>
|
||
<a-form-item
|
||
field="confirmPassword"
|
||
:label="t('profile.confirmPassword')"
|
||
:rules="[
|
||
{ required: true, message: t('profile.confirmPassword') },
|
||
{ validator: validateConfirmPassword },
|
||
]"
|
||
>
|
||
<a-input-password
|
||
v-model="pwdForm.confirmPassword"
|
||
:placeholder="t('profile.confirmPassword')"
|
||
allow-clear
|
||
/>
|
||
</a-form-item>
|
||
</a-form>
|
||
</a-modal>
|
||
</template>
|
||
|
||
<script lang="ts" setup>
|
||
import { computed, nextTick, onMounted, onUnmounted, reactive, ref, watch } from 'vue';
|
||
import { useRouter } from 'vue-router';
|
||
import { useI18n } from 'vue-i18n';
|
||
import { Message } from '@arco-design/web-vue';
|
||
import { useUserStore, useAppStore } from '@/store';
|
||
import { useRbacUserStore } from '@/store/modules/rbac-user';
|
||
import { AuthService } from '@/api/rbac';
|
||
import {
|
||
peekCachedCurrentCustomer,
|
||
resolveCurrentCustomer,
|
||
} from '@/api/customer/resolve';
|
||
import { CUSTOMER_BALANCE_CHANGED_EVENT } from '@/api/customer/accountFlow';
|
||
import { getMapIdFromAccessToken } from '@/utils/jwt';
|
||
import { isValidAvatarUrl, resolveAvatarUrl } from '@/utils/avatar';
|
||
import useLocale from '@/hooks/locale';
|
||
import { resolvePostLogoutLogin } from '@/utils/login-portal';
|
||
import { openPortalSideDrawer } from '@/views/user/portal-drawer/usePortalSideDrawer';
|
||
import { resolvePortalDrawerPanel } from '@/views/user/portal-drawer/types';
|
||
import { getSubMenuIcon } from '@/utils/menu-icon';
|
||
import { MENU_NAME_TO_LOCALE_KEY, translateMenuTitle } from '@/utils/menu-i18n';
|
||
import {
|
||
getCustomerNavPath,
|
||
type CustomerNavItem,
|
||
} from '@/utils/customer-portal-nav';
|
||
|
||
const props = withDefaults(
|
||
defineProps<{
|
||
/** 侧栏收起等场景只显示头像 */
|
||
compact?: boolean
|
||
/** 下拉相对触发器位置;侧栏 Cursor 风格默认 tl(向上) */
|
||
dropdownPosition?: 'br' | 'bl' | 'tr' | 'tl' | 'rt' | 'rb' | 'bottom' | 'top'
|
||
/** 客户侧栏:资产与账户菜单,收进用户下拉 */
|
||
accountMenus?: CustomerNavItem[]
|
||
/** 侧栏面板内嵌语言切换;客户门户语言已挪到页签行右上角 */
|
||
showLanguageMenu?: boolean
|
||
/** navbar 保持原下拉;sider 用 Cursor 式面板 */
|
||
variant?: 'navbar' | 'sider'
|
||
trigger?: 'hover' | 'click'
|
||
}>(),
|
||
{
|
||
compact: false,
|
||
dropdownPosition: undefined,
|
||
accountMenus: () => [],
|
||
showLanguageMenu: false,
|
||
variant: 'navbar',
|
||
trigger: undefined,
|
||
},
|
||
);
|
||
|
||
const { t, locale } = useI18n();
|
||
const { changeLocale } = useLocale();
|
||
const router = useRouter();
|
||
const userStore = useUserStore();
|
||
const appStore = useAppStore();
|
||
const rbacUserStore = useRbacUserStore();
|
||
|
||
const menuVisible = ref(false);
|
||
|
||
const isSiderVariant = computed(() => props.variant === 'sider');
|
||
const showLanguageMenu = computed(() => props.showLanguageMenu);
|
||
|
||
const dropdownTrigger = computed(() => {
|
||
if (props.trigger) return props.trigger;
|
||
return isSiderVariant.value ? 'click' : 'hover';
|
||
});
|
||
|
||
const dropdownPosition = computed(
|
||
() => props.dropdownPosition ?? (isSiderVariant.value ? 'tl' : 'bottom'),
|
||
);
|
||
|
||
const contentClass = computed(() =>
|
||
isSiderVariant.value ? 'csr-dock-dropdown csr-account-dropdown' : 'user-account-dropdown',
|
||
);
|
||
|
||
/** 向上弹出时略抬离触发器,贴近 Cursor */
|
||
const popupTranslate = computed<[number, number] | undefined>(() =>
|
||
isSiderVariant.value ? [0, -6] : undefined,
|
||
);
|
||
|
||
const languageOptions = [
|
||
{ value: 'zh-CN', label: '中文', short: '中' },
|
||
{ value: 'en-US', label: 'English', short: 'EN' },
|
||
] as const;
|
||
|
||
const currentLanguage = computed(() => String(locale.value || 'zh-CN'));
|
||
const isZh = computed(() => currentLanguage.value === 'zh-CN');
|
||
const langToggleLabel = computed(() => (isZh.value ? 'EN' : '中'));
|
||
const langToggleTitle = computed(() =>
|
||
isZh.value ? 'Switch to English' : '切换到中文',
|
||
);
|
||
|
||
function toggleLanguage() {
|
||
void changeLocale(isZh.value ? 'en-US' : 'zh-CN', { silent: true });
|
||
}
|
||
|
||
const isCustomerPortal = computed(() => rbacUserStore.isCustomerPortal());
|
||
|
||
const displayName = computed(() => {
|
||
return userStore.name || '--';
|
||
});
|
||
|
||
const displayNameInitial = computed(() => {
|
||
const name = String(displayName.value || '').trim();
|
||
return name ? name.slice(0, 1).toUpperCase() : '?';
|
||
});
|
||
|
||
const compact = computed(() => props.compact);
|
||
const accountMenus = computed(() => props.accountMenus || []);
|
||
|
||
/** 出口资质备案放到账户菜单末尾(改密/页面设置之后、退出之前) */
|
||
function isTrailingAccountMenuItem(item: CustomerNavItem) {
|
||
const path = getCustomerNavPath(item).toLowerCase();
|
||
return (
|
||
path.includes('/exportqualification') ||
|
||
path.includes('exportqualification') ||
|
||
String(item.name || '').includes('出口资质')
|
||
);
|
||
}
|
||
|
||
const primaryAccountMenus = computed(() =>
|
||
accountMenus.value.filter((item) => !isTrailingAccountMenuItem(item)),
|
||
);
|
||
|
||
const trailingAccountMenus = computed(() =>
|
||
accountMenus.value.filter((item) => isTrailingAccountMenuItem(item)),
|
||
);
|
||
|
||
const hasAccountProfileItem = computed(() =>
|
||
accountMenus.value.some((item) => {
|
||
const path = getCustomerNavPath(item);
|
||
return path === '/user/profile' || resolvePortalDrawerPanel(path) === 'profile';
|
||
}),
|
||
);
|
||
|
||
function accountMenuKey(item: CustomerNavItem) {
|
||
return `account:${getCustomerNavPath(item) || item.id || item.name}`;
|
||
}
|
||
|
||
function formatAccountTitle(item: CustomerNavItem) {
|
||
void locale.value;
|
||
return translateMenuTitle(t, {
|
||
name: item.name,
|
||
route: item.route || item.path,
|
||
path: item.path || item.route,
|
||
meta: item.meta,
|
||
});
|
||
}
|
||
|
||
function openAccountMenuItem(item: CustomerNavItem) {
|
||
let targetPath = getCustomerNavPath(item);
|
||
if (!targetPath) return;
|
||
if (!targetPath.startsWith('/')) targetPath = `/${targetPath}`;
|
||
const portalPanel = resolvePortalDrawerPanel(targetPath);
|
||
if (portalPanel) {
|
||
openPortalSideDrawer(portalPanel);
|
||
return;
|
||
}
|
||
if (router.currentRoute.value.path === targetPath) return;
|
||
router.push(targetPath).catch(() => undefined);
|
||
}
|
||
|
||
const customerAvatarRaw = ref('');
|
||
|
||
const customerAvatarUrl = computed(() =>
|
||
resolveAvatarUrl(customerAvatarRaw.value),
|
||
);
|
||
|
||
const showCustomerAvatar = computed(
|
||
() => isCustomerPortal.value && isValidAvatarUrl(customerAvatarRaw.value),
|
||
);
|
||
|
||
async function loadCustomerAvatar() {
|
||
if (!rbacUserStore.isCustomerPortal() || !rbacUserStore.isLoggedIn) {
|
||
customerAvatarRaw.value = '';
|
||
return;
|
||
}
|
||
const mapId = getMapIdFromAccessToken(rbacUserStore.accessToken);
|
||
const account = rbacUserStore.userInfo?.account?.trim() || '';
|
||
const cached = peekCachedCurrentCustomer({ mapId, account });
|
||
const fromCache =
|
||
cached?.wechatAvatarUrl || cached?.wechatAvatar || '';
|
||
if (isValidAvatarUrl(fromCache)) {
|
||
customerAvatarRaw.value = String(fromCache).trim();
|
||
}
|
||
try {
|
||
const data = await resolveCurrentCustomer({ mapId, account });
|
||
const next = data?.wechatAvatarUrl || data?.wechatAvatar || '';
|
||
customerAvatarRaw.value = isValidAvatarUrl(next) ? String(next).trim() : '';
|
||
} catch {
|
||
if (!isValidAvatarUrl(customerAvatarRaw.value)) {
|
||
customerAvatarRaw.value = '';
|
||
}
|
||
}
|
||
}
|
||
|
||
watch(
|
||
() =>
|
||
[
|
||
rbacUserStore.isLoggedIn,
|
||
rbacUserStore.loginPortalType,
|
||
rbacUserStore.accessToken,
|
||
] as const,
|
||
() => {
|
||
void loadCustomerAvatar();
|
||
},
|
||
{ immediate: true },
|
||
);
|
||
|
||
function onCustomerProfileChanged() {
|
||
void loadCustomerAvatar();
|
||
}
|
||
|
||
onMounted(() => {
|
||
window.addEventListener(CUSTOMER_BALANCE_CHANGED_EVENT, onCustomerProfileChanged);
|
||
});
|
||
|
||
onUnmounted(() => {
|
||
window.removeEventListener(
|
||
CUSTOMER_BALANCE_CHANGED_EVENT,
|
||
onCustomerProfileChanged,
|
||
);
|
||
});
|
||
|
||
const changePasswordVisible = ref(false);
|
||
const changePasswordLoading = ref(false);
|
||
const pwdFormRef = ref();
|
||
const pwdForm = reactive({
|
||
oldPassword: '',
|
||
newPassword: '',
|
||
confirmPassword: '',
|
||
});
|
||
|
||
// Arco Form:validator(value, callback)
|
||
function validateConfirmPassword(value: string, callback: (error?: string) => void) {
|
||
if (value !== pwdForm.newPassword) {
|
||
callback(t('profile.passwordMismatch'));
|
||
} else {
|
||
callback();
|
||
}
|
||
}
|
||
|
||
function resetPasswordForm() {
|
||
pwdForm.oldPassword = '';
|
||
pwdForm.newPassword = '';
|
||
pwdForm.confirmPassword = '';
|
||
}
|
||
|
||
function openChangePasswordModal() {
|
||
resetPasswordForm();
|
||
changePasswordVisible.value = true;
|
||
}
|
||
|
||
function handleChangePasswordCancel() {
|
||
changePasswordVisible.value = false;
|
||
resetPasswordForm();
|
||
}
|
||
|
||
async function handleChangePasswordSubmit() {
|
||
try {
|
||
await pwdFormRef.value?.validate();
|
||
} catch {
|
||
return;
|
||
}
|
||
|
||
changePasswordLoading.value = true;
|
||
try {
|
||
await AuthService.postRbacAuthChangePassword({
|
||
oldPassword: pwdForm.oldPassword,
|
||
newPassword: pwdForm.newPassword,
|
||
});
|
||
Message.success(t('profile.changePasswordSuccess'));
|
||
changePasswordVisible.value = false;
|
||
resetPasswordForm();
|
||
const loginType = rbacUserStore.resolveLoginTypeForRedirect();
|
||
const currentPath = router.currentRoute.value.fullPath;
|
||
rbacUserStore.logout();
|
||
userStore.logout();
|
||
const target = resolvePostLogoutLogin({ loginType, path: currentPath });
|
||
if (target.path) {
|
||
router.replace({ path: target.path, query: target.query });
|
||
} else {
|
||
router.replace({ name: target.name, query: target.query });
|
||
}
|
||
} catch (err: any) {
|
||
if (err?.errors || err?.errorFields) return;
|
||
Message.error(err?.message || t('profile.changePasswordFailed'));
|
||
} finally {
|
||
changePasswordLoading.value = false;
|
||
}
|
||
}
|
||
|
||
function closeMenu() {
|
||
menuVisible.value = false;
|
||
}
|
||
|
||
async function onPanelAction(key: string) {
|
||
// 切语言留在面板内,其它操作关闭;先收起下拉再跳转,避免弹层卸掉时主区宽度闪缩
|
||
if (!key.startsWith('lang:')) {
|
||
closeMenu();
|
||
await nextTick();
|
||
}
|
||
void onMenuClick({ key });
|
||
}
|
||
|
||
const onDropdownSelect = (value: string | number | Record<string, unknown> | undefined) => {
|
||
if (value === undefined || value === null) return;
|
||
onMenuClick({ key: String(value) });
|
||
};
|
||
|
||
const onMenuClick = async (event: { key: string }) => {
|
||
const { key } = event;
|
||
|
||
if (key === 'recharge') {
|
||
router.push({ name: 'VipRechargeDeposit' }).catch(() => undefined);
|
||
return;
|
||
}
|
||
|
||
if (key.startsWith('account:')) {
|
||
const path = key.slice('account:'.length);
|
||
const item = accountMenus.value.find(
|
||
(m) => getCustomerNavPath(m) === path || String(m.id || m.name) === path,
|
||
);
|
||
if (item) openAccountMenuItem(item);
|
||
return;
|
||
}
|
||
|
||
if (key.startsWith('lang:')) {
|
||
const next = key.slice('lang:'.length);
|
||
if (next && next !== currentLanguage.value) {
|
||
changeLocale(next);
|
||
}
|
||
return;
|
||
}
|
||
|
||
if (key === 'logout') {
|
||
const loginType = rbacUserStore.resolveLoginTypeForRedirect();
|
||
const currentPath = router.currentRoute.value.fullPath;
|
||
rbacUserStore.logout();
|
||
userStore.logout();
|
||
const target = resolvePostLogoutLogin({ loginType, path: currentPath });
|
||
if (target.path) {
|
||
router.push({ path: target.path, query: target.query });
|
||
} else {
|
||
router.push({ name: target.name, query: target.query });
|
||
}
|
||
} else if (key === 'userinfo') {
|
||
openPortalSideDrawer('profile');
|
||
} else if (key === 'changePassword') {
|
||
openChangePasswordModal();
|
||
} else if (key === 'settings') {
|
||
void appStore.openGlobalSettings();
|
||
}
|
||
};
|
||
</script>
|
||
|
||
<style scoped>
|
||
.user-dropdown-trigger {
|
||
display: inline-flex;
|
||
align-items: center;
|
||
gap: 6px;
|
||
max-width: 180px;
|
||
height: 28px;
|
||
padding: 0 8px;
|
||
border-radius: 8px;
|
||
white-space: nowrap;
|
||
cursor: pointer;
|
||
color: inherit;
|
||
text-decoration: none;
|
||
transition: background-color 0.15s ease, opacity 0.15s ease;
|
||
}
|
||
|
||
.user-dropdown-trigger.is-compact {
|
||
max-width: none;
|
||
width: 28px;
|
||
height: 28px;
|
||
padding: 0;
|
||
justify-content: center;
|
||
}
|
||
|
||
.user-dropdown-trigger:hover {
|
||
background-color: rgba(0, 0, 0, 0.05);
|
||
}
|
||
|
||
.user-avatar {
|
||
width: 22px;
|
||
height: 22px;
|
||
border-radius: 50%;
|
||
object-fit: cover;
|
||
flex-shrink: 0;
|
||
background: var(--color-fill-3, #e5e6eb);
|
||
}
|
||
|
||
.user-avatar--fallback {
|
||
display: inline-flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
font-size: 12px;
|
||
font-weight: 600;
|
||
color: var(--color-text-1, #1d2129);
|
||
background: var(--color-fill-3, #e5e6eb);
|
||
}
|
||
|
||
.user-name {
|
||
white-space: nowrap;
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
max-width: 140px;
|
||
font-size: 13px;
|
||
line-height: 28px;
|
||
}
|
||
|
||
.user-menu-item {
|
||
display: inline-flex;
|
||
align-items: center;
|
||
width: max-content;
|
||
max-width: 100%;
|
||
box-sizing: border-box;
|
||
line-height: 1.35;
|
||
}
|
||
|
||
.user-menu-item__icon {
|
||
width: 16px;
|
||
flex-shrink: 0;
|
||
display: inline-flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
margin-right: 8px;
|
||
font-size: 13px;
|
||
color: var(--color-text-3);
|
||
}
|
||
|
||
.user-menu-item__lang {
|
||
width: 22px;
|
||
height: 18px;
|
||
border-radius: 4px;
|
||
font-size: 11px;
|
||
font-weight: 600;
|
||
letter-spacing: 0.02em;
|
||
color: var(--color-text-2);
|
||
background: var(--color-fill-2, #f2f3f5);
|
||
}
|
||
|
||
.user-menu-item__label {
|
||
flex: 0 1 auto;
|
||
white-space: nowrap;
|
||
font-size: 13px;
|
||
font-weight: 500;
|
||
text-align: left;
|
||
}
|
||
|
||
.user-menu-item__hint {
|
||
margin-left: 8px;
|
||
color: var(--app-primary-color, rgb(var(--primary-6)));
|
||
font-weight: 600;
|
||
}
|
||
|
||
.user-menu-item.is-danger .user-menu-item__label {
|
||
color: rgb(var(--red-6));
|
||
}
|
||
</style>
|
||
|
||
<style lang="less">
|
||
.user-account-dropdown {
|
||
padding: 6px !important;
|
||
border-radius: 8px !important;
|
||
width: max-content !important;
|
||
|
||
.arco-dropdown {
|
||
min-width: 0;
|
||
width: max-content;
|
||
padding: 0;
|
||
}
|
||
|
||
.arco-dropdown-list {
|
||
padding: 0;
|
||
width: max-content;
|
||
}
|
||
|
||
.arco-dropdown-option {
|
||
min-height: 32px;
|
||
line-height: 1.35;
|
||
padding: 0;
|
||
width: 100%;
|
||
}
|
||
|
||
.arco-dropdown-option-content {
|
||
display: flex;
|
||
padding: 7px 12px;
|
||
width: 100%;
|
||
box-sizing: border-box;
|
||
}
|
||
}
|
||
|
||
/* Linear / Notion 式账户面板壳 */
|
||
.csr-account-dropdown {
|
||
width: 200px !important;
|
||
min-width: 200px !important;
|
||
max-width: 200px !important;
|
||
padding: 0 !important;
|
||
border: 1px solid rgba(15, 23, 42, 0.08) !important;
|
||
border-radius: 14px !important;
|
||
box-shadow:
|
||
0 0 0 1px rgba(15, 23, 42, 0.03),
|
||
0 12px 40px rgba(15, 23, 42, 0.12),
|
||
0 2px 8px rgba(15, 23, 42, 0.04) !important;
|
||
overflow: hidden;
|
||
background: #fff !important;
|
||
|
||
.arco-dropdown {
|
||
width: 100%;
|
||
min-width: 0 !important;
|
||
padding: 0;
|
||
background: transparent;
|
||
box-shadow: none;
|
||
}
|
||
|
||
.arco-dropdown-list-wrapper,
|
||
.arco-scrollbar,
|
||
.arco-dropdown-list {
|
||
max-height: none !important;
|
||
padding: 0 !important;
|
||
margin: 0 !important;
|
||
}
|
||
|
||
.arco-scrollbar-container {
|
||
overflow-x: hidden !important;
|
||
}
|
||
|
||
.arco-scrollbar-track-direction-horizontal {
|
||
display: none !important;
|
||
}
|
||
}
|
||
|
||
.csr-user-panel {
|
||
width: 200px;
|
||
max-width: 200px;
|
||
box-sizing: border-box;
|
||
display: flex;
|
||
flex-direction: column;
|
||
overflow-x: hidden;
|
||
background: #fff;
|
||
color: #1a2e38;
|
||
|
||
&__body {
|
||
padding: 4px 6px 6px;
|
||
max-height: min(60vh, 460px);
|
||
overflow-x: hidden;
|
||
overflow-y: auto;
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 0;
|
||
}
|
||
|
||
&__section {
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 0;
|
||
padding: 2px 0 4px;
|
||
|
||
& + & {
|
||
border-top: 1px solid rgba(15, 23, 42, 0.06);
|
||
margin-top: 2px;
|
||
padding-top: 4px;
|
||
}
|
||
}
|
||
|
||
&__section-label {
|
||
padding: 4px 10px 2px;
|
||
font-size: 11px;
|
||
font-weight: 600;
|
||
letter-spacing: 0.04em;
|
||
text-transform: uppercase;
|
||
color: rgba(26, 46, 56, 0.38);
|
||
user-select: none;
|
||
}
|
||
|
||
&__footer {
|
||
padding: 4px 6px 6px;
|
||
border-top: 1px solid rgba(15, 23, 42, 0.06);
|
||
}
|
||
|
||
&__item {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 10px;
|
||
width: 100%;
|
||
min-height: 34px;
|
||
padding: 0 10px;
|
||
border: none;
|
||
border-radius: 8px;
|
||
background: transparent;
|
||
color: #1a2e38;
|
||
font-size: 13px;
|
||
font-weight: 500;
|
||
text-align: left;
|
||
cursor: pointer;
|
||
transition: background-color 0.12s ease, color 0.12s ease;
|
||
|
||
&:hover {
|
||
background: rgba(15, 23, 42, 0.045);
|
||
}
|
||
|
||
&:active {
|
||
background: rgba(15, 23, 42, 0.07);
|
||
}
|
||
|
||
&.is-danger {
|
||
color: #c93c37;
|
||
justify-content: flex-start;
|
||
|
||
.csr-user-panel__item-icon {
|
||
color: #c93c37;
|
||
background: rgba(201, 60, 55, 0.08);
|
||
}
|
||
|
||
&:hover {
|
||
background: rgba(201, 60, 55, 0.06);
|
||
}
|
||
}
|
||
}
|
||
|
||
&__item-icon {
|
||
width: 26px;
|
||
height: 26px;
|
||
flex-shrink: 0;
|
||
display: inline-flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
border-radius: 999px;
|
||
font-size: 13px;
|
||
line-height: 0;
|
||
color: rgba(26, 46, 56, 0.55);
|
||
background: rgba(26, 46, 56, 0.05);
|
||
}
|
||
|
||
&__item-label {
|
||
flex: 1;
|
||
min-width: 0;
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
white-space: nowrap;
|
||
}
|
||
|
||
&__item-extra {
|
||
flex-shrink: 0;
|
||
min-width: 24px;
|
||
padding: 2px 7px;
|
||
border-radius: 999px;
|
||
background: rgba(15, 23, 42, 0.05);
|
||
color: rgba(26, 46, 56, 0.62);
|
||
font-size: 11px;
|
||
font-weight: 650;
|
||
letter-spacing: 0.02em;
|
||
line-height: 1.4;
|
||
text-align: center;
|
||
}
|
||
|
||
&__hint {
|
||
margin-left: 8px;
|
||
color: var(--app-primary-color, rgb(var(--primary-6)));
|
||
font-weight: 600;
|
||
}
|
||
}
|
||
|
||
.csr-dock-dropdown {
|
||
.arco-dropdown-option {
|
||
padding: 0 4px;
|
||
}
|
||
|
||
.arco-dropdown-option-content {
|
||
padding: 8px 10px;
|
||
border-radius: 6px;
|
||
}
|
||
}
|
||
</style>
|