feat: @vben/plugins/vxe-table 异步导出 vxe-table 相关组件提供给需要单独使用 vxe-table 的场景
parent
62570fa745
commit
98676e1dc9
|
@ -53,8 +53,7 @@
|
|||
"pinia": "catalog:",
|
||||
"vue": "catalog:",
|
||||
"vue-dompurify-html": "catalog:",
|
||||
"vue-router": "catalog:",
|
||||
"vxe-table": "catalog:"
|
||||
"vue-router": "catalog:"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/crypto-js": "catalog:"
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
/* 来自 @vben/plugins/vxe-table style.css */
|
||||
:root {
|
||||
--vxe-ui-font-color: hsl(var(--foreground));
|
||||
--vxe-ui-font-primary-color: hsl(var(--primary));
|
||||
|
||||
/* --vxe-ui-font-lighten-color: #babdc0;
|
||||
--vxe-ui-font-darken-color: #86898e; */
|
||||
--vxe-ui-font-disabled-color: hsl(var(--foreground) / 50%);
|
||||
|
||||
/* base */
|
||||
--vxe-ui-base-popup-border-color: hsl(var(--border));
|
||||
--vxe-ui-input-disabled-color: hsl(var(--border) / 60%);
|
||||
|
||||
/* --vxe-ui-base-popup-box-shadow: 0px 12px 30px 8px rgb(0 0 0 / 50%); */
|
||||
|
||||
/* layout */
|
||||
--vxe-ui-layout-background-color: hsl(var(--background));
|
||||
--vxe-ui-table-resizable-line-color: hsl(var(--heavy));
|
||||
|
||||
/* --vxe-ui-table-fixed-left-scrolling-box-shadow: 8px 0px 10px -5px hsl(var(--accent));
|
||||
--vxe-ui-table-fixed-right-scrolling-box-shadow: -8px 0px 10px -5px hsl(var(--accent)); */
|
||||
|
||||
/* input */
|
||||
--vxe-ui-input-border-color: hsl(var(--border));
|
||||
|
||||
/* --vxe-ui-input-placeholder-color: #8d9095; */
|
||||
|
||||
/* --vxe-ui-input-disabled-background-color: #262727; */
|
||||
|
||||
/* loading */
|
||||
--vxe-ui-loading-background-color: hsl(var(--overlay-content));
|
||||
|
||||
/* table */
|
||||
--vxe-ui-table-header-background-color: hsl(var(--accent));
|
||||
--vxe-ui-table-border-color: hsl(var(--border));
|
||||
--vxe-ui-table-row-hover-background-color: hsl(var(--accent-hover));
|
||||
--vxe-ui-table-row-striped-background-color: hsl(var(--accent) / 60%);
|
||||
--vxe-ui-table-row-hover-striped-background-color: hsl(var(--accent));
|
||||
--vxe-ui-table-row-radio-checked-background-color: hsl(var(--accent));
|
||||
--vxe-ui-table-row-hover-radio-checked-background-color: hsl(
|
||||
var(--accent-hover)
|
||||
);
|
||||
--vxe-ui-table-row-checkbox-checked-background-color: hsl(var(--accent));
|
||||
--vxe-ui-table-row-hover-checkbox-checked-background-color: hsl(
|
||||
var(--accent-hover)
|
||||
);
|
||||
--vxe-ui-table-row-current-background-color: hsl(var(--accent));
|
||||
--vxe-ui-table-row-hover-current-background-color: hsl(var(--accent-hover));
|
||||
--vxe-ui-font-primary-tinge-color: hsl(var(--primary));
|
||||
--vxe-ui-font-primary-lighten-color: hsl(var(--primary) / 60%);
|
||||
--vxe-ui-font-primary-darken-color: hsl(var(--primary));
|
||||
|
||||
/* height: auto !important; */
|
||||
|
||||
/* --vxe-ui-table-fixed-scrolling-box-shadow-color: rgb(0 0 0 / 80%); */
|
||||
}
|
||||
|
||||
.vxe-tools--operate {
|
||||
margin-right: 0.25rem;
|
||||
margin-left: 0.75rem;
|
||||
}
|
||||
|
||||
.vxe-table-custom--checkbox-option:hover {
|
||||
background: none !important;
|
||||
}
|
||||
|
||||
.vxe-toolbar {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.vxe-buttons--wrapper:not(:empty),
|
||||
.vxe-tools--operate:not(:empty),
|
||||
.vxe-tools--wrapper:not(:empty) {
|
||||
padding: 0.6em 0;
|
||||
}
|
||||
|
||||
.vxe-tools--operate:not(:has(button)) {
|
||||
margin-left: 0;
|
||||
}
|
|
@ -4,7 +4,11 @@ import { h } from 'vue';
|
|||
|
||||
import { IconifyIcon } from '@vben/icons';
|
||||
import { $te } from '@vben/locales';
|
||||
import { setupVbenVxeTable, useVbenVxeGrid } from '@vben/plugins/vxe-table';
|
||||
import {
|
||||
AsyncComponents,
|
||||
setupVbenVxeTable,
|
||||
useVbenVxeGrid,
|
||||
} from '@vben/plugins/vxe-table';
|
||||
import { isFunction, isString } from '@vben/utils';
|
||||
|
||||
import { Button, Image, Popconfirm, Switch } from 'ant-design-vue';
|
||||
|
@ -14,6 +18,8 @@ import { $t } from '#/locales';
|
|||
|
||||
import { useVbenForm } from './form';
|
||||
|
||||
import '#/adapter/style.css';
|
||||
|
||||
setupVbenVxeTable({
|
||||
configVxeTable: (vxeUI) => {
|
||||
vxeUI.setConfig({
|
||||
|
@ -111,6 +117,7 @@ setupVbenVxeTable({
|
|||
loading: row[loadingKey] ?? false,
|
||||
'onUpdate:checked': onChange,
|
||||
};
|
||||
|
||||
async function onChange(newVal: any) {
|
||||
row[loadingKey] = true;
|
||||
try {
|
||||
|
@ -122,6 +129,7 @@ setupVbenVxeTable({
|
|||
row[loadingKey] = false;
|
||||
}
|
||||
}
|
||||
|
||||
return h(Switch, finallyProps);
|
||||
},
|
||||
});
|
||||
|
@ -280,6 +288,10 @@ setupVbenVxeTable({
|
|||
});
|
||||
|
||||
export { useVbenVxeGrid };
|
||||
|
||||
const [VxeTable, VxeColumn, VxeToolbar] = AsyncComponents;
|
||||
export { VxeColumn, VxeTable, VxeToolbar };
|
||||
|
||||
// add by 芋艿:from https://github.com/vbenjs/vue-vben-admin/blob/main/playground/src/adapter/vxe-table.ts#L264-L270
|
||||
export type OnActionClickParams<T = Recordable<any>> = {
|
||||
code: string;
|
||||
|
|
|
@ -17,8 +17,6 @@ import { initComponentAdapter } from './adapter/component';
|
|||
import App from './app.vue';
|
||||
import { router } from './router';
|
||||
|
||||
import 'vxe-table/styles/cssvar.scss'; // TODO @puhui999:这个必须导入哇?我看 use-vxe-grid.vue 已经导入了
|
||||
|
||||
async function bootstrap(namespace: string) {
|
||||
// 初始化组件适配器
|
||||
await initComponentAdapter();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<!-- add by puhui999:vxe table 工具栏二次封装,提供给 vxe 原生列表使用 -->
|
||||
<script setup lang="ts">
|
||||
import type { VxeToolbarInstance } from 'vxe-table';
|
||||
import type { VxeToolbarInstance } from '#/adapter/vxe-table';
|
||||
|
||||
import { ref } from 'vue';
|
||||
|
||||
|
@ -8,7 +8,8 @@ import { useContentMaximize, useRefresh } from '@vben/hooks';
|
|||
import { Fullscreen, RefreshCw, Search } from '@vben/icons';
|
||||
|
||||
import { Button } from 'ant-design-vue';
|
||||
import { VxeToolbar } from 'vxe-table';
|
||||
|
||||
import { VxeToolbar } from '#/adapter/vxe-table';
|
||||
|
||||
/** 列表工具栏封装 */
|
||||
defineOptions({ name: 'TableToolbar' });
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<script lang="ts" setup>
|
||||
import type { VxeTableInstance } from 'vxe-table';
|
||||
|
||||
import type { VxeTableInstance } from '#/adapter/vxe-table';
|
||||
import type { Demo01ContactApi } from '#/api/infra/demo/demo01';
|
||||
|
||||
import { h, nextTick, onMounted, reactive, ref } from 'vue';
|
||||
|
@ -22,8 +21,8 @@ import {
|
|||
RangePicker,
|
||||
Select,
|
||||
} from 'ant-design-vue';
|
||||
import { VxeColumn, VxeTable } from 'vxe-table';
|
||||
|
||||
import { VxeColumn, VxeTable } from '#/adapter/vxe-table';
|
||||
import {
|
||||
deleteDemo01Contact,
|
||||
exportDemo01Contact,
|
||||
|
@ -192,7 +191,6 @@ onMounted(async () => {
|
|||
|
||||
<!-- 列表 -->
|
||||
<ContentWrap title="示例联系人">
|
||||
<!-- TODO @puhui999:暗黑模式下,会有个黑底 -->
|
||||
<template #extra>
|
||||
<TableToolbar
|
||||
ref="tableToolbarRef"
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
export { setupVbenVxeTable } from './init';
|
||||
export { AsyncComponents, setupVbenVxeTable } from './init';
|
||||
export type { VxeTableGridOptions } from './types';
|
||||
export * from './use-vxe-grid';
|
||||
|
||||
export { default as VbenVxeGrid } from './use-vxe-grid.vue';
|
||||
export type { VxeGridListeners, VxeGridProps } from 'vxe-table';
|
||||
export type {
|
||||
VxeGridListeners,
|
||||
VxeGridProps,
|
||||
VxeTableInstance,
|
||||
VxeToolbarInstance,
|
||||
} from 'vxe-table';
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import type { SetupVxeTable } from './types';
|
||||
|
||||
import { defineComponent, watch } from 'vue';
|
||||
import { defineAsyncComponent, defineComponent, watch } from 'vue';
|
||||
|
||||
import { usePreferences } from '@vben/preferences';
|
||||
|
||||
|
@ -100,6 +100,18 @@ export function initVxeTable() {
|
|||
isInit = true;
|
||||
}
|
||||
|
||||
// 异步导出 vxe-table 相关组件提供给需要单独使用 vxe-table 的场景
|
||||
const AsyncVxeTable = defineAsyncComponent(() =>
|
||||
import('vxe-table').then((mod) => mod.VxeTable),
|
||||
);
|
||||
const AsyncVxeColumn = defineAsyncComponent(() =>
|
||||
import('vxe-table').then((mod) => mod.VxeColumn),
|
||||
);
|
||||
const AsyncVxeToolbar = defineAsyncComponent(() =>
|
||||
import('vxe-table').then((mod) => mod.VxeToolbar),
|
||||
);
|
||||
export const AsyncComponents = [AsyncVxeTable, AsyncVxeColumn, AsyncVxeToolbar];
|
||||
|
||||
export function setupVbenVxeTable(setupOptions: SetupVxeTable) {
|
||||
const { configVxeTable, useVbenForm } = setupOptions;
|
||||
|
||||
|
|
Loading…
Reference in New Issue