mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-11-30 22:42:09 +08:00
feat(design, tdesign-vue-next-adapter, table, element-plus-adapter): 完善tdesign适配
This commit is contained in:
parent
dabeba85a0
commit
979b834fac
@ -4,8 +4,9 @@
|
|||||||
:is="uiComponent"
|
:is="uiComponent"
|
||||||
v-bind="uiProps"
|
v-bind="uiProps"
|
||||||
@size-change="handleSizeChange"
|
@size-change="handleSizeChange"
|
||||||
@page-size-change="handleSizeChange"
|
|
||||||
@current-change="handleCurrentChange"
|
@current-change="handleCurrentChange"
|
||||||
|
@update:current-page="updateCurrentPage"
|
||||||
|
@update:page-size="updatePageSize"
|
||||||
></component>
|
></component>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -21,7 +22,7 @@ defineOptions({
|
|||||||
|
|
||||||
const props = defineProps<PaginationProps>();
|
const props = defineProps<PaginationProps>();
|
||||||
|
|
||||||
const emit = defineEmits(['size-change', 'current-change']);
|
const emit = defineEmits(['size-change', 'current-change', 'update:current-page', 'update:page-size']);
|
||||||
|
|
||||||
const ui = getDesignConfig('components')?.pagination;
|
const ui = getDesignConfig('components')?.pagination;
|
||||||
|
|
||||||
@ -35,4 +36,10 @@ const handleSizeChange = (...args: any[]) => {
|
|||||||
const handleCurrentChange = (...args: any[]) => {
|
const handleCurrentChange = (...args: any[]) => {
|
||||||
emit('current-change', ...args);
|
emit('current-change', ...args);
|
||||||
};
|
};
|
||||||
|
const updateCurrentPage = (...args: any[]) => {
|
||||||
|
emit('update:current-page', ...args);
|
||||||
|
};
|
||||||
|
const updatePageSize = (...args: any[]) => {
|
||||||
|
emit('update:page-size', ...args);
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -54,21 +54,8 @@ export { default as TMagicTooltip } from './Tooltip.vue';
|
|||||||
export { default as TMagicUpload } from './Upload.vue';
|
export { default as TMagicUpload } from './Upload.vue';
|
||||||
export { default as TMagicPopconfirm } from './Popconfirm.vue';
|
export { default as TMagicPopconfirm } from './Popconfirm.vue';
|
||||||
|
|
||||||
export const tMagicMessage = {
|
// eslint-disable-next-line import/no-mutable-exports
|
||||||
error: (msg: string) => {
|
export let tMagicMessage: TMagicMessage;
|
||||||
console.error(msg);
|
|
||||||
},
|
|
||||||
success: (msg: string) => {
|
|
||||||
console.log(msg);
|
|
||||||
},
|
|
||||||
warning: (msg: string) => {
|
|
||||||
console.warn(msg);
|
|
||||||
},
|
|
||||||
info: (msg: string) => {
|
|
||||||
console.info(msg);
|
|
||||||
},
|
|
||||||
closeAll: (_msg: string) => {},
|
|
||||||
} as unknown as TMagicMessage;
|
|
||||||
|
|
||||||
export const tMagicMessageBox = {
|
export const tMagicMessageBox = {
|
||||||
alert: (msg: string) => {
|
alert: (msg: string) => {
|
||||||
@ -108,13 +95,23 @@ export let useZIndex = (zIndexOverrides?: Ref<number>) => {
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
install(app: App, options: DesignPluginOptions) {
|
install(app: App, options: DesignPluginOptions) {
|
||||||
if (options.message) {
|
tMagicMessage =
|
||||||
tMagicMessage.error = options.message?.error;
|
options.message ||
|
||||||
tMagicMessage.success = options.message?.success;
|
({
|
||||||
tMagicMessage.warning = options.message?.warning;
|
error: (msg: string) => {
|
||||||
tMagicMessage.info = options.message?.info;
|
console.error(msg);
|
||||||
tMagicMessage.closeAll = options.message?.closeAll;
|
},
|
||||||
}
|
success: (msg: string) => {
|
||||||
|
console.log(msg);
|
||||||
|
},
|
||||||
|
warning: (msg: string) => {
|
||||||
|
console.warn(msg);
|
||||||
|
},
|
||||||
|
info: (msg: string) => {
|
||||||
|
console.info(msg);
|
||||||
|
},
|
||||||
|
closeAll: (_msg: string) => {},
|
||||||
|
} as unknown as TMagicMessage);
|
||||||
|
|
||||||
if (options.messageBox) {
|
if (options.messageBox) {
|
||||||
tMagicMessageBox.alert = options.messageBox?.alert;
|
tMagicMessageBox.alert = options.messageBox?.alert;
|
||||||
|
|||||||
@ -224,8 +224,9 @@ export interface PaginationProps {
|
|||||||
hideOnSinglePage?: boolean;
|
hideOnSinglePage?: boolean;
|
||||||
curPage?: number;
|
curPage?: number;
|
||||||
pageSizes?: number[];
|
pageSizes?: number[];
|
||||||
pagesize?: number;
|
pageSize?: number;
|
||||||
total?: number;
|
total?: number;
|
||||||
|
size?: 'large' | 'default' | 'small';
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PopconfirmProps {
|
export interface PopconfirmProps {
|
||||||
@ -399,7 +400,7 @@ export interface IconProps {
|
|||||||
size?: string;
|
size?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TMagicMessage {
|
interface ExtraApi {
|
||||||
success: (msg: string) => void;
|
success: (msg: string) => void;
|
||||||
warning: (msg: string) => void;
|
warning: (msg: string) => void;
|
||||||
info: (msg: string) => void;
|
info: (msg: string) => void;
|
||||||
@ -407,6 +408,14 @@ export interface TMagicMessage {
|
|||||||
closeAll: () => void;
|
closeAll: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type TMagicMessage = ExtraApi &
|
||||||
|
((options: {
|
||||||
|
type?: 'info' | 'success' | 'warning' | 'error';
|
||||||
|
message?: string;
|
||||||
|
dangerouslyUseHTMLString?: boolean;
|
||||||
|
duration?: number;
|
||||||
|
}) => void);
|
||||||
|
|
||||||
export type ElMessageBoxShortcutMethod = ((
|
export type ElMessageBoxShortcutMethod = ((
|
||||||
message: string,
|
message: string,
|
||||||
title: string,
|
title: string,
|
||||||
|
|||||||
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed } from 'vue';
|
import { computed } from 'vue';
|
||||||
|
import { ElFormItem } from 'element-plus';
|
||||||
|
|
||||||
import { FormItemProps } from '@tmagic/design';
|
import { FormItemProps } from '@tmagic/design';
|
||||||
|
|
||||||
|
|||||||
@ -29,12 +29,12 @@
|
|||||||
row[config.prop]
|
row[config.prop]
|
||||||
}}</a>
|
}}</a>
|
||||||
|
|
||||||
<el-tooltip v-else-if="config.action === 'tip'" placement="left">
|
<TMagicTooltip v-else-if="config.action === 'tip'" placement="left">
|
||||||
<template #content>
|
<template #content>
|
||||||
<div>{{ formatter(config, row, { index: index }) }}</div>
|
<div>{{ formatter(config, row, { index: index }) }}</div>
|
||||||
</template>
|
</template>
|
||||||
<TMagicButton link type="primary">{{ config.buttonText || '扩展配置' }}</TMagicButton>
|
<TMagicButton link type="primary">{{ config.buttonText || '扩展配置' }}</TMagicButton>
|
||||||
</el-tooltip>
|
</TMagicTooltip>
|
||||||
|
|
||||||
<TMagicTag
|
<TMagicTag
|
||||||
v-else-if="config.action === 'tag' && config.prop"
|
v-else-if="config.action === 'tag' && config.prop"
|
||||||
@ -46,7 +46,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { TMagicButton, TMagicForm, TMagicTag } from '@tmagic/design';
|
import { TMagicButton, TMagicForm, TMagicTag, TMagicTooltip } from '@tmagic/design';
|
||||||
|
|
||||||
import { ColumnConfig } from './schema';
|
import { ColumnConfig } from './schema';
|
||||||
import { formatter } from './utils';
|
import { formatter } from './utils';
|
||||||
|
|||||||
43
packages/tdesign-vue-next-adapter/src/Pagination.vue
Normal file
43
packages/tdesign-vue-next-adapter/src/Pagination.vue
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<template>
|
||||||
|
<TPagination
|
||||||
|
:total="total"
|
||||||
|
:current="curPage"
|
||||||
|
:size="size === 'small' ? 'small' : 'medium'"
|
||||||
|
:page-size="pageSize"
|
||||||
|
:page-size-options="pageSizes"
|
||||||
|
@current-change="handleCurrentChange"
|
||||||
|
@page-size-change="handleSizeChange"
|
||||||
|
@update:current="updateCurrentPage"
|
||||||
|
@update:page-size="updatePageSize"
|
||||||
|
></TPagination>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { Pagination as TPagination } from 'tdesign-vue-next';
|
||||||
|
|
||||||
|
import type { PaginationProps } from '@tmagic/design';
|
||||||
|
|
||||||
|
defineOptions({
|
||||||
|
name: 'TTDesignAdapterPagination',
|
||||||
|
});
|
||||||
|
|
||||||
|
defineProps<PaginationProps>();
|
||||||
|
|
||||||
|
const emit = defineEmits(['size-change', 'current-change', 'update:current-page', 'update:page-size']);
|
||||||
|
|
||||||
|
const handleCurrentChange = (...args: any[]) => {
|
||||||
|
emit('current-change', ...args);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSizeChange = (...args: any[]) => {
|
||||||
|
emit('size-change', ...args);
|
||||||
|
};
|
||||||
|
|
||||||
|
const updateCurrentPage = (...args: any[]) => {
|
||||||
|
emit('update:current-page', ...args);
|
||||||
|
};
|
||||||
|
|
||||||
|
const updatePageSize = (...args: any[]) => {
|
||||||
|
emit('update:page-size', ...args);
|
||||||
|
};
|
||||||
|
</script>
|
||||||
@ -21,7 +21,6 @@ import {
|
|||||||
MessagePlugin,
|
MessagePlugin,
|
||||||
Option as TOption,
|
Option as TOption,
|
||||||
OptionGroup as TOptionGroup,
|
OptionGroup as TOptionGroup,
|
||||||
Pagination as TPagination,
|
|
||||||
RadioGroup as TRadioGroup,
|
RadioGroup as TRadioGroup,
|
||||||
Row as TRow,
|
Row as TRow,
|
||||||
Select as TSelect,
|
Select as TSelect,
|
||||||
@ -81,6 +80,7 @@ import DatePicker from './DatePicker.vue';
|
|||||||
import Dialog from './Dialog.vue';
|
import Dialog from './Dialog.vue';
|
||||||
import Icon from './Icon.vue';
|
import Icon from './Icon.vue';
|
||||||
import Input from './Input.vue';
|
import Input from './Input.vue';
|
||||||
|
import Pagination from './Pagination.vue';
|
||||||
import Popconfirm from './Popconfirm.vue';
|
import Popconfirm from './Popconfirm.vue';
|
||||||
import Radio from './Radio.vue';
|
import Radio from './Radio.vue';
|
||||||
import RadioButton from './RadioButton.vue';
|
import RadioButton from './RadioButton.vue';
|
||||||
@ -88,8 +88,24 @@ import Scrollbar from './Scrollbar.vue';
|
|||||||
import Table from './Table.vue';
|
import Table from './Table.vue';
|
||||||
import Tabs from './Tabs.vue';
|
import Tabs from './Tabs.vue';
|
||||||
|
|
||||||
|
const messageBox = (options: {
|
||||||
|
type?: 'info' | 'success' | 'warning' | 'error';
|
||||||
|
message?: string;
|
||||||
|
dangerouslyUseHTMLString?: boolean;
|
||||||
|
duration?: number;
|
||||||
|
}) =>
|
||||||
|
MessagePlugin(options.type || 'info', {
|
||||||
|
duration: options.duration || 3000,
|
||||||
|
content: options.message,
|
||||||
|
});
|
||||||
|
|
||||||
|
messageBox.success = MessagePlugin.success;
|
||||||
|
messageBox.error = MessagePlugin.error;
|
||||||
|
messageBox.warning = MessagePlugin.warning;
|
||||||
|
messageBox.info = MessagePlugin.info;
|
||||||
|
|
||||||
const adapter: any = {
|
const adapter: any = {
|
||||||
message: MessagePlugin,
|
message: messageBox,
|
||||||
messageBox: {
|
messageBox: {
|
||||||
alert: (msg: string, title?: string) => {
|
alert: (msg: string, title?: string) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
@ -351,13 +367,8 @@ const adapter: any = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
pagination: {
|
pagination: {
|
||||||
component: TPagination,
|
component: Pagination,
|
||||||
props: (props: PaginationProps) => ({
|
props: (props: PaginationProps) => props,
|
||||||
current: props.curPage,
|
|
||||||
pageSizeOptions: props.pageSizes,
|
|
||||||
pageSize: props.pagesize,
|
|
||||||
total: props.total,
|
|
||||||
}),
|
|
||||||
},
|
},
|
||||||
|
|
||||||
radio: {
|
radio: {
|
||||||
|
|||||||
@ -3,6 +3,9 @@
|
|||||||
<NavMenu :data="menu"></NavMenu>
|
<NavMenu :data="menu"></NavMenu>
|
||||||
<div class="table-content">
|
<div class="table-content">
|
||||||
<MagicTable class="left-panel" :columns="columns" :data="data" :show-header="true" rowkey-name="a"></MagicTable>
|
<MagicTable class="left-panel" :columns="columns" :data="data" :show-header="true" rowkey-name="a"></MagicTable>
|
||||||
|
|
||||||
|
<TMagicPagination class="pagination" :total="100" :page-size="10" :current-page="1"></TMagicPagination>
|
||||||
|
|
||||||
<TMagicTabs class="right-panel" modelValue="columns">
|
<TMagicTabs class="right-panel" modelValue="columns">
|
||||||
<TMagicTabPane label="columns" name="columns">
|
<TMagicTabPane label="columns" name="columns">
|
||||||
<TMagicCodeEditor class="code-editor-content" :init-values="columns" @save="change"></TMagicCodeEditor>
|
<TMagicCodeEditor class="code-editor-content" :init-values="columns" @save="change"></TMagicCodeEditor>
|
||||||
@ -20,7 +23,15 @@ import { ref } from 'vue';
|
|||||||
import { useRouter } from 'vue-router';
|
import { useRouter } from 'vue-router';
|
||||||
|
|
||||||
import type { ColumnConfig } from '@tmagic/editor';
|
import type { ColumnConfig } from '@tmagic/editor';
|
||||||
import { MagicTable, MenuButton, TMagicCodeEditor, tMagicMessage, TMagicTabPane, TMagicTabs } from '@tmagic/editor';
|
import {
|
||||||
|
MagicTable,
|
||||||
|
MenuButton,
|
||||||
|
TMagicCodeEditor,
|
||||||
|
tMagicMessage,
|
||||||
|
TMagicPagination,
|
||||||
|
TMagicTabPane,
|
||||||
|
TMagicTabs,
|
||||||
|
} from '@tmagic/editor';
|
||||||
|
|
||||||
import NavMenu from '../components/NavMenu.vue';
|
import NavMenu from '../components/NavMenu.vue';
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user