fix: the brand color setting does not take effect (#4405)
parent
38fe6426a2
commit
c3d0102cda
|
@ -14,6 +14,7 @@ function generatorColorVariables(colorItems: ColorItem[]) {
|
|||
colorItems.forEach(({ alias, color, name }) => {
|
||||
if (color) {
|
||||
const colorsMap = getColors(new TinyColor(color).toHexString());
|
||||
|
||||
let mainColor = colorsMap['500'];
|
||||
|
||||
const colorKeys = Object.keys(colorsMap);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
|
||||
import { openWindow } from '../window'; // 假设你的函数在 'openWindow' 文件中
|
||||
import { openWindow } from '../window';
|
||||
|
||||
describe('openWindow', () => {
|
||||
// 保存原始的 window.open 函数
|
||||
|
|
|
@ -86,21 +86,22 @@ function updateMainColorVariables(preference: Preferences) {
|
|||
{ alias: 'destructive', color: colorDestructive, name: 'red' },
|
||||
]);
|
||||
|
||||
if (colorPrimary) {
|
||||
const mainColor = colorVariables['--primary-500'];
|
||||
mainColor &&
|
||||
document.documentElement.style.setProperty('--primary', mainColor);
|
||||
}
|
||||
// 要设置的 CSS 变量映射
|
||||
const colorMappings = {
|
||||
'--green-500': '--success',
|
||||
'--primary-500': '--primary',
|
||||
'--red-500': '--destructive',
|
||||
'--yellow-500': '--warning',
|
||||
};
|
||||
|
||||
// 统一处理颜色变量的更新
|
||||
Object.entries(colorMappings).forEach(([sourceVar, targetVar]) => {
|
||||
const colorValue = colorVariables[sourceVar];
|
||||
if (colorValue) {
|
||||
document.documentElement.style.setProperty(targetVar, colorValue);
|
||||
}
|
||||
});
|
||||
|
||||
if (colorVariables['--green-500']) {
|
||||
colorVariables['--success'] = colorVariables['--green-500'];
|
||||
}
|
||||
if (colorVariables['--yellow-500']) {
|
||||
colorVariables['--warning'] = colorVariables['--yellow-500'];
|
||||
}
|
||||
if (colorVariables['--red-500']) {
|
||||
colorVariables['--destructive'] = colorVariables['--red-500'];
|
||||
}
|
||||
executeUpdateCSSVariables(colorVariables);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import type { ModalState } from '../modal';
|
||||
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
// 假设 ModalApi 位于同一目录
|
||||
|
||||
import { ModalApi } from '../modal-api';
|
||||
|
||||
vi.mock('@vben-core/shared/store', () => {
|
||||
|
|
|
@ -52,7 +52,9 @@ defineExpose({
|
|||
|
||||
<template>
|
||||
<DialogPortal>
|
||||
<DialogOverlay v-if="open && modal" @click="() => emits('close')" />
|
||||
<Transition name="fade">
|
||||
<DialogOverlay v-if="open && modal" @click="() => emits('close')" />
|
||||
</Transition>
|
||||
<DialogContent
|
||||
ref="contentRef"
|
||||
v-bind="forwarded"
|
||||
|
|
|
@ -5,7 +5,7 @@ useScrollLock();
|
|||
</script>
|
||||
<template>
|
||||
<div
|
||||
class="data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 bg-overlay fixed inset-0 z-[1000]"
|
||||
class="bg-overlay fixed inset-0 z-[1000]"
|
||||
data-dismissable-modal="true"
|
||||
></div>
|
||||
</template>
|
||||
|
|
|
@ -46,7 +46,9 @@ const forwarded = useForwardPropsEmits(delegatedProps, emits);
|
|||
|
||||
<template>
|
||||
<DialogPortal>
|
||||
<SheetOverlay v-if="open && modal" />
|
||||
<Transition name="fade">
|
||||
<SheetOverlay v-if="open && modal" />
|
||||
</Transition>
|
||||
<DialogContent
|
||||
:class="cn(sheetVariants({ side }), 'z-[1000]', props.class)"
|
||||
v-bind="{ ...forwarded, ...$attrs }"
|
||||
|
|
|
@ -5,7 +5,7 @@ useScrollLock();
|
|||
</script>
|
||||
<template>
|
||||
<div
|
||||
class="bg-overlay data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-[1000]"
|
||||
class="bg-overlay fixed inset-0 z-[1000]"
|
||||
data-dismissable-modal="true"
|
||||
></div>
|
||||
</template>
|
||||
|
|
|
@ -5,7 +5,6 @@ import { useLockStore } from './lock';
|
|||
|
||||
describe('useLockStore', () => {
|
||||
beforeEach(() => {
|
||||
// 每个测试前重置 Pinia
|
||||
setActivePinia(createPinia());
|
||||
});
|
||||
|
||||
|
|
|
@ -63,12 +63,11 @@ describe('useAccessStore', () => {
|
|||
store.tabs = [
|
||||
{ fullPath: '/home', meta: {}, name: 'Home', path: '/home' },
|
||||
] as any;
|
||||
router.replace = vi.fn(); // 使用 vitest 的 mock 函数
|
||||
router.replace = vi.fn();
|
||||
|
||||
await store.closeAllTabs(router);
|
||||
|
||||
expect(store.tabs.length).toBe(1); // 假设没有固定的标签页
|
||||
// expect(router.replace).toHaveBeenCalled();
|
||||
expect(store.tabs.length).toBe(1);
|
||||
});
|
||||
|
||||
it('closes a non-affix tab', () => {
|
||||
|
@ -161,7 +160,7 @@ describe('useAccessStore', () => {
|
|||
await store._bulkCloseByPaths(['/home', '/contact']);
|
||||
|
||||
expect(store.tabs).toHaveLength(1);
|
||||
expect(store.tabs[0].name).toBe('About');
|
||||
expect(store.tabs[0]?.name).toBe('About');
|
||||
});
|
||||
|
||||
it('closes all tabs to the left of the specified tab', async () => {
|
||||
|
@ -189,7 +188,7 @@ describe('useAccessStore', () => {
|
|||
await store.closeLeftTabs(targetTab);
|
||||
|
||||
expect(store.tabs).toHaveLength(1);
|
||||
expect(store.tabs[0].name).toBe('Contact');
|
||||
expect(store.tabs[0]?.name).toBe('Contact');
|
||||
});
|
||||
|
||||
it('closes all tabs except the specified tab', async () => {
|
||||
|
@ -217,7 +216,7 @@ describe('useAccessStore', () => {
|
|||
await store.closeOtherTabs(targetTab);
|
||||
|
||||
expect(store.tabs).toHaveLength(1);
|
||||
expect(store.tabs[0].name).toBe('About');
|
||||
expect(store.tabs[0]?.name).toBe('About');
|
||||
});
|
||||
|
||||
it('closes all tabs to the right of the specified tab', async () => {
|
||||
|
@ -245,7 +244,7 @@ describe('useAccessStore', () => {
|
|||
await store.closeRightTabs(targetTab);
|
||||
|
||||
expect(store.tabs).toHaveLength(1);
|
||||
expect(store.tabs[0].name).toBe('Home');
|
||||
expect(store.tabs[0]?.name).toBe('Home');
|
||||
});
|
||||
|
||||
it('closes the tab with the specified key', async () => {
|
||||
|
|
|
@ -24,7 +24,7 @@ describe('useUserStore', () => {
|
|||
expect(store.userInfo).not.toBeNull();
|
||||
expect(store.userRoles.length).toBeGreaterThan(0);
|
||||
|
||||
store.setUserInfo(null as any); // 重置用户信息
|
||||
store.setUserInfo(null as any);
|
||||
expect(store.userInfo).toBeNull();
|
||||
expect(store.userRoles).toEqual([]);
|
||||
});
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
import {
|
||||
createRouter,
|
||||
createWebHistory,
|
||||
type Router,
|
||||
type RouteRecordRaw,
|
||||
} from 'vue-router';
|
||||
import type { Router, RouteRecordRaw } from 'vue-router';
|
||||
|
||||
import { createRouter, createWebHistory } from 'vue-router';
|
||||
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
// 替换为您的实际路径
|
||||
|
||||
import { generateMenus } from '../generate-menus';
|
||||
|
||||
// Nested route setup to test child inclusion and hideChildrenInMenu functionality
|
||||
|
|
|
@ -9,4 +9,5 @@ export const overridesPreferences = defineOverridesPreferences({
|
|||
app: {
|
||||
name: import.meta.env.VITE_APP_TITLE,
|
||||
},
|
||||
theme: {},
|
||||
});
|
||||
|
|
|
@ -24,7 +24,7 @@ async function handleClick(type: LoginExpiredModeType) {
|
|||
接口请求遇到401状态码时,需要重新登录。有两种方式:
|
||||
<p>1.转到登录页,登录成功后跳转回原页面</p>
|
||||
<p>
|
||||
2.弹出重新登录弹窗,登录后关闭弹窗,不进行任何页面跳转(刷新后调整登录页面)
|
||||
2.弹出重新登录弹窗,登录后关闭弹窗,不进行任何页面跳转(刷新后还是会跳转登录页面)
|
||||
</p>
|
||||
</div>
|
||||
</template>
|
||||
|
|
Loading…
Reference in New Issue