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