Merge branch 'main' of https://github.com/vbenjs/vue-vben-admin
This commit is contained in:
@@ -37,6 +37,7 @@ exports[`defaultPreferences immutability test > should not modify the config obj
|
||||
"enable": true,
|
||||
"icp": "",
|
||||
"icpLink": "",
|
||||
"settingShow": true,
|
||||
},
|
||||
"footer": {
|
||||
"enable": false,
|
||||
@@ -73,7 +74,7 @@ exports[`defaultPreferences immutability test > should not modify the config obj
|
||||
"width": 224,
|
||||
},
|
||||
"tabbar": {
|
||||
"dragable": true,
|
||||
"draggable": true,
|
||||
"enable": true,
|
||||
"height": 38,
|
||||
"keepAlive": true,
|
||||
|
@@ -37,6 +37,7 @@ const defaultPreferences: Preferences = {
|
||||
enable: true,
|
||||
icp: '',
|
||||
icpLink: '',
|
||||
settingShow: true,
|
||||
},
|
||||
footer: {
|
||||
enable: false,
|
||||
@@ -73,7 +74,7 @@ const defaultPreferences: Preferences = {
|
||||
width: 224,
|
||||
},
|
||||
tabbar: {
|
||||
dragable: true,
|
||||
draggable: true,
|
||||
enable: true,
|
||||
height: 38,
|
||||
keepAlive: true,
|
||||
|
@@ -88,6 +88,8 @@ interface CopyrightPreferences {
|
||||
icp: string;
|
||||
/** 备案号链接 */
|
||||
icpLink: string;
|
||||
/** 设置面板是否显示*/
|
||||
settingShow?: boolean;
|
||||
}
|
||||
|
||||
interface FooterPreferences {
|
||||
@@ -154,7 +156,7 @@ interface ShortcutKeyPreferences {
|
||||
|
||||
interface TabbarPreferences {
|
||||
/** 是否开启多标签页拖拽 */
|
||||
dragable: boolean;
|
||||
draggable: boolean;
|
||||
/** 是否开启多标签页 */
|
||||
enable: boolean;
|
||||
/** 标签页高度 */
|
||||
|
@@ -69,7 +69,7 @@ const tabsView = computed((): TabConfig[] => {
|
||||
v-for="(tab, i) in tabsView"
|
||||
:key="tab.key"
|
||||
ref="tabRef"
|
||||
:class="[{ 'is-active': tab.key === active, dragable: !tab.affixTab }]"
|
||||
:class="[{ 'is-active': tab.key === active, draggable: !tab.affixTab }]"
|
||||
:data-active-tab="active"
|
||||
:data-index="i"
|
||||
class="tabs-chrome__item draggable translate-all group relative -mr-3 flex h-full select-none items-center"
|
||||
|
@@ -75,7 +75,7 @@ const tabsView = computed((): TabConfig[] => {
|
||||
:class="[
|
||||
{
|
||||
'is-active dark:bg-accent bg-primary/15': tab.key === active,
|
||||
dragable: !tab.affixTab,
|
||||
draggable: !tab.affixTab,
|
||||
},
|
||||
typeWithClass.content,
|
||||
]"
|
||||
|
@@ -17,7 +17,7 @@ defineOptions({
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
contentClass: 'vben-tabs-content',
|
||||
dragable: true,
|
||||
draggable: true,
|
||||
styleType: 'chrome',
|
||||
});
|
||||
|
||||
|
@@ -21,7 +21,7 @@ export interface TabsProps {
|
||||
/**
|
||||
* @zh_CN 是否可以拖拽
|
||||
*/
|
||||
dragable?: boolean;
|
||||
draggable?: boolean;
|
||||
/**
|
||||
* @zh_CN 间隙
|
||||
* @default 7
|
||||
|
@@ -42,8 +42,8 @@ export function useTabsDrag(props: TabsProps, emit: EmitType) {
|
||||
const { initializeSortable } = useSortable(el, {
|
||||
filter: (_evt, target: HTMLElement) => {
|
||||
const parent = findParentElement(target);
|
||||
const dragable = parent?.classList.contains('dragable');
|
||||
return !dragable || !props.dragable;
|
||||
const draggable = parent?.classList.contains('draggable');
|
||||
return !draggable || !props.draggable;
|
||||
},
|
||||
onEnd(evt) {
|
||||
const { newIndex, oldIndex } = evt;
|
||||
@@ -62,7 +62,7 @@ export function useTabsDrag(props: TabsProps, emit: EmitType) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!srcParent.classList.contains('dragable')) {
|
||||
if (!srcParent.classList.contains('draggable')) {
|
||||
resetElState();
|
||||
|
||||
return;
|
||||
@@ -81,7 +81,7 @@ export function useTabsDrag(props: TabsProps, emit: EmitType) {
|
||||
},
|
||||
onMove(evt) {
|
||||
const parent = findParentElement(evt.related);
|
||||
return parent?.classList.contains('dragable') && props.dragable;
|
||||
return parent?.classList.contains('draggable') && props.draggable;
|
||||
},
|
||||
onStart: () => {
|
||||
el.style.cursor = 'grabbing';
|
||||
|
@@ -1 +0,0 @@
|
||||
export { default } from '@vben/tailwind-config/postcss';
|
@@ -1 +0,0 @@
|
||||
export { default } from '@vben/tailwind-config';
|
@@ -1 +0,0 @@
|
||||
export { default } from '@vben/tailwind-config/postcss';
|
@@ -1 +0,0 @@
|
||||
export { default } from '@vben/tailwind-config';
|
@@ -1 +0,0 @@
|
||||
export { default } from '@vben/tailwind-config/postcss';
|
@@ -118,7 +118,7 @@ function clearPreferencesAndLogout() {
|
||||
>
|
||||
<slot :name="slot.name">
|
||||
<template v-if="slot.name === 'refresh'">
|
||||
<VbenIconButton class="my-0 rounded-md" @click="refresh">
|
||||
<VbenIconButton class="my-0 mr-1 rounded-md" @click="refresh">
|
||||
<RotateCw class="size-4" />
|
||||
</VbenIconButton>
|
||||
</template>
|
||||
|
@@ -51,7 +51,7 @@ if (!preferences.tabbar.persist) {
|
||||
:active="currentActive"
|
||||
:class="theme"
|
||||
:context-menus="createContextMenus"
|
||||
:dragable="preferences.tabbar.dragable"
|
||||
:draggable="preferences.tabbar.draggable"
|
||||
:show-icon="showIcon"
|
||||
:style-type="preferences.tabbar.styleType"
|
||||
:tabs="currentTabs"
|
||||
|
@@ -6,10 +6,6 @@ import { $t } from '@vben/locales';
|
||||
import InputItem from '../input-item.vue';
|
||||
import SwitchItem from '../switch-item.vue';
|
||||
|
||||
defineOptions({
|
||||
name: 'PreferenceBreadcrumbConfig',
|
||||
});
|
||||
|
||||
const props = defineProps<{ disabled: boolean }>();
|
||||
|
||||
const copyrightEnable = defineModel<boolean>('copyrightEnable');
|
||||
|
@@ -3,10 +3,6 @@ import { $t } from '@vben/locales';
|
||||
|
||||
import SwitchItem from '../switch-item.vue';
|
||||
|
||||
defineOptions({
|
||||
name: 'PreferenceBreadcrumbConfig',
|
||||
});
|
||||
|
||||
const footerEnable = defineModel<boolean>('footerEnable');
|
||||
const footerFixed = defineModel<boolean>('footerFixed');
|
||||
</script>
|
||||
|
@@ -6,10 +6,6 @@ import { $t } from '@vben/locales';
|
||||
import SelectItem from '../select-item.vue';
|
||||
import SwitchItem from '../switch-item.vue';
|
||||
|
||||
defineOptions({
|
||||
name: 'PreferenceBreadcrumbConfig',
|
||||
});
|
||||
|
||||
defineProps<{ disabled: boolean }>();
|
||||
|
||||
const headerEnable = defineModel<boolean>('headerEnable');
|
||||
|
@@ -4,10 +4,6 @@ import { $t } from '@vben/locales';
|
||||
import NumberFieldItem from '../number-field-item.vue';
|
||||
import SwitchItem from '../switch-item.vue';
|
||||
|
||||
defineOptions({
|
||||
name: 'PreferenceBreadcrumbConfig',
|
||||
});
|
||||
|
||||
defineProps<{ disabled: boolean }>();
|
||||
|
||||
const sidebarEnable = defineModel<boolean>('sidebarEnable');
|
||||
|
@@ -17,7 +17,7 @@ defineProps<{ disabled?: boolean }>();
|
||||
const tabbarEnable = defineModel<boolean>('tabbarEnable');
|
||||
const tabbarShowIcon = defineModel<boolean>('tabbarShowIcon');
|
||||
const tabbarPersist = defineModel<boolean>('tabbarPersist');
|
||||
const tabbarDragable = defineModel<boolean>('tabbarDragable');
|
||||
const tabbarDraggable = defineModel<boolean>('tabbarDraggable');
|
||||
const tabbarStyleType = defineModel<string>('tabbarStyleType');
|
||||
const tabbarShowMore = defineModel<boolean>('tabbarShowMore');
|
||||
const tabbarShowMaximize = defineModel<boolean>('tabbarShowMaximize');
|
||||
@@ -50,8 +50,8 @@ const styleItems = computed((): SelectOption[] => [
|
||||
<SwitchItem v-model="tabbarPersist" :disabled="!tabbarEnable">
|
||||
{{ $t('preferences.tabbar.persist') }}
|
||||
</SwitchItem>
|
||||
<SwitchItem v-model="tabbarDragable" :disabled="!tabbarEnable">
|
||||
{{ $t('preferences.tabbar.dragable') }}
|
||||
<SwitchItem v-model="tabbarDraggable" :disabled="!tabbarEnable">
|
||||
{{ $t('preferences.tabbar.draggable') }}
|
||||
</SwitchItem>
|
||||
<SwitchItem v-model="tabbarShowIcon" :disabled="!tabbarEnable">
|
||||
{{ $t('preferences.tabbar.icon') }}
|
||||
|
@@ -102,7 +102,7 @@ const tabbarShowIcon = defineModel<boolean>('tabbarShowIcon');
|
||||
const tabbarShowMore = defineModel<boolean>('tabbarShowMore');
|
||||
const tabbarShowMaximize = defineModel<boolean>('tabbarShowMaximize');
|
||||
const tabbarPersist = defineModel<boolean>('tabbarPersist');
|
||||
const tabbarDragable = defineModel<boolean>('tabbarDragable');
|
||||
const tabbarDraggable = defineModel<boolean>('tabbarDraggable');
|
||||
const tabbarStyleType = defineModel<string>('tabbarStyleType');
|
||||
|
||||
const navigationStyleType = defineModel<NavigationStyleType>(
|
||||
@@ -116,6 +116,7 @@ const navigationAccordion = defineModel<boolean>('navigationAccordion');
|
||||
const footerEnable = defineModel<boolean>('footerEnable');
|
||||
const footerFixed = defineModel<boolean>('footerFixed');
|
||||
|
||||
const copyrightSettingShow = defineModel<boolean>('copyrightSettingShow');
|
||||
const copyrightEnable = defineModel<boolean>('copyrightEnable');
|
||||
const copyrightCompanyName = defineModel<string>('copyrightCompanyName');
|
||||
const copyrightCompanySiteLink = defineModel<string>(
|
||||
@@ -339,7 +340,7 @@ async function handleReset() {
|
||||
</Block>
|
||||
<Block :title="$t('preferences.tabbar.title')">
|
||||
<Tabbar
|
||||
v-model:tabbar-dragable="tabbarDragable"
|
||||
v-model:tabbar-draggable="tabbarDraggable"
|
||||
v-model:tabbar-enable="tabbarEnable"
|
||||
v-model:tabbar-persist="tabbarPersist"
|
||||
v-model:tabbar-show-icon="tabbarShowIcon"
|
||||
@@ -369,7 +370,10 @@ async function handleReset() {
|
||||
v-model:footer-fixed="footerFixed"
|
||||
/>
|
||||
</Block>
|
||||
<Block :title="$t('preferences.copyright.title')">
|
||||
<Block
|
||||
v-if="copyrightSettingShow"
|
||||
:title="$t('preferences.copyright.title')"
|
||||
>
|
||||
<Copyright
|
||||
v-model:copyright-company-name="copyrightCompanyName"
|
||||
v-model:copyright-company-site-link="copyrightCompanySiteLink"
|
||||
|
@@ -1 +0,0 @@
|
||||
export { default } from '@vben/tailwind-config';
|
@@ -1 +0,0 @@
|
||||
export { default } from '@vben/tailwind-config/postcss';
|
50
packages/effects/plugins/src/vxe-table/extends.ts
Normal file
50
packages/effects/plugins/src/vxe-table/extends.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
import type { VxeGridProps } from 'vxe-table';
|
||||
|
||||
import type { VxeGridApi } from './api';
|
||||
|
||||
import { isFunction } from '@vben/utils';
|
||||
|
||||
export function extendProxyOptions(
|
||||
api: VxeGridApi,
|
||||
options: VxeGridProps,
|
||||
getFormValues: () => Record<string, any>,
|
||||
) {
|
||||
[
|
||||
'query',
|
||||
'querySuccess',
|
||||
'queryError',
|
||||
'queryAll',
|
||||
'queryAllSuccess',
|
||||
'queryAllError',
|
||||
].forEach((key) => {
|
||||
extendProxyOption(key, api, options, getFormValues);
|
||||
});
|
||||
}
|
||||
|
||||
function extendProxyOption(
|
||||
key: string,
|
||||
api: VxeGridApi,
|
||||
options: VxeGridProps,
|
||||
getFormValues: () => Record<string, any>,
|
||||
) {
|
||||
const { proxyConfig } = options;
|
||||
const configFn = (proxyConfig?.ajax as any)?.[key];
|
||||
if (!isFunction(configFn)) {
|
||||
return options;
|
||||
}
|
||||
|
||||
const wrapperFn = async (params: any, _formValues: any, ...args: any[]) => {
|
||||
const formValues = getFormValues();
|
||||
const data = await configFn(params, formValues, ...args);
|
||||
return data;
|
||||
};
|
||||
api.setState({
|
||||
gridOptions: {
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
[key]: wrapperFn,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
@@ -26,6 +26,7 @@ import { VbenLoading } from '@vben-core/shadcn-ui';
|
||||
|
||||
import { VxeGrid, VxeUI } from 'vxe-table';
|
||||
|
||||
import { extendProxyOptions } from './extends';
|
||||
import { useTableForm } from './init';
|
||||
|
||||
import 'vxe-table/styles/cssvar.scss';
|
||||
@@ -38,6 +39,8 @@ interface Props extends VxeGridProps {
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {});
|
||||
|
||||
const FORM_SLOT_PREFIX = 'form-';
|
||||
|
||||
const gridRef = useTemplateRef<VxeGridInstance>('gridRef');
|
||||
|
||||
const state = props.api?.useStore?.();
|
||||
@@ -172,11 +175,11 @@ const delegatedFormSlots = computed(() => {
|
||||
const resultSlots: string[] = [];
|
||||
|
||||
for (const key of Object.keys(slots)) {
|
||||
if (key.startsWith('form-')) {
|
||||
if (key.startsWith(FORM_SLOT_PREFIX)) {
|
||||
resultSlots.push(key);
|
||||
}
|
||||
}
|
||||
return resultSlots;
|
||||
return resultSlots.map((key) => key.replace(FORM_SLOT_PREFIX, ''));
|
||||
});
|
||||
|
||||
async function init() {
|
||||
@@ -191,7 +194,7 @@ async function init() {
|
||||
const autoLoad = defaultGridOptions.proxyConfig?.autoLoad;
|
||||
const enableProxyConfig = options.value.proxyConfig?.enabled;
|
||||
if (enableProxyConfig && autoLoad) {
|
||||
props.api.reload(formApi.form.values);
|
||||
props.api.reload(formApi.form?.values ?? {});
|
||||
}
|
||||
|
||||
// form 由 vben-form代替,所以不适配formConfig,这里给出警告
|
||||
@@ -201,6 +204,9 @@ async function init() {
|
||||
'[Vben Vxe Table]: The formConfig in the grid is not supported, please use the `formOptions` props',
|
||||
);
|
||||
}
|
||||
|
||||
// form 由 vben-form 代替,所以需要保证query相关事件可以拿到参数
|
||||
extendProxyOptions(props.api, defaultGridOptions, () => formApi.form.values);
|
||||
}
|
||||
|
||||
watch(
|
||||
|
@@ -1 +0,0 @@
|
||||
export { default } from '@vben/tailwind-config';
|
@@ -91,7 +91,7 @@ export const errorMessageResponseInterceptor = (
|
||||
return Promise.reject(error);
|
||||
}
|
||||
|
||||
let errorMessage = error?.response?.data?.error?.message ?? '';
|
||||
let errorMessage = '';
|
||||
const status = error?.response?.status;
|
||||
|
||||
switch (status) {
|
||||
|
@@ -215,7 +215,7 @@
|
||||
"showMore": "Show More Button",
|
||||
"showMaximize": "Show Maximize Button",
|
||||
"persist": "Persist Tabs",
|
||||
"dragable": "Enable Dragable Sort",
|
||||
"draggable": "Enable Draggable Sort",
|
||||
"styleType": {
|
||||
"title": "Tabs Style",
|
||||
"chrome": "Chrome",
|
||||
|
@@ -215,7 +215,7 @@
|
||||
"showMore": "显示更多按钮",
|
||||
"showMaximize": "显示最大化按钮",
|
||||
"persist": "持久化标签页",
|
||||
"dragable": "启动拖拽排序",
|
||||
"draggable": "启动拖拽排序",
|
||||
"styleType": {
|
||||
"title": "标签页风格",
|
||||
"chrome": "谷歌",
|
||||
|
Reference in New Issue
Block a user