Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
monorepo
/
venus
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
1
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit c3d0102c
authored
Sep 14, 2024
by
Vben
Committed by
GitHub
Sep 14, 2024
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix: the brand color setting does not take effect (#4405)
1 parent
38fe6426
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
39 additions
and
37 deletions
packages/@core/base/shared/src/color/generator.ts
packages/@core/base/shared/src/utils/__tests__/window.test.ts
packages/@core/preferences/src/update-css-variables.ts
packages/@core/ui-kit/popup-ui/src/modal/__tests__/modal-api.test.ts
packages/@core/ui-kit/shadcn-ui/src/components/ui/dialog/DialogContent.vue
packages/@core/ui-kit/shadcn-ui/src/components/ui/dialog/DialogOverlay.vue
packages/@core/ui-kit/shadcn-ui/src/components/ui/sheet/SheetContent.vue
packages/@core/ui-kit/shadcn-ui/src/components/ui/sheet/SheetOverlay.vue
packages/stores/src/modules/lock.test.ts
packages/stores/src/modules/tabbar.test.ts
packages/stores/src/modules/user.test.ts
packages/utils/src/helpers/__tests__/generate-menus.test.ts
playground/src/preferences.ts
playground/src/views/demos/features/login-expired/index.vue
packages/@core/base/shared/src/color/generator.ts
View file @
c3d0102
...
@@ -14,6 +14,7 @@ function generatorColorVariables(colorItems: ColorItem[]) {
...
@@ -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
);
...
...
packages/@core/base/shared/src/utils/__tests__/window.test.ts
View file @
c3d0102
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 函数
...
...
packages/@core/preferences/src/update-css-variables.ts
View file @
c3d0102
...
@@ -86,21 +86,22 @@ function updateMainColorVariables(preference: Preferences) {
...
@@ -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
);
}
}
...
...
packages/@core/ui-kit/popup-ui/src/modal/__tests__/modal-api.test.ts
View file @
c3d0102
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'
,
()
=>
{
...
...
packages/@core/ui-kit/shadcn-ui/src/components/ui/dialog/DialogContent.vue
View file @
c3d0102
...
@@ -52,7 +52,9 @@ defineExpose({
...
@@ -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"
...
...
packages/@core/ui-kit/shadcn-ui/src/components/ui/dialog/DialogOverlay.vue
View file @
c3d0102
...
@@ -5,7 +5,7 @@ useScrollLock();
...
@@ -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
>
packages/@core/ui-kit/shadcn-ui/src/components/ui/sheet/SheetContent.vue
View file @
c3d0102
...
@@ -46,7 +46,9 @@ const forwarded = useForwardPropsEmits(delegatedProps, emits);
...
@@ -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 }"
...
...
packages/@core/ui-kit/shadcn-ui/src/components/ui/sheet/SheetOverlay.vue
View file @
c3d0102
...
@@ -5,7 +5,7 @@ useScrollLock();
...
@@ -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
>
packages/stores/src/modules/lock.test.ts
View file @
c3d0102
...
@@ -5,7 +5,6 @@ import { useLockStore } from './lock';
...
@@ -5,7 +5,6 @@ import { useLockStore } from './lock';
describe
(
'useLockStore'
,
()
=>
{
describe
(
'useLockStore'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
// 每个测试前重置 Pinia
setActivePinia
(
createPinia
());
setActivePinia
(
createPinia
());
});
});
...
...
packages/stores/src/modules/tabbar.test.ts
View file @
c3d0102
...
@@ -63,12 +63,11 @@ describe('useAccessStore', () => {
...
@@ -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', () => {
...
@@ -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', () => {
...
@@ -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', () => {
...
@@ -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', () => {
...
@@ -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
()
=>
{
...
...
packages/stores/src/modules/user.test.ts
View file @
c3d0102
...
@@ -24,7 +24,7 @@ describe('useUserStore', () => {
...
@@ -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
([]);
});
});
...
...
packages/utils/src/helpers/__tests__/generate-menus.test.ts
View file @
c3d0102
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
...
...
playground/src/preferences.ts
View file @
c3d0102
...
@@ -9,4 +9,5 @@ export const overridesPreferences = defineOverridesPreferences({
...
@@ -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
:
{},
});
});
playground/src/views/demos/features/login-expired/index.vue
View file @
c3d0102
...
@@ -24,7 +24,7 @@ async function handleClick(type: LoginExpiredModeType) {
...
@@ -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
>
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment