mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-08-26 16:46:19 +08:00
feat: core components support simple locale switching (#4273)
* feat: core components support simple locale switching * fix: test error * fix: test error
This commit is contained in:
@@ -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', () => {
|
||||
|
@@ -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,
|
||||
|
@@ -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>
|
||||
|
@@ -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', () => {
|
||||
|
@@ -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,
|
||||
|
@@ -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>
|
||||
|
@@ -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>
|
||||
|
Reference in New Issue
Block a user