This commit is contained in:
dap
2024-08-30 10:15:41 +08:00
73 changed files with 329 additions and 155 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@vben-core/design",
"version": "5.1.2",
"version": "5.2.0",
"homepage": "https://github.com/vbenjs/vue-vben-admin",
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
"repository": {

View File

@@ -28,7 +28,7 @@
/* 主题颜色 */
--primary: 211 91% 39%;
--primary: 231 98% 65%;
--primary-foreground: 0 0% 98%;
/* Used for destructive actions such as <Button variant="destructive"> */

View File

@@ -1,6 +1,6 @@
{
"name": "@vben-core/icons",
"version": "5.1.2",
"version": "5.2.0",
"homepage": "https://github.com/vbenjs/vue-vben-admin",
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
"repository": {

View File

@@ -1,6 +1,6 @@
{
"name": "@vben-core/shared",
"version": "5.1.2",
"version": "5.2.0",
"homepage": "https://github.com/vbenjs/vue-vben-admin",
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
"repository": {

View File

@@ -1,6 +1,6 @@
{
"name": "@vben-core/typings",
"version": "5.1.2",
"version": "5.2.0",
"homepage": "https://github.com/vbenjs/vue-vben-admin",
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
"repository": {

View File

@@ -1,6 +1,6 @@
{
"name": "@vben-core/composables",
"version": "5.1.2",
"version": "5.2.0",
"homepage": "https://github.com/vbenjs/vue-vben-admin",
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
"repository": {

View File

@@ -2,6 +2,7 @@ export * from './use-content-style';
export * from './use-is-mobile';
export * from './use-namespace';
export * from './use-priority-value';
export * from './use-simple-locale';
export * from './use-sortable';
export {
useEmitAsProps,

View File

@@ -0,0 +1,3 @@
# Simple i18n
Simple i18 implementation

View File

@@ -0,0 +1,25 @@
import { computed, ref } from 'vue';
import { createSharedComposable } from '@vueuse/core';
import { getMessages, type Locale } from './messages';
export const useSimpleLocale = createSharedComposable(() => {
const currentLocale = ref<Locale>('zh-CN');
const setSimpleLocale = (locale: Locale) => {
currentLocale.value = locale;
};
const $t = computed(() => {
const localeMessages = getMessages(currentLocale.value);
return (key: string) => {
return localeMessages[key] || key;
};
});
return {
$t,
currentLocale,
setSimpleLocale,
};
});

View File

@@ -0,0 +1,14 @@
export type Locale = 'en-US' | 'zh-CN';
export const messages: Record<Locale, Record<string, string>> = {
'en-US': {
cancel: 'Cancel',
confirm: 'Confirm',
},
'zh-CN': {
cancel: '取消',
confirm: '确认',
},
};
export const getMessages = (locale: Locale) => messages[locale];

View File

@@ -1,6 +1,6 @@
{
"name": "@vben-core/preferences",
"version": "5.1.2",
"version": "5.2.0",
"homepage": "https://github.com/vbenjs/vue-vben-admin",
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
"repository": {

View File

@@ -43,6 +43,13 @@ function usePreferences() {
isMobile.value ? 'sidebar-nav' : appPreferences.value.layout,
);
/**
* @zh_CN 是否显示顶栏
*/
const isShowHeaderNav = computed(() => {
return preferences.header.enable;
});
/**
* @zh_CN 是否全屏显示content不需要侧边、底部、顶部、tab区域
*/
@@ -180,7 +187,11 @@ function usePreferences() {
}
// 如果是全屏模式或者没有固定在顶部,
const fixed = contentIsMaximize || isFullContent.value || isMobile.value;
const fixed =
contentIsMaximize ||
isFullContent.value ||
isMobile.value ||
!isShowHeaderNav.value;
return {
fixed,

View File

@@ -1,6 +1,6 @@
{
"name": "@vben-core/layout-ui",
"version": "5.1.2",
"version": "5.2.0",
"homepage": "https://github.com/vbenjs/vue-vben-admin",
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
"repository": {

View File

@@ -1,6 +1,6 @@
{
"name": "@vben-core/menu-ui",
"version": "5.1.2",
"version": "5.2.0",
"homepage": "https://github.com/vbenjs/vue-vben-admin",
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
"repository": {

View File

@@ -44,8 +44,8 @@ describe('drawerApi', () => {
it('should initialize with default state', () => {
expect(drawerState.isOpen).toBe(false);
expect(drawerState.cancelText).toBe('取消');
expect(drawerState.confirmText).toBe('确定');
expect(drawerState.cancelText).toBe(undefined);
expect(drawerState.confirmText).toBe(undefined);
});
it('should open the drawer', () => {

View File

@@ -28,12 +28,10 @@ export class DrawerApi {
} = options;
const defaultState: DrawerState = {
cancelText: '取消',
closable: true,
closeOnClickModal: true,
closeOnPressEscape: true,
confirmLoading: false,
confirmText: '确定',
footer: true,
isOpen: false,
loading: false,

View File

@@ -3,7 +3,11 @@ import type { DrawerProps, ExtendedDrawerApi } from './drawer';
import { ref, watch } from 'vue';
import { useIsMobile, usePriorityValue } from '@vben-core/composables';
import {
useIsMobile,
usePriorityValue,
useSimpleLocale,
} from '@vben-core/composables';
import { Info, X } from '@vben-core/icons';
import {
Sheet,
@@ -34,7 +38,7 @@ const props = withDefaults(defineProps<Props>(), {
});
const wrapperRef = ref<HTMLElement>();
const { $t } = useSimpleLocale();
const { isMobile } = useIsMobile();
const state = props.drawerApi?.useStore?.();
@@ -165,7 +169,7 @@ function pointerDownOutside(e: Event) {
<slot name="footer">
<VbenButton variant="ghost" @click="() => drawerApi?.onCancel()">
<slot name="cancelText">
{{ cancelText }}
{{ cancelText || $t('cancel') }}
</slot>
</VbenButton>
<VbenButton
@@ -173,7 +177,7 @@ function pointerDownOutside(e: Event) {
@click="() => drawerApi?.onConfirm()"
>
<slot name="confirmText">
{{ confirmText }}
{{ confirmText || $t('confirm') }}
</slot>
</VbenButton>
</slot>

View File

@@ -44,8 +44,8 @@ describe('modalApi', () => {
it('should initialize with default state', () => {
expect(modalState.isOpen).toBe(false);
expect(modalState.cancelText).toBe('取消');
expect(modalState.confirmText).toBe('确定');
expect(modalState.cancelText).toBe(undefined);
expect(modalState.confirmText).toBe(undefined);
});
it('should open the modal', () => {

View File

@@ -28,12 +28,10 @@ export class ModalApi {
} = options;
const defaultState: ModalState = {
cancelText: '取消',
centered: false,
closeOnClickModal: true,
closeOnPressEscape: true,
confirmLoading: false,
confirmText: '确定',
draggable: false,
footer: true,
fullscreen: false,

View File

@@ -3,7 +3,11 @@ import type { ExtendedModalApi, ModalProps } from './modal';
import { computed, nextTick, ref, watch } from 'vue';
import { useIsMobile, usePriorityValue } from '@vben-core/composables';
import {
useIsMobile,
usePriorityValue,
useSimpleLocale,
} from '@vben-core/composables';
import { Expand, Info, Shrink } from '@vben-core/icons';
import {
Dialog,
@@ -44,6 +48,7 @@ const dialogRef = ref();
const headerRef = ref();
const footerRef = ref();
const { $t } = useSimpleLocale();
const { isMobile } = useIsMobile();
const state = props.modalApi?.useStore?.();
@@ -235,7 +240,7 @@ function pointerDownOutside(e: Event) {
<slot name="footer">
<VbenButton variant="ghost" @click="() => modalApi?.onCancel()">
<slot name="cancelText">
{{ cancelText }}
{{ cancelText || $t('cancel') }}
</slot>
</VbenButton>
<VbenButton
@@ -243,7 +248,7 @@ function pointerDownOutside(e: Event) {
@click="() => modalApi?.onConfirm()"
>
<slot name="confirmText">
{{ confirmText }}
{{ confirmText || $t('confirm') }}
</slot>
</VbenButton>
</slot>

View File

@@ -1,6 +1,6 @@
{
"name": "@vben-core/shadcn-ui",
"version": "5.1.2",
"version": "5.2.0",
"homepage": "https://github.com/vbenjs/vue-vben-admin",
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
"repository": {

View File

@@ -53,10 +53,7 @@ withDefaults(defineProps<Props>(), {
:width="logoSize"
class="relative rounded-none bg-transparent"
/>
<span
v-if="!collapsed"
class="text-primary dark:text-foreground truncate text-nowrap"
>
<span v-if="!collapsed" class="text-foreground truncate text-nowrap">
{{ text }}
</span>
</a>

View File

@@ -1,6 +1,6 @@
{
"name": "@vben-core/tabs-ui",
"version": "5.1.2",
"version": "5.2.0",
"homepage": "https://github.com/vbenjs/vue-vben-admin",
"bugs": "https://github.com/vbenjs/vue-vben-admin/issues",
"repository": {