帮助文档页面添加更新功能

This commit is contained in:
qsc 2023-08-06 20:22:09 +08:00
parent 32c27a4685
commit 3f6a5eb655
12 changed files with 55 additions and 26 deletions

View File

@ -2,5 +2,6 @@
import { EntityDict } from '../../../general-app-domain';
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<EntityDict, "article", false, {
articleMenuId: string;
changeIsEdit: () => void;
}>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
export default _default;

View File

@ -30,6 +30,7 @@ exports.default = OakComponent({
},
properties: {
articleMenuId: '',
changeIsEdit: function () { return undefined; },
},
listeners: {
'editor,content': function (prev, next) {
@ -123,6 +124,9 @@ exports.default = OakComponent({
return [4 /*yield*/, this.execute()];
case 1:
_a.sent();
if (this.props.changeIsEdit) {
this.props.changeIsEdit();
}
return [3 /*break*/, 3];
case 2:
if (this.state.name && this.state.name.length > 0) {

View File

@ -13,6 +13,7 @@ export default function Render(props: WebComponentProps<EntityDict, "article", f
origin1: string;
articleMenuId: string;
oakId: string;
changeIsEdit: () => void;
}, {
setHtml: (content: string) => void;
setEditor: (editor: any) => void;

View File

@ -32,7 +32,7 @@ function customCheckImageFn(src, alt, url) {
function Render(props) {
var method = props.methods, data = props.data;
var t = method.t, setEditor = method.setEditor, check = method.check, preview = method.preview, addExtraFile = method.addExtraFile, uploadFile = method.uploadFile, update = method.update, setHtml = method.setHtml, gotoPreview = method.gotoPreview;
var id = data.id, content = data.content, editor = data.editor, origin1 = data.origin1, oakFullpath = data.oakFullpath, html = data.html, oakId = data.oakId, articleMenuId = data.articleMenuId;
var id = data.id, content = data.content, editor = data.editor, origin1 = data.origin1, oakFullpath = data.oakFullpath, html = data.html, oakId = data.oakId, articleMenuId = data.articleMenuId, changeIsEdit = data.changeIsEdit;
var features = (0, useFeatures_1.default)();
var _a = tslib_1.__read((0, react_1.useState)(""), 2), articleId = _a[0], setArticleId = _a[1];
(0, react_1.useEffect)(function () {

View File

@ -20,6 +20,10 @@ function Render(props) {
var _g = tslib_1.__read((0, react_1.useState)(''), 2), selectedArticleId = _g[0], setSelectedArticleId = _g[1];
var _h = tslib_1.__read((0, react_1.useState)(true), 2), defaultOpen = _h[0], setDefaultOpen = _h[1];
var _j = tslib_1.__read((0, react_1.useState)([]), 2), openArray = _j[0], setOpenArray = _j[1];
var _k = tslib_1.__read((0, react_1.useState)(false), 2), isEdit = _k[0], setIsEdit = _k[1];
var changeIsEdit = function () {
setIsEdit(false);
};
var changeDefaultOpen = function (defaultOpen, openArray) {
setDefaultOpen(defaultOpen);
setOpenArray(openArray);
@ -39,6 +43,7 @@ function Render(props) {
(0, react_1.useEffect)(function () {
if (editArticle) {
setSelectedArticleId(editArticle);
changeIsEdit();
}
}, [editArticle]);
if (oakFullpath) {
@ -77,10 +82,10 @@ function Render(props) {
content: '复制链接成功',
type: 'success',
});
} }, { children: [(0, jsx_runtime_1.jsx)(icons_1.CopyOutlined, {}), "\u590D\u5236\u94FE\u63A5"] }))] })) })), (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ style: { fontSize: 14, display: 'flex', flexDirection: 'row', marginLeft: 10, marginBottom: 5 } }, { children: breadcrumbItems.length > 0 &&
} }, { children: [(0, jsx_runtime_1.jsx)(icons_1.CopyOutlined, {}), "\u590D\u5236\u94FE\u63A5"] })), (0, jsx_runtime_1.jsxs)(antd_1.Button, tslib_1.__assign({ onClick: function () { return setIsEdit(true); } }, { children: [(0, jsx_runtime_1.jsx)(icons_1.EditOutlined, {}), "\u66F4\u65B0"] }))] })) })), (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ style: { fontSize: 14, display: 'flex', flexDirection: 'row', marginLeft: 10, marginBottom: 5 } }, { children: breadcrumbItems.length > 0 &&
breadcrumbItems.map(function (breadcrumbItem, index) {
return index !== breadcrumbItems.length - 1 ? ((0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ style: { color: '#B2B2B2' } }, { children: [breadcrumbItem, (0, jsx_runtime_1.jsx)("span", tslib_1.__assign({ style: { margin: '0 6px' } }, { children: "/" }))] }), index)) : ((0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: web_pc_module_less_1.default.breadcrumbItem }, { children: breadcrumbItem }), index));
}) })), (0, jsx_runtime_1.jsx)(cell_1.default, { oakId: editArticle, oakAutoUnmount: true, oakPath: "article-detail-".concat(editArticle) })] })) }))] })));
}) })), isEdit ? ((0, jsx_runtime_1.jsx)(upsert_1.default, { oakId: editArticle, oakAutoUnmount: true, oakPath: "article-upsert-".concat(editArticle), changeIsEdit: changeIsEdit })) : ((0, jsx_runtime_1.jsx)(cell_1.default, { oakId: editArticle, oakAutoUnmount: true, oakPath: "article-detail-".concat(editArticle) }))] })) }))] })));
}
}
return null;

View File

@ -139,7 +139,6 @@ exports.default = OakComponent({
var users = _a.data, props = _a.props, features = _a.features;
var entity = props.entity, entityId = props.entityId;
var filter = this.getFilterByName('fulltext');
var pagination = this.getPagination();
return {
users: users === null || users === void 0 ? void 0 : users.map(function (ele) {
var _a;
@ -153,7 +152,6 @@ exports.default = OakComponent({
return user2;
}),
searchValue: (filter === null || filter === void 0 ? void 0 : filter.$text) && filter.$text.$search,
pagination: pagination,
};
},
properties: {
@ -161,8 +159,6 @@ exports.default = OakComponent({
entityId: '',
redirectToAfterConfirm: {},
qrCodeType: '',
showTitle: true,
showBack: false,
onUpdate: function (id) { return undefined; },
onCreate: function () { return undefined; },
},

View File

@ -3,11 +3,6 @@ import { EntityDict } from '../../../general-app-domain';
export default function Render(props: WebComponentProps<EntityDict, 'user', true, {
users: EntityDict['user']['Schema'][];
searchValue?: string;
pagination: {
pageSize: number;
total: number;
currentPage: number;
};
entity: string;
entityId: string;
showBack: boolean;

View File

@ -8,11 +8,11 @@ var antd_1 = require("antd");
var web_module_less_1 = tslib_1.__importDefault(require("./web.module.less"));
function Render(props) {
var _this = this;
var _a = props.data, pagination = _a.pagination, _b = _a.users, users = _b === void 0 ? [] : _b, entity = _a.entity, entityId = _a.entityId, oakLoading = _a.oakLoading, _c = _a.showBack, showBack = _c === void 0 ? false : _c, _d = _a.showTitle, showTitle = _d === void 0 ? true : _d;
var _e = pagination || {}, pageSize = _e.pageSize, total = _e.total, currentPage = _e.currentPage;
var _f = props.methods, goUpsert = _f.goUpsert, t = _f.t, setCurrentPage = _f.setCurrentPage, setPageSize = _f.setPageSize, confirmDelete = _f.confirmDelete, goUpdate = _f.goUpdate;
var _g = tslib_1.__read((0, react_1.useState)(undefined), 2), idRemove = _g[0], setIdRemove = _g[1];
var _h = tslib_1.__read((0, react_1.useState)(false), 2), inviteVisible = _h[0], setInviteVisible = _h[1];
var _a = props.data, oakPagination = _a.oakPagination, _b = _a.users, users = _b === void 0 ? [] : _b, entity = _a.entity, entityId = _a.entityId, oakLoading = _a.oakLoading;
var _c = oakPagination || {}, pageSize = _c.pageSize, total = _c.total, currentPage = _c.currentPage;
var _d = props.methods, goUpsert = _d.goUpsert, t = _d.t, setCurrentPage = _d.setCurrentPage, setPageSize = _d.setPageSize, confirmDelete = _d.confirmDelete, goUpdate = _d.goUpdate;
var _e = tslib_1.__read((0, react_1.useState)(undefined), 2), idRemove = _e[0], setIdRemove = _e[1];
var _f = tslib_1.__read((0, react_1.useState)(false), 2), inviteVisible = _f[0], setInviteVisible = _f[1];
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: web_module_less_1.default.container }, { children: [(0, jsx_runtime_1.jsx)(antd_1.Space, tslib_1.__assign({ style: { marginBottom: 16 } }, { children: (0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ type: "primary", onClick: function () { return goUpsert(); } }, { children: "\u6DFB\u52A0" })) })), (0, jsx_runtime_1.jsx)(antd_1.Table, { loading: oakLoading, rowKey: "id", columns: [
{
width: 100,

View File

@ -45,7 +45,7 @@ function render(props) {
// addonAfter="分钟"
addonAfter: (0, jsx_runtime_1.jsxs)(antd_1.Select, tslib_1.__assign({ value: unit, style: { width: 80 }, onChange: function (v) {
setUnit(v);
} }, { children: [(0, jsx_runtime_1.jsx)(antd_1.Select.Option, tslib_1.__assign({ value: "minute" }, { children: t('unit.minute') })), (0, jsx_runtime_1.jsx)(antd_1.Select.Option, tslib_1.__assign({ value: "hour" }, { children: t('unit.hour') }))] })) }) }) })), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, tslib_1.__assign({ wrapperCol: { offset: 4 } }, { children: (0, jsx_runtime_1.jsxs)(antd_1.Space, { children: [(0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ type: "primary", onClick: function () { return confirm(); }, disabled: oakExecutable !== true }, { children: t('common:action.confirm') })), (0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ onClick: function () { return onBack(); } }, { children: t('common.back') }))] }) }))] })));
} }, { children: [(0, jsx_runtime_1.jsx)(antd_1.Select.Option, tslib_1.__assign({ value: "minute" }, { children: t('unit.minute') })), (0, jsx_runtime_1.jsx)(antd_1.Select.Option, tslib_1.__assign({ value: "hour" }, { children: t('unit.hour') }))] })) }) }) })), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, tslib_1.__assign({ wrapperCol: { offset: 4 } }, { children: (0, jsx_runtime_1.jsxs)(antd_1.Space, { children: [(0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ type: "primary", onClick: function () { return confirm(); }, disabled: oakExecutable !== true }, { children: t('common:action.confirm') })), (0, jsx_runtime_1.jsx)(antd_1.Button, tslib_1.__assign({ onClick: function () { return onBack(); } }, { children: t('common:back') }))] }) }))] })));
return (0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ className: web_module_less_1.default.container }, { children: P }));
}
exports.default = render;

View File

@ -34,6 +34,7 @@ export default OakComponent({
},
properties: {
articleMenuId: '',
changeIsEdit: () => undefined as void,
},
listeners: {
'editor,content'(prev, next) {
@ -109,6 +110,9 @@ export default OakComponent({
this.state.html !== '<p><br></p>'
) {
await this.execute();
if(this.props.changeIsEdit) {
this.props.changeIsEdit();
}
} else if (this.state.name && this.state.name.length > 0) {
this.setMessage({
content: '请填写文章内容!',

View File

@ -67,6 +67,7 @@ export default function Render(
origin1: string;
articleMenuId: string;
oakId: string;
changeIsEdit: () => void;
},
{
setHtml: (content: string) => void;
@ -94,9 +95,9 @@ export default function Render(
uploadFile,
update,
setHtml,
gotoPreview
gotoPreview,
} = method;
const { id, content, editor, origin1, oakFullpath, html, oakId, articleMenuId } = data;
const { id, content, editor, origin1, oakFullpath, html, oakId, articleMenuId, changeIsEdit } = data;
const features = useFeatures();
const [articleId, setArticleId] = useState("");
useEffect(() => {

View File

@ -5,7 +5,7 @@ import { WebComponentProps } from 'oak-frontend-base';
import { EntityDict } from "../../../general-app-domain";
import Styles from './web.pc.module.less';
import { Button, Divider, Tooltip, Space, Drawer, Empty } from 'antd';
import { EyeOutlined, CopyOutlined, MenuFoldOutlined, MenuUnfoldOutlined, PlusOutlined } from '@ant-design/icons';
import { EyeOutlined, CopyOutlined, MenuFoldOutlined, MenuUnfoldOutlined, PlusOutlined, EditOutlined } from '@ant-design/icons';
import ArticleUpsert from '../../article/upsert';
import ArticleDetail from '../../article/cell';
import copy from 'copy-to-clipboard';
@ -37,6 +37,10 @@ export default function Render(
const [selectedArticleId, setSelectedArticleId] = useState('');
const [defaultOpen, setDefaultOpen] = useState(true);
const [openArray, setOpenArray] = useState([] as string[]);
const [isEdit, setIsEdit] = useState(false);
const changeIsEdit= () => {
setIsEdit(false);
};
const changeDefaultOpen = (defaultOpen: boolean, openArray: string[]) => {
setDefaultOpen(defaultOpen);
setOpenArray(openArray);
@ -56,6 +60,7 @@ export default function Render(
useEffect(() => {
if (editArticle) {
setSelectedArticleId(editArticle);
changeIsEdit();
}
}, [editArticle])
if (oakFullpath) {
@ -296,6 +301,12 @@ export default function Render(
<CopyOutlined />
</Button>
<Button
onClick={() => setIsEdit(true)}
>
<EditOutlined />
</Button>
</Space>
</div>
<div style={{ fontSize: 14, display: 'flex', flexDirection: 'row', marginLeft: 10, marginBottom: 5 }}>
@ -315,11 +326,22 @@ export default function Render(
})
}
</div>
<ArticleDetail
oakId={editArticle}
oakAutoUnmount={true}
oakPath={`article-detail-${editArticle}`}
/>
{
isEdit ? (
<ArticleUpsert
oakId={editArticle}
oakAutoUnmount={true}
oakPath={`article-upsert-${editArticle}`}
changeIsEdit={changeIsEdit}
/>
) : (
<ArticleDetail
oakId={editArticle}
oakAutoUnmount={true}
oakPath={`article-detail-${editArticle}`}
/>
)
}
</div>
)
}