From 1d0bc568a78e2c835d17468c9f7979d05bb835f9 Mon Sep 17 00:00:00 2001 From: wangwenchen <920960949@qq.com> Date: Thu, 12 Oct 2023 10:12:41 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- es/triggers/sessionMessage.js | 3 ++- lib/triggers/sessionMessage.js | 5 +++-- src/triggers/sessionMessage.ts | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/es/triggers/sessionMessage.js b/es/triggers/sessionMessage.js index 1d8ea0d13..bd5bf6071 100644 --- a/es/triggers/sessionMessage.js +++ b/es/triggers/sessionMessage.js @@ -50,12 +50,13 @@ const triggers = [ sorter: [ { $attr: { - $$createAt$$: 1, + createTime: 1, }, $direction: 'desc', }, ], count: 1, + indexFrom: 0, }, {}); if (sessionMessage && sessionMessage.wechatUserId) { const [session] = await context.select('session', { diff --git a/lib/triggers/sessionMessage.js b/lib/triggers/sessionMessage.js index 43ba14374..dcb58c594 100644 --- a/lib/triggers/sessionMessage.js +++ b/lib/triggers/sessionMessage.js @@ -43,7 +43,7 @@ const triggers = [ aaoe: 1, }, filter: { - id: sessionId, + sessionId, aaoe: false, createTime: { $gt: Date.now() - (48 * 60 * 60 * 1000 - 5 * 60 * 1000) @@ -52,12 +52,13 @@ const triggers = [ sorter: [ { $attr: { - $$createAt$$: 1, + createTime: 1, }, $direction: 'desc', }, ], count: 1, + indexFrom: 0, }, {}); if (sessionMessage && sessionMessage.wechatUserId) { const [session] = await context.select('session', { diff --git a/src/triggers/sessionMessage.ts b/src/triggers/sessionMessage.ts index 96a9430ac..a05ed667f 100644 --- a/src/triggers/sessionMessage.ts +++ b/src/triggers/sessionMessage.ts @@ -69,12 +69,13 @@ const triggers: Trigger Date: Thu, 12 Oct 2023 10:16:27 +0800 Subject: [PATCH 2/4] =?UTF-8?q?wechatMenu=E8=8F=9C=E5=8D=95=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E5=BC=80=E5=90=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- es/components/wechatMenu/index.js | 45 ++++++++++++--------------- es/components/wechatMenu/web.pc.js | 4 +-- lib/components/wechatMenu/index.js | 45 ++++++++++++--------------- lib/components/wechatMenu/web.pc.js | 4 +-- src/components/wechatMenu/index.ts | 46 ++++++++++++---------------- src/components/wechatMenu/web.pc.tsx | 11 ++++--- 6 files changed, 68 insertions(+), 87 deletions(-) diff --git a/es/components/wechatMenu/index.js b/es/components/wechatMenu/index.js index 414a1763a..97b51332a 100644 --- a/es/components/wechatMenu/index.js +++ b/es/components/wechatMenu/index.js @@ -8,36 +8,29 @@ export default OakComponent({ lifetimes: { async ready() { const { applicationId } = this.props; - const result = await this.features.wechatMenu.getCurrentMenu({ applicationId: applicationId }); - if (result.is_menu_open === 1) { - const { data: wechatMenu } = await this.features.cache.refresh('wechatMenu', { - data: { - id: 1, - applicationId: 1, - wechatPublicTagId: 1, - }, - filter: { - applicationId, - wechatPublicTagId: { - $exists: false - } - } - }); - if (wechatMenu && wechatMenu[0]) { - this.setState({ - menuId: wechatMenu[0].id, - }); - } - this.setState({ - is_menu_open: true, + // const result = await this.features.wechatMenu.getCurrentMenu({ applicationId: applicationId! }); + const { data: wechatMenu } = await this.features.cache.refresh('wechatMenu', { + data: { + id: 1, + applicationId: 1, + wechatPublicTagId: 1, + }, + filter: { applicationId, - }); - } - else { + wechatPublicTagId: { + $exists: false + } + } + }); + if (wechatMenu && wechatMenu[0]) { this.setState({ - is_menu_open: false, + menuId: wechatMenu[0].id, }); } + this.setState({ + is_menu_open: true, + applicationId, + }); } }, methods: {}, diff --git a/es/components/wechatMenu/web.pc.js b/es/components/wechatMenu/web.pc.js index 006641301..c77c997a9 100644 --- a/es/components/wechatMenu/web.pc.js +++ b/es/components/wechatMenu/web.pc.js @@ -26,14 +26,14 @@ export default function Render(props) { }, ]; if (oakFullpath) { - return (_jsx("div", { children: is_menu_open ? (_jsx("div", { className: Style.tabs, children: isPlatform ? _jsx(WechatMenu, { menuId: menuId ? menuId : undefined, oakPath: '$wechatMenu', applicationId: applicationId, oakAutoUnmount: true, menuType: menuType, tabKey: tabKey }) : _jsx(Tabs, { defaultActiveKey: '1', items: items, onChange: (key) => { + return (_jsx("div", { children: is_menu_open && (_jsx("div", { className: Style.tabs, children: isPlatform ? _jsx(WechatMenu, { menuId: menuId ? menuId : undefined, oakPath: '$wechatMenu', applicationId: applicationId, oakAutoUnmount: true, menuType: menuType, tabKey: tabKey }) : _jsx(Tabs, { defaultActiveKey: '1', items: items, onChange: (key) => { if (key === '1') { setMenuType('common'); } else { setMenuType('conditional'); } - } }) })) : (_jsx("div", { className: Style.container, children: _jsx("div", { className: Style.warn, children: "\u5C1A\u672A\u5F00\u542F\u83DC\u5355\uFF0C\u8BF7\u5148\u524D\u5F80\u5FAE\u4FE1\u516C\u4F17\u5E73\u53F0\u5F00\u542F\u3002" }) })) })); + } }) })) })); } return null; } diff --git a/lib/components/wechatMenu/index.js b/lib/components/wechatMenu/index.js index 7d6b0dc84..a7aa1ac03 100644 --- a/lib/components/wechatMenu/index.js +++ b/lib/components/wechatMenu/index.js @@ -10,36 +10,29 @@ exports.default = OakComponent({ lifetimes: { async ready() { const { applicationId } = this.props; - const result = await this.features.wechatMenu.getCurrentMenu({ applicationId: applicationId }); - if (result.is_menu_open === 1) { - const { data: wechatMenu } = await this.features.cache.refresh('wechatMenu', { - data: { - id: 1, - applicationId: 1, - wechatPublicTagId: 1, - }, - filter: { - applicationId, - wechatPublicTagId: { - $exists: false - } - } - }); - if (wechatMenu && wechatMenu[0]) { - this.setState({ - menuId: wechatMenu[0].id, - }); - } - this.setState({ - is_menu_open: true, + // const result = await this.features.wechatMenu.getCurrentMenu({ applicationId: applicationId! }); + const { data: wechatMenu } = await this.features.cache.refresh('wechatMenu', { + data: { + id: 1, + applicationId: 1, + wechatPublicTagId: 1, + }, + filter: { applicationId, - }); - } - else { + wechatPublicTagId: { + $exists: false + } + } + }); + if (wechatMenu && wechatMenu[0]) { this.setState({ - is_menu_open: false, + menuId: wechatMenu[0].id, }); } + this.setState({ + is_menu_open: true, + applicationId, + }); } }, methods: {}, diff --git a/lib/components/wechatMenu/web.pc.js b/lib/components/wechatMenu/web.pc.js index 47e92a9a9..6c5d060c4 100644 --- a/lib/components/wechatMenu/web.pc.js +++ b/lib/components/wechatMenu/web.pc.js @@ -29,14 +29,14 @@ function Render(props) { }, ]; if (oakFullpath) { - return ((0, jsx_runtime_1.jsx)("div", { children: is_menu_open ? ((0, jsx_runtime_1.jsx)("div", { className: web_module_less_1.default.tabs, children: isPlatform ? (0, jsx_runtime_1.jsx)(menu_1.default, { menuId: menuId ? menuId : undefined, oakPath: '$wechatMenu', applicationId: applicationId, oakAutoUnmount: true, menuType: menuType, tabKey: tabKey }) : (0, jsx_runtime_1.jsx)(antd_1.Tabs, { defaultActiveKey: '1', items: items, onChange: (key) => { + return ((0, jsx_runtime_1.jsx)("div", { children: is_menu_open && ((0, jsx_runtime_1.jsx)("div", { className: web_module_less_1.default.tabs, children: isPlatform ? (0, jsx_runtime_1.jsx)(menu_1.default, { menuId: menuId ? menuId : undefined, oakPath: '$wechatMenu', applicationId: applicationId, oakAutoUnmount: true, menuType: menuType, tabKey: tabKey }) : (0, jsx_runtime_1.jsx)(antd_1.Tabs, { defaultActiveKey: '1', items: items, onChange: (key) => { if (key === '1') { setMenuType('common'); } else { setMenuType('conditional'); } - } }) })) : ((0, jsx_runtime_1.jsx)("div", { className: web_module_less_1.default.container, children: (0, jsx_runtime_1.jsx)("div", { className: web_module_less_1.default.warn, children: "\u5C1A\u672A\u5F00\u542F\u83DC\u5355\uFF0C\u8BF7\u5148\u524D\u5F80\u5FAE\u4FE1\u516C\u4F17\u5E73\u53F0\u5F00\u542F\u3002" }) })) })); + } }) })) })); } return null; } diff --git a/src/components/wechatMenu/index.ts b/src/components/wechatMenu/index.ts index a3de95591..a96549dcd 100644 --- a/src/components/wechatMenu/index.ts +++ b/src/components/wechatMenu/index.ts @@ -9,38 +9,32 @@ export default OakComponent({ lifetimes: { async ready() { const { applicationId } = this.props; - const result = await this.features.wechatMenu.getCurrentMenu({ applicationId: applicationId! }); - if (result.is_menu_open === 1) { - const { data: wechatMenu } = await this.features.cache.refresh( - 'wechatMenu', - { - data: { - id: 1, - applicationId: 1, - wechatPublicTagId: 1, - }, - filter: { - applicationId, - wechatPublicTagId: { - $exists: false - } + // const result = await this.features.wechatMenu.getCurrentMenu({ applicationId: applicationId! }); + const { data: wechatMenu } = await this.features.cache.refresh( + 'wechatMenu', + { + data: { + id: 1, + applicationId: 1, + wechatPublicTagId: 1, + }, + filter: { + applicationId, + wechatPublicTagId: { + $exists: false } } - ); - if (wechatMenu && wechatMenu[0]) { - this.setState({ - menuId: wechatMenu[0].id, - }); } + ); + if (wechatMenu && wechatMenu[0]) { this.setState({ - is_menu_open: true, - applicationId, - }); - } else { - this.setState({ - is_menu_open: false, + menuId: wechatMenu[0].id, }); } + this.setState({ + is_menu_open: true, + applicationId, + }); } }, methods: { diff --git a/src/components/wechatMenu/web.pc.tsx b/src/components/wechatMenu/web.pc.tsx index 00d0a5386..4262ec36a 100644 --- a/src/components/wechatMenu/web.pc.tsx +++ b/src/components/wechatMenu/web.pc.tsx @@ -82,7 +82,7 @@ export default function Render( return (
{ - is_menu_open ? ( + is_menu_open && (
{ isPlatform ? }
- ) : ( -
-
尚未开启菜单,请先前往微信公众平台开启。
-
) + // : ( + //
+ //
尚未开启菜单,请先前往微信公众平台开启。
+ //
+ // ) }
) From 268f4d1a09de28d8096aa6840b58dd976a4bdb67 Mon Sep 17 00:00:00 2001 From: wangwenchen <920960949@qq.com> Date: Thu, 12 Oct 2023 10:17:01 +0800 Subject: [PATCH 3/4] ele.$$createAt$$ !== 1 --- src/components/sessionMessage/list/index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/sessionMessage/list/index.ts b/src/components/sessionMessage/list/index.ts index 2750dec3c..7623c56d7 100644 --- a/src/components/sessionMessage/list/index.ts +++ b/src/components/sessionMessage/list/index.ts @@ -113,7 +113,9 @@ export default OakComponent({ this.getUserLastMessage(); // console.log(url); return { - sessionMessageList, + sessionMessageList: sessionMessageList?.filter( + (ele) => ele.$$createAt$$ !== 1 + ), num: sessionMessageList?.length, sessionMessageType, }; From 40bf1ed898054c4d1dc4da9e6689b86aabaeb68c Mon Sep 17 00:00:00 2001 From: wkj <278599135@qq.com> Date: Thu, 12 Oct 2023 10:28:43 +0800 Subject: [PATCH 4/4] =?UTF-8?q?extrafile/upload=20removeitem=E5=90=8E=20?= =?UTF-8?q?=E8=BF=87=E6=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- es/components/extraFile/commit/web.js | 2 +- es/components/extraFile/commit/web.pc.js | 2 +- es/components/extraFile/upload/index.d.ts | 6 +-- es/components/extraFile/upload/index.js | 4 +- es/components/extraFile/upload/web.d.ts | 1 - es/components/extraFile/upload/web.js | 46 +++++++++++----------- es/data/i18n.js | 1 + es/locales/common/zh_CN.json | 1 + lib/components/extraFile/commit/web.js | 2 +- lib/components/extraFile/commit/web.pc.js | 2 +- lib/components/extraFile/upload/index.d.ts | 6 +-- lib/components/extraFile/upload/index.js | 4 +- lib/components/extraFile/upload/web.d.ts | 1 - lib/components/extraFile/upload/web.js | 46 +++++++++++----------- lib/data/i18n.js | 1 + lib/locales/common/zh_CN.json | 1 + src/components/extraFile/commit/web.pc.tsx | 2 +- src/components/extraFile/commit/web.tsx | 2 +- src/components/extraFile/upload/index.ts | 27 ++++++++++--- src/components/extraFile/upload/web.tsx | 6 --- src/data/i18n.ts | 1 + src/locales/common/zh_CN.json | 1 + 22 files changed, 91 insertions(+), 74 deletions(-) diff --git a/es/components/extraFile/commit/web.js b/es/components/extraFile/commit/web.js index 17473b474..bbe6b7fbf 100644 --- a/es/components/extraFile/commit/web.js +++ b/es/components/extraFile/commit/web.js @@ -6,7 +6,7 @@ export default function render(props) { const disabled = oakExecuting || ['uploading'].includes(state) || (oakExecutable === false && ['uploaded'].includes(state)); - let text = executeText || t('common::action.confirm'); + let text = executeText || t('common:submit'); if (oakExecuting) { text = t('executing', { text }); } diff --git a/es/components/extraFile/commit/web.pc.js b/es/components/extraFile/commit/web.pc.js index 3efefa647..1bc0c9171 100644 --- a/es/components/extraFile/commit/web.pc.js +++ b/es/components/extraFile/commit/web.pc.js @@ -6,7 +6,7 @@ export default function render(props) { const disabled = oakExecuting || ['uploading'].includes(state) || (oakExecutable !== true && ['uploaded'].includes(state)); - let text = executeText || t('common::action.confirm'); + let text = executeText || t('common:submit'); if (oakExecuting) { text = t('executing', { text }); } diff --git a/es/components/extraFile/upload/index.d.ts b/es/components/extraFile/upload/index.d.ts index 445fefdbb..d35a3b6f3 100644 --- a/es/components/extraFile/upload/index.d.ts +++ b/es/components/extraFile/upload/index.d.ts @@ -10,9 +10,9 @@ export interface EnhancedExtraFile extends ExtraFile { fileState?: FileState; percentage?: number; } -type SourceType = 'album' | 'camera'; export type Theme = 'file' | 'image' | 'image-flow' | 'custom'; -type ImgMode = 'scaleToFill' | 'aspectFit' | 'aspectFill' | 'widthFix' | "heightFix" | 'top' | 'bottom' | 'left' | 'right' | 'center' | 'top left' | 'top right' | 'bottom left' | 'bottom right'; +type SourceType = 'album' | 'camera'; +type ImageMode = 'scaleToFill' | 'aspectFit' | 'aspectFill' | 'widthFix' | 'heightFix' | 'top' | 'bottom' | 'left' | 'right' | 'center' | 'top left' | 'top right' | 'bottom left' | 'bottom right'; declare const _default: (props: ReactComponentProps ele1.sort - ele2.sort); + let files = data + ?.filter((ele) => !ele.$$deleteAt$$) + .sort((ele1, ele2) => ele1.sort - ele2.sort); if (this.props.tag1) { files = files?.filter((ele) => ele?.tag1 === this.props.tag1); } diff --git a/es/components/extraFile/upload/web.d.ts b/es/components/extraFile/upload/web.d.ts index 7c810a870..a1058805e 100644 --- a/es/components/extraFile/upload/web.d.ts +++ b/es/components/extraFile/upload/web.d.ts @@ -9,7 +9,6 @@ export default function render(props: WebComponentProps Promise | boolean; style?: Record; className?: string; diff --git a/es/components/extraFile/upload/web.js b/es/components/extraFile/upload/web.js index cb13033a1..483a6871e 100644 --- a/es/components/extraFile/upload/web.js +++ b/es/components/extraFile/upload/web.js @@ -48,7 +48,7 @@ const DraggableUploadListItem = ({ originNode, moveRow, file, fileList, }) => { return (_jsx("div", { ref: ref, className: `ant-upload-draggable-list-item ${isOver ? dropClassName : ""}`, style: { cursor: "move", height: "100%" }, children: originNode })); }; export default function render(props) { - const { accept = 'image/*', maxNumber = 20, multiple = maxNumber !== 1, draggable = false, theme = 'image', tips, beforeUpload, style, className, directory = false, onPreview, onDownload, children, showUploadList = true, files = [], disableInsert = false, disableDownload = false, disableDelete = false, disablePreview = false, } = props.data; + const { accept = 'image/*', maxNumber = 20, multiple = maxNumber !== 1, draggable = false, theme = 'image', beforeUpload, style, className, directory = false, onPreview, onDownload, children, showUploadList = true, files = [], disableInsert = false, disableDownload = false, disableDelete = false, disablePreview = false, } = props.data; const { t, updateItem, onRemove, addFileByWeb, checkSort } = props.methods; const listType = getListType(theme); const getUploadButton = () => { @@ -146,27 +146,27 @@ export default function render(props) { updateItem({ sort }, dragRow.id); } }, [files]); - return (_jsxs(Space, { direction: "vertical", className: Style['oak-upload'], style: { width: '100%' }, children: [_jsx(DndProvider, { backend: isPc ? HTML5Backend : TouchBackend, children: _jsx(Upload, { className: classNames(Style['oak-upload__upload'], className), style: style, directory: directory, showUploadList: showUploadList - ? { - showPreviewIcon: !disablePreview, - showRemoveIcon: !disableDelete, - showDownloadIcon: !disableDownload, + return (_jsx(Space, { direction: "vertical", className: Style['oak-upload'], style: { width: '100%' }, children: _jsx(DndProvider, { backend: isPc ? HTML5Backend : TouchBackend, children: _jsx(Upload, { className: classNames(Style['oak-upload__upload'], className), style: style, directory: directory, showUploadList: showUploadList + ? { + showPreviewIcon: !disablePreview, + showRemoveIcon: !disableDelete, + showDownloadIcon: !disableDownload, + } + : false, beforeUpload: async (file) => { + if (typeof beforeUpload === 'function') { + const result = await beforeUpload(file); + if (result) { + return false; } - : false, beforeUpload: async (file) => { - if (typeof beforeUpload === 'function') { - const result = await beforeUpload(file); - if (result) { - return false; - } - } - return false; - }, multiple: multiple, accept: accept, listType: listType, fileList: transformToUploadFile(), onChange: ({ file, fileList, event }) => { - if (file instanceof File) { - addFileByWeb(file); - } - }, onRemove: onRemove, onPreview: onPreview, onDownload: onDownload, itemRender: (originNode, currentFile, currentFileList) => { - return (_jsx(DraggableUploadListItem, { originNode: originNode, file: currentFile, fileList: currentFileList, moveRow: moveRow })); - }, children: !disableInsert && files.length < maxNumber - ? getUploadButton() - : null }) }), tips && (_jsx("small", { className: Style['oak-upload__tips'], children: tips }))] })); + } + return false; + }, multiple: multiple, accept: accept, listType: listType, fileList: transformToUploadFile(), onChange: ({ file, fileList, event }) => { + if (file instanceof File) { + addFileByWeb(file); + } + }, onRemove: onRemove, onPreview: onPreview, onDownload: onDownload, itemRender: (originNode, currentFile, currentFileList) => { + return (_jsx(DraggableUploadListItem, { originNode: originNode, file: currentFile, fileList: currentFileList, moveRow: moveRow })); + }, children: !disableInsert && files.length < maxNumber + ? getUploadButton() + : null }) }) })); } diff --git a/es/data/i18n.js b/es/data/i18n.js index cb0ebb55c..1e377a7ac 100644 --- a/es/data/i18n.js +++ b/es/data/i18n.js @@ -394,6 +394,7 @@ const i18ns = [ "newAdd": "新增", "add": "添加" }, + "submit": "提交", "reset": "重置", "select": "查询", "expand": "展开", diff --git a/es/locales/common/zh_CN.json b/es/locales/common/zh_CN.json index 53827656b..57edc4c87 100644 --- a/es/locales/common/zh_CN.json +++ b/es/locales/common/zh_CN.json @@ -16,6 +16,7 @@ "newAdd": "新增", "add": "添加" }, + "submit": "提交", "reset": "重置", "select": "查询", "expand": "展开", diff --git a/lib/components/extraFile/commit/web.js b/lib/components/extraFile/commit/web.js index 275e05625..fc1e89c1e 100644 --- a/lib/components/extraFile/commit/web.js +++ b/lib/components/extraFile/commit/web.js @@ -8,7 +8,7 @@ function render(props) { const disabled = oakExecuting || ['uploading'].includes(state) || (oakExecutable === false && ['uploaded'].includes(state)); - let text = executeText || t('common::action.confirm'); + let text = executeText || t('common:submit'); if (oakExecuting) { text = t('executing', { text }); } diff --git a/lib/components/extraFile/commit/web.pc.js b/lib/components/extraFile/commit/web.pc.js index 396fcedca..e9b743cab 100644 --- a/lib/components/extraFile/commit/web.pc.js +++ b/lib/components/extraFile/commit/web.pc.js @@ -8,7 +8,7 @@ function render(props) { const disabled = oakExecuting || ['uploading'].includes(state) || (oakExecutable !== true && ['uploaded'].includes(state)); - let text = executeText || t('common::action.confirm'); + let text = executeText || t('common:submit'); if (oakExecuting) { text = t('executing', { text }); } diff --git a/lib/components/extraFile/upload/index.d.ts b/lib/components/extraFile/upload/index.d.ts index 445fefdbb..d35a3b6f3 100644 --- a/lib/components/extraFile/upload/index.d.ts +++ b/lib/components/extraFile/upload/index.d.ts @@ -10,9 +10,9 @@ export interface EnhancedExtraFile extends ExtraFile { fileState?: FileState; percentage?: number; } -type SourceType = 'album' | 'camera'; export type Theme = 'file' | 'image' | 'image-flow' | 'custom'; -type ImgMode = 'scaleToFill' | 'aspectFit' | 'aspectFill' | 'widthFix' | "heightFix" | 'top' | 'bottom' | 'left' | 'right' | 'center' | 'top left' | 'top right' | 'bottom left' | 'bottom right'; +type SourceType = 'album' | 'camera'; +type ImageMode = 'scaleToFill' | 'aspectFit' | 'aspectFill' | 'widthFix' | 'heightFix' | 'top' | 'bottom' | 'left' | 'right' | 'center' | 'top left' | 'top right' | 'bottom left' | 'bottom right'; declare const _default: (props: ReactComponentProps ele1.sort - ele2.sort); + let files = data + ?.filter((ele) => !ele.$$deleteAt$$) + .sort((ele1, ele2) => ele1.sort - ele2.sort); if (this.props.tag1) { files = files?.filter((ele) => ele?.tag1 === this.props.tag1); } diff --git a/lib/components/extraFile/upload/web.d.ts b/lib/components/extraFile/upload/web.d.ts index 7c810a870..a1058805e 100644 --- a/lib/components/extraFile/upload/web.d.ts +++ b/lib/components/extraFile/upload/web.d.ts @@ -9,7 +9,6 @@ export default function render(props: WebComponentProps Promise | boolean; style?: Record; className?: string; diff --git a/lib/components/extraFile/upload/web.js b/lib/components/extraFile/upload/web.js index d3280a59d..3f6a1491f 100644 --- a/lib/components/extraFile/upload/web.js +++ b/lib/components/extraFile/upload/web.js @@ -51,7 +51,7 @@ const DraggableUploadListItem = ({ originNode, moveRow, file, fileList, }) => { return ((0, jsx_runtime_1.jsx)("div", { ref: ref, className: `ant-upload-draggable-list-item ${isOver ? dropClassName : ""}`, style: { cursor: "move", height: "100%" }, children: originNode })); }; function render(props) { - const { accept = 'image/*', maxNumber = 20, multiple = maxNumber !== 1, draggable = false, theme = 'image', tips, beforeUpload, style, className, directory = false, onPreview, onDownload, children, showUploadList = true, files = [], disableInsert = false, disableDownload = false, disableDelete = false, disablePreview = false, } = props.data; + const { accept = 'image/*', maxNumber = 20, multiple = maxNumber !== 1, draggable = false, theme = 'image', beforeUpload, style, className, directory = false, onPreview, onDownload, children, showUploadList = true, files = [], disableInsert = false, disableDownload = false, disableDelete = false, disablePreview = false, } = props.data; const { t, updateItem, onRemove, addFileByWeb, checkSort } = props.methods; const listType = getListType(theme); const getUploadButton = () => { @@ -149,28 +149,28 @@ function render(props) { updateItem({ sort }, dragRow.id); } }, [files]); - return ((0, jsx_runtime_1.jsxs)(antd_1.Space, { direction: "vertical", className: web_module_less_1.default['oak-upload'], style: { width: '100%' }, children: [(0, jsx_runtime_1.jsx)(react_dnd_1.DndProvider, { backend: utils_1.isPc ? react_dnd_html5_backend_1.HTML5Backend : react_dnd_touch_backend_1.TouchBackend, children: (0, jsx_runtime_1.jsx)(antd_1.Upload, { className: (0, classnames_1.default)(web_module_less_1.default['oak-upload__upload'], className), style: style, directory: directory, showUploadList: showUploadList - ? { - showPreviewIcon: !disablePreview, - showRemoveIcon: !disableDelete, - showDownloadIcon: !disableDownload, + return ((0, jsx_runtime_1.jsx)(antd_1.Space, { direction: "vertical", className: web_module_less_1.default['oak-upload'], style: { width: '100%' }, children: (0, jsx_runtime_1.jsx)(react_dnd_1.DndProvider, { backend: utils_1.isPc ? react_dnd_html5_backend_1.HTML5Backend : react_dnd_touch_backend_1.TouchBackend, children: (0, jsx_runtime_1.jsx)(antd_1.Upload, { className: (0, classnames_1.default)(web_module_less_1.default['oak-upload__upload'], className), style: style, directory: directory, showUploadList: showUploadList + ? { + showPreviewIcon: !disablePreview, + showRemoveIcon: !disableDelete, + showDownloadIcon: !disableDownload, + } + : false, beforeUpload: async (file) => { + if (typeof beforeUpload === 'function') { + const result = await beforeUpload(file); + if (result) { + return false; } - : false, beforeUpload: async (file) => { - if (typeof beforeUpload === 'function') { - const result = await beforeUpload(file); - if (result) { - return false; - } - } - return false; - }, multiple: multiple, accept: accept, listType: listType, fileList: transformToUploadFile(), onChange: ({ file, fileList, event }) => { - if (file instanceof File) { - addFileByWeb(file); - } - }, onRemove: onRemove, onPreview: onPreview, onDownload: onDownload, itemRender: (originNode, currentFile, currentFileList) => { - return ((0, jsx_runtime_1.jsx)(DraggableUploadListItem, { originNode: originNode, file: currentFile, fileList: currentFileList, moveRow: moveRow })); - }, children: !disableInsert && files.length < maxNumber - ? getUploadButton() - : null }) }), tips && ((0, jsx_runtime_1.jsx)("small", { className: web_module_less_1.default['oak-upload__tips'], children: tips }))] })); + } + return false; + }, multiple: multiple, accept: accept, listType: listType, fileList: transformToUploadFile(), onChange: ({ file, fileList, event }) => { + if (file instanceof File) { + addFileByWeb(file); + } + }, onRemove: onRemove, onPreview: onPreview, onDownload: onDownload, itemRender: (originNode, currentFile, currentFileList) => { + return ((0, jsx_runtime_1.jsx)(DraggableUploadListItem, { originNode: originNode, file: currentFile, fileList: currentFileList, moveRow: moveRow })); + }, children: !disableInsert && files.length < maxNumber + ? getUploadButton() + : null }) }) })); } exports.default = render; diff --git a/lib/data/i18n.js b/lib/data/i18n.js index 37f721d9a..61bc4be60 100644 --- a/lib/data/i18n.js +++ b/lib/data/i18n.js @@ -396,6 +396,7 @@ const i18ns = [ "newAdd": "新增", "add": "添加" }, + "submit": "提交", "reset": "重置", "select": "查询", "expand": "展开", diff --git a/lib/locales/common/zh_CN.json b/lib/locales/common/zh_CN.json index 53827656b..57edc4c87 100644 --- a/lib/locales/common/zh_CN.json +++ b/lib/locales/common/zh_CN.json @@ -16,6 +16,7 @@ "newAdd": "新增", "add": "添加" }, + "submit": "提交", "reset": "重置", "select": "查询", "expand": "展开", diff --git a/src/components/extraFile/commit/web.pc.tsx b/src/components/extraFile/commit/web.pc.tsx index dfd545ac3..f77d1d4ee 100644 --- a/src/components/extraFile/commit/web.pc.tsx +++ b/src/components/extraFile/commit/web.pc.tsx @@ -42,7 +42,7 @@ export default function render( oakExecuting || ['uploading'].includes(state) || (oakExecutable !== true && ['uploaded'].includes(state)); - let text = executeText || t('common::action.confirm'); + let text = executeText || t('common:submit'); if (oakExecuting) { text = t('executing', { text }); } else if (oakExecutable === false) { diff --git a/src/components/extraFile/commit/web.tsx b/src/components/extraFile/commit/web.tsx index 057adb9cc..f27dbb233 100644 --- a/src/components/extraFile/commit/web.tsx +++ b/src/components/extraFile/commit/web.tsx @@ -43,7 +43,7 @@ export default function render( oakExecuting || ['uploading'].includes(state) || (oakExecutable === false && ['uploaded'].includes(state)); - let text = executeText || t('common::action.confirm'); + let text = executeText || t('common:submit'); if (oakExecuting) { text = t('executing', { text }); } else if (oakExecutable === false) { diff --git a/src/components/extraFile/upload/index.ts b/src/components/extraFile/upload/index.ts index 20b6310a6..fad11e8d2 100644 --- a/src/components/extraFile/upload/index.ts +++ b/src/components/extraFile/upload/index.ts @@ -14,11 +14,24 @@ export interface EnhancedExtraFile extends ExtraFile { fileState?: FileState; percentage?: number; }; +export type Theme = 'file' | 'image' | 'image-flow' | 'custom'; type SourceType = 'album' | 'camera'; -export type Theme = 'file' | 'image' | 'image-flow' | 'custom'; -type ImgMode = 'scaleToFill' | 'aspectFit' | 'aspectFill' | 'widthFix' | "heightFix" | 'top' | 'bottom' | 'left' - | 'right' | 'center' | 'top left' | 'top right' | 'bottom left' | 'bottom right'; +type ImageMode = + | 'scaleToFill' + | 'aspectFit' + | 'aspectFill' + | 'widthFix' + | 'heightFix' + | 'top' + | 'bottom' + | 'left' + | 'right' + | 'center' + | 'top left' + | 'top right' + | 'bottom left' + | 'bottom right'; export default OakComponent({ entity: 'extraFile', @@ -72,7 +85,7 @@ export default OakComponent({ selectCount: 1, // 每次打开图片时,可选中的数量 小程序独有 sourceType: ['album', 'camera'] as SourceType[], // 小程序独有 chooseMedia mediaType: ['image'] as ('image' | 'video')[], // 小程序独有 chooseMedia - mode: 'aspectFit' as ImgMode, // 图片显示模式 + mode: 'aspectFit' as ImageMode, // 图片显示模式 size: 3, // 每行可显示的个数 小程序独有 showUploadList: true, //web独有 showUploadProgress: false, // web独有 @@ -123,7 +136,9 @@ export default OakComponent({ }, features: ['extraFile2'], formData({ data, features }) { - let files = data?.sort((ele1, ele2) => ele1.sort! - ele2.sort!); + let files = data + ?.filter((ele) => !ele.$$deleteAt$$) + .sort((ele1, ele2) => ele1.sort! - ele2.sort!); if (this.props.tag1) { files = files?.filter((ele) => ele?.tag1 === this.props.tag1); } @@ -363,7 +378,7 @@ export default OakComponent({ sourceType: SourceType[]; mediaType: ('image' | 'video')[]; // 图片显示模式 - mode: ImgMode; + mode: ImageMode; // 每行可显示的个数 size: number; showUploadList: boolean; diff --git a/src/components/extraFile/upload/web.tsx b/src/components/extraFile/upload/web.tsx index e83078200..9a203ac8f 100644 --- a/src/components/extraFile/upload/web.tsx +++ b/src/components/extraFile/upload/web.tsx @@ -80,7 +80,6 @@ export default function render( multiple?: boolean; draggable?: boolean; theme?: Theme; - tips?: string; beforeUpload?: (file: File) => Promise | boolean; style?: Record; className?: string; @@ -107,7 +106,6 @@ export default function render( multiple = maxNumber !== 1, draggable = false, theme = 'image', - tips, beforeUpload, style, className, @@ -287,10 +285,6 @@ export default function render( : null} - - {tips && ( - {tips} - )} ); } \ No newline at end of file diff --git a/src/data/i18n.ts b/src/data/i18n.ts index a5afd9582..6c20d56bc 100644 --- a/src/data/i18n.ts +++ b/src/data/i18n.ts @@ -396,6 +396,7 @@ const i18ns: I18n[] = [ "newAdd": "新增", "add": "添加" }, + "submit": "提交", "reset": "重置", "select": "查询", "expand": "展开", diff --git a/src/locales/common/zh_CN.json b/src/locales/common/zh_CN.json index 71a893b0a..28954a787 100644 --- a/src/locales/common/zh_CN.json +++ b/src/locales/common/zh_CN.json @@ -16,6 +16,7 @@ "newAdd": "新增", "add": "添加" }, + "submit": "提交", "reset": "重置", "select": "查询", "expand": "展开",