fix: column not pass to cell
parent
844700e561
commit
61e8bfdb8c
|
@ -162,6 +162,7 @@ export default defineComponent<BodyRowProps<unknown>>({
|
||||||
customRender={customRender}
|
customRender={customRender}
|
||||||
{...fixedInfo}
|
{...fixedInfo}
|
||||||
additionalProps={additionalCellProps}
|
additionalProps={additionalCellProps}
|
||||||
|
column={column}
|
||||||
v-slots={{
|
v-slots={{
|
||||||
// ============= Used for nest expandable =============
|
// ============= Used for nest expandable =============
|
||||||
appendNode: () => {
|
appendNode: () => {
|
||||||
|
|
|
@ -1,45 +1,73 @@
|
||||||
|
<docs>
|
||||||
|
---
|
||||||
|
order: 0
|
||||||
|
title:
|
||||||
|
en-US: Basic Usage
|
||||||
|
zh-CN: 基本用法
|
||||||
|
---
|
||||||
|
|
||||||
|
## zh-CN
|
||||||
|
|
||||||
|
简单的表格,最后一列是各种操作。
|
||||||
|
|
||||||
|
## en-US
|
||||||
|
|
||||||
|
Simple table with actions.
|
||||||
|
</docs>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<a-table :columns="columns" :data-source="data">
|
<a-table :columns="columns" :data-source="data">
|
||||||
<template #customTitle>
|
<template #headerCell="{ title, column }">
|
||||||
<span>
|
<template v-if="column.key === 'name'">
|
||||||
<smile-outlined />
|
<span>
|
||||||
Name
|
<smile-outlined />
|
||||||
</span>
|
Name
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
<template v-else>{{ title }}</template>
|
||||||
</template>
|
</template>
|
||||||
<template #tags="{ text: tags }">
|
|
||||||
<span>
|
<template #bodyCell="{ column, record }">
|
||||||
<a-tag
|
<template v-if="column.key === 'name'">
|
||||||
v-for="tag in tags"
|
<a>
|
||||||
:key="tag"
|
{{ record.name }}
|
||||||
:color="tag === 'loser' ? 'volcano' : tag.length > 5 ? 'geekblue' : 'green'"
|
|
||||||
>
|
|
||||||
{{ tag.toUpperCase() }}
|
|
||||||
</a-tag>
|
|
||||||
</span>
|
|
||||||
</template>
|
|
||||||
<template #action="{ record }">
|
|
||||||
<span>
|
|
||||||
<a>Invite 一 {{ record.name }}</a>
|
|
||||||
<a-divider type="vertical" />
|
|
||||||
<a>Delete</a>
|
|
||||||
<a-divider type="vertical" />
|
|
||||||
<a class="ant-dropdown-link">
|
|
||||||
More actions
|
|
||||||
<down-outlined />
|
|
||||||
</a>
|
</a>
|
||||||
</span>
|
</template>
|
||||||
|
<template v-else-if="column.key === 'tags'">
|
||||||
|
<span>
|
||||||
|
<a-tag
|
||||||
|
v-for="tag in record.tags"
|
||||||
|
:key="tag"
|
||||||
|
:color="tag === 'loser' ? 'volcano' : tag.length > 5 ? 'geekblue' : 'green'"
|
||||||
|
>
|
||||||
|
{{ tag.toUpperCase() }}
|
||||||
|
</a-tag>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
<template v-else-if="column.key === 'action'">
|
||||||
|
<span>
|
||||||
|
<a>Invite 一 {{ record.name }}</a>
|
||||||
|
<a-divider type="vertical" />
|
||||||
|
<a>Delete</a>
|
||||||
|
<a-divider type="vertical" />
|
||||||
|
<a class="ant-dropdown-link">
|
||||||
|
More actions
|
||||||
|
<down-outlined />
|
||||||
|
</a>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
<template v-else>{{ record.name }}</template>
|
||||||
</template>
|
</template>
|
||||||
</a-table>
|
</a-table>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { SmileOutlined, DownOutlined } from '@ant-design/icons-vue';
|
import { SmileOutlined, DownOutlined } from '@ant-design/icons-vue';
|
||||||
import { defineComponent, ref } from 'vue';
|
import { defineComponent } from 'vue';
|
||||||
const columns = [
|
const columns = [
|
||||||
{
|
{
|
||||||
title: 'Name',
|
name: 'Name',
|
||||||
dataIndex: 'name',
|
dataIndex: 'name',
|
||||||
key: 'name',
|
key: 'name',
|
||||||
slots: { title: 'customTitle', customRender: 'name' },
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Age',
|
title: 'Age',
|
||||||
|
@ -55,12 +83,10 @@ const columns = [
|
||||||
title: 'Tags',
|
title: 'Tags',
|
||||||
key: 'tags',
|
key: 'tags',
|
||||||
dataIndex: 'tags',
|
dataIndex: 'tags',
|
||||||
slots: { customRender: 'tags' },
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'Action',
|
title: 'Action',
|
||||||
key: 'action',
|
key: 'action',
|
||||||
slots: { customRender: 'action' },
|
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -94,12 +120,9 @@ export default defineComponent({
|
||||||
DownOutlined,
|
DownOutlined,
|
||||||
},
|
},
|
||||||
setup() {
|
setup() {
|
||||||
const test = ref('111');
|
|
||||||
window.test = test;
|
|
||||||
return {
|
return {
|
||||||
data,
|
data,
|
||||||
columns,
|
columns,
|
||||||
test,
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
import less from 'less';
|
||||||
|
import defaultVars from '../scripts/default-vars';
|
||||||
|
import dark from '../scripts/dark-vars';
|
||||||
|
const themeConfig = [
|
||||||
|
{
|
||||||
|
theme: 'dark',
|
||||||
|
htmlThemeAttr: 'dark',
|
||||||
|
modifyVars: {
|
||||||
|
hack: `true;@import "${require.resolve('../components/style/color/colorPalette.less')}";`,
|
||||||
|
...defaultVars,
|
||||||
|
...dark,
|
||||||
|
'text-color': 'fade(@white, 65%)',
|
||||||
|
'gray-8': '@text-color',
|
||||||
|
'background-color-base': '#555',
|
||||||
|
'skeleton-color': 'rgba(0,0,0,0.8)',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
const additionalData = async (content: string, filename: string): Promise<string> => {
|
||||||
|
const themePromises = themeConfig.map(async t => {
|
||||||
|
const { htmlThemeAttr, modifyVars = {} } = t;
|
||||||
|
const options = {
|
||||||
|
javascriptEnabled: true,
|
||||||
|
modifyVars,
|
||||||
|
relativeUrls: true,
|
||||||
|
filename,
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
const { css } = await less.render(content, options);
|
||||||
|
let res = '';
|
||||||
|
if (htmlThemeAttr && css) {
|
||||||
|
res = `
|
||||||
|
[data-doc-theme=${htmlThemeAttr}] {
|
||||||
|
${css}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
return Promise.resolve(res);
|
||||||
|
} catch (error) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log(error);
|
||||||
|
return Promise.reject(content);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
let res = content;
|
||||||
|
for (const themePromise of themePromises) {
|
||||||
|
const theme = await themePromise;
|
||||||
|
res += theme;
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default themeConfig;
|
||||||
|
export { themeConfig, additionalData };
|
|
@ -3,14 +3,17 @@ import vue from '@vitejs/plugin-vue';
|
||||||
import md from '../plugin/md';
|
import md from '../plugin/md';
|
||||||
import docs from '../plugin/docs';
|
import docs from '../plugin/docs';
|
||||||
import vueJsx from '@vitejs/plugin-vue-jsx';
|
import vueJsx from '@vitejs/plugin-vue-jsx';
|
||||||
|
import { additionalData } from './themeConfig';
|
||||||
|
import defaultVar from '../scripts/default-vars';
|
||||||
/**
|
/**
|
||||||
* @type {import('vite').UserConfig}
|
* @type {import('vite').UserConfig}
|
||||||
*/
|
*/
|
||||||
export default {
|
export default {
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
|
'@': path.join(__dirname, './src'),
|
||||||
vue: 'vue/dist/vue.esm-bundler.js',
|
vue: 'vue/dist/vue.esm-bundler.js',
|
||||||
|
'ant-design-vue/es': path.resolve(__dirname, '../components'),
|
||||||
'ant-design-vue': path.resolve(__dirname, '../components'),
|
'ant-design-vue': path.resolve(__dirname, '../components'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -31,16 +34,23 @@ export default {
|
||||||
'fetch-jsonp',
|
'fetch-jsonp',
|
||||||
'@ant-design/icons-vue',
|
'@ant-design/icons-vue',
|
||||||
'lodash-es',
|
'lodash-es',
|
||||||
|
'dayjs',
|
||||||
'vue',
|
'vue',
|
||||||
'vue-router',
|
'vue-router',
|
||||||
'dayjs',
|
'vue-i18n',
|
||||||
'async-validator',
|
'async-validator',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
css: {
|
css: {
|
||||||
preprocessorOptions: {
|
preprocessorOptions: {
|
||||||
less: {
|
less: {
|
||||||
|
modifyVars: {
|
||||||
|
hack: `true;@import "${require.resolve('../components/style/color/colorPalette.less')}";`,
|
||||||
|
...defaultVar,
|
||||||
|
},
|
||||||
javascriptEnabled: true,
|
javascriptEnabled: true,
|
||||||
|
// includePaths: ["node_modules/"],
|
||||||
|
additionalData,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -15,7 +15,10 @@ export default (options: Options = {}): Plugin => {
|
||||||
return {
|
return {
|
||||||
name: 'vueToMdToVue',
|
name: 'vueToMdToVue',
|
||||||
transform(code, id) {
|
transform(code, id) {
|
||||||
if (id.endsWith('.vue') && id.indexOf('/demo/') > -1 && id.indexOf('index.vue') === -1) {
|
if (
|
||||||
|
(id.endsWith('.vue') && id.indexOf('/demo/') > -1 && id.indexOf('index.vue') === -1) ||
|
||||||
|
id.indexOf('/examples/App.vue') > -1
|
||||||
|
) {
|
||||||
// transform .md files into vueSrc so plugin-vue can handle it
|
// transform .md files into vueSrc so plugin-vue can handle it
|
||||||
return { code: markdownToVue(vueToMarkdown(code, id).vueSrc, id).vueSrc, map: null };
|
return { code: markdownToVue(vueToMarkdown(code, id).vueSrc, id).vueSrc, map: null };
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue