Skip to content

feat: update result #2362

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions components/result/index.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { inject } from 'vue';
import PropTypes from '../_util/vue-types';
import { getComponentFromProp } from '../_util/props-util';
import { getComponent } from '../_util/props-util';
import { ConfigConsumerProps } from '../config-provider';
import CheckCircleFilled from '@ant-design/icons-vue/CheckCircleFilled';
import CloseCircleFilled from '@ant-design/icons-vue/CloseCircleFilled';
import ExclamationCircleFilled from '@ant-design/icons-vue/ExclamationCircleFilled';
import WarningFilled from '@ant-design/icons-vue/WarningFilled';
import Base from '../base';
import noFound from './noFound';
import serverError from './serverError';
import unauthorized from './unauthorized';
Expand Down Expand Up @@ -55,25 +55,27 @@ const renderExtra = (h, prefixCls, extra) =>
const Result = {
name: 'AResult',
props: ResultProps,
inject: {
configProvider: { default: () => ConfigConsumerProps },
setup() {
return {
configProvider: inject('configProvider', ConfigConsumerProps),
};
},
render(h) {
const { prefixCls: customizePrefixCls, status } = this;
const getPrefixCls = this.configProvider.getPrefixCls;
const prefixCls = getPrefixCls('result', customizePrefixCls);

const title = getComponentFromProp(this, 'title');
const subTitle = getComponentFromProp(this, 'subTitle');
const icon = getComponentFromProp(this, 'icon');
const extra = getComponentFromProp(this, 'extra');
const title = getComponent(this, 'title');
const subTitle = getComponent(this, 'subTitle');
const icon = getComponent(this, 'icon');
const extra = getComponent(this, 'extra');

return (
<div class={`${prefixCls} ${prefixCls}-${status}`}>
{renderIcon(h, prefixCls, { status, icon })}
<div class={`${prefixCls}-title`}>{title}</div>
{subTitle && <div class={`${prefixCls}-subtitle`}>{subTitle}</div>}
{this.$slots.default && <div class={`${prefixCls}-content`}>{this.$slots.default}</div>}
{this.$slots.default && <div class={`${prefixCls}-content`}>{this.$slots.default()}</div>}
{renderExtra(h, prefixCls, extra)}
</div>
);
Expand All @@ -86,8 +88,7 @@ Result.PRESENTED_IMAGE_404 = ExceptionMap[404];
Result.PRESENTED_IMAGE_500 = ExceptionMap[500];

/* istanbul ignore next */
Result.install = function(Vue) {
Vue.use(Base);
Vue.component(Result.name, Result);
Result.install = function(app) {
app.component(Result.name, Result);
};
export default Result;
4 changes: 3 additions & 1 deletion examples/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import Affix from 'ant-design-vue/affix';
import Alert from 'ant-design-vue/alert';
import Divider from 'ant-design-vue/divider';
import ConfigProvider from 'ant-design-vue/config-provider';
import Spin from 'ant-design-vue/Spin';
import Result from 'ant-design-vue/result';
import Spin from 'ant-design-vue/spin';
import Empty from 'ant-design-vue/empty';
import 'ant-design-vue/style.js';

Expand All @@ -18,6 +19,7 @@ createApp(App)
.use(Affix)
.use(Alert)
.use(Divider)
.use(Result)
.use(Spin)
.use(Empty)
.mount('#app');