Merge branch 'dev' of codeup.aliyun.com:61c14a7efa282c88e103c23f/oak-general-business into dev
This commit is contained in:
commit
bd979ccca0
|
|
@ -2,6 +2,7 @@ import { WebEnv, WechatMpEnv } from 'oak-domain/lib/types/Environment';
|
|||
import { AppType } from '../oak-app-domain/Application/Schema';
|
||||
import { EntityDict } from '../oak-app-domain';
|
||||
import { Config } from '../types/Config';
|
||||
import { Style } from '../types/Style';
|
||||
import { MenuType } from '../types/WeChat';
|
||||
import { BackendRuntimeContext } from '../context/BackendRuntimeContext';
|
||||
import { WechatPublicEventData, WechatMpEventData } from 'oak-external-sdk';
|
||||
|
|
@ -65,6 +66,11 @@ export type GeneralAspectDict<ED extends EntityDict, Cxt extends BackendRuntimeC
|
|||
entityId: string;
|
||||
config: Config;
|
||||
}, context: Cxt) => Promise<void>;
|
||||
updateStyle: (params: {
|
||||
entity: 'platform' | 'system' | 'application';
|
||||
entityId: string;
|
||||
style: Style;
|
||||
}, context: Cxt) => Promise<void>;
|
||||
updateApplicationConfig: (params: {
|
||||
entity: 'application';
|
||||
entityId: string;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import { loginByMobile, loginWechat, loginWechatMp, syncUserInfoWechatMp, sendCa
|
|||
import { getInfoByUrl } from './extraFile';
|
||||
import { getApplication, signatureJsSDK, uploadWechatMedia } from './application';
|
||||
import { updateConfig, updateApplicationConfig } from './config';
|
||||
import { updateStyle } from './style2';
|
||||
import { mergeUser, getChangePasswordChannels, updateUserPassword } from './user';
|
||||
import { createWechatLogin } from './wechatLogin';
|
||||
import { unbindingWechat } from './wechatUser';
|
||||
|
|
@ -22,6 +23,7 @@ declare const aspectDict: {
|
|||
sendCaptcha: typeof sendCaptcha;
|
||||
getApplication: typeof getApplication;
|
||||
updateConfig: typeof updateConfig;
|
||||
updateStyle: typeof updateStyle;
|
||||
updateApplicationConfig: typeof updateApplicationConfig;
|
||||
getWechatMpUserPhoneNumber: typeof getWechatMpUserPhoneNumber;
|
||||
logout: typeof logout;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import { loginByMobile, loginWechat, loginWechatMp, syncUserInfoWechatMp, sendCa
|
|||
import { getInfoByUrl } from './extraFile';
|
||||
import { getApplication, signatureJsSDK, uploadWechatMedia, } from './application';
|
||||
import { updateConfig, updateApplicationConfig } from './config';
|
||||
import { updateStyle } from './style2';
|
||||
import { mergeUser, getChangePasswordChannels, updateUserPassword } from './user';
|
||||
import { createWechatLogin } from './wechatLogin';
|
||||
import { unbindingWechat } from './wechatUser';
|
||||
|
|
@ -22,6 +23,7 @@ const aspectDict = {
|
|||
sendCaptcha,
|
||||
getApplication,
|
||||
updateConfig,
|
||||
updateStyle,
|
||||
updateApplicationConfig,
|
||||
getWechatMpUserPhoneNumber,
|
||||
logout,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
import { BackendRuntimeContext } from '../context/BackendRuntimeContext';
|
||||
import { EntityDict } from '../oak-app-domain';
|
||||
import { Style } from '../types/Style';
|
||||
export declare function updateStyle<ED extends EntityDict, Cxt extends BackendRuntimeContext<ED>>(params: {
|
||||
entity: 'platform' | 'system';
|
||||
entityId: string;
|
||||
style: Style;
|
||||
}, context: Cxt): Promise<void>;
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
import { generateNewId } from 'oak-domain/lib/utils/uuid';
|
||||
export async function updateStyle(params, context) {
|
||||
const { entity, entityId, style } = params;
|
||||
await context.operate(entity, {
|
||||
id: generateNewId(),
|
||||
action: 'update',
|
||||
data: {
|
||||
style,
|
||||
},
|
||||
filter: {
|
||||
id: entityId,
|
||||
}
|
||||
}, {});
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
import { BackendRuntimeContext } from '../context/BackendRuntimeContext';
|
||||
import { EntityDict } from '../oak-app-domain';
|
||||
import { Style } from '../types/Style';
|
||||
export declare function updateStyle<ED extends EntityDict, Cxt extends BackendRuntimeContext<ED>>(params: {
|
||||
entity: 'platform' | 'system';
|
||||
entityId: string;
|
||||
style: Style;
|
||||
}, context: Cxt): Promise<void>;
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
import { generateNewId } from 'oak-domain/lib/utils/uuid';
|
||||
export async function updateStyle(params, context) {
|
||||
const { entity, entityId, style } = params;
|
||||
await context.operate(entity, {
|
||||
id: generateNewId(),
|
||||
action: 'update',
|
||||
data: {
|
||||
style,
|
||||
},
|
||||
filter: {
|
||||
id: entityId,
|
||||
}
|
||||
}, {});
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|||
import { Tabs } from 'antd';
|
||||
import ApplicationDetail from '../detail';
|
||||
import ConfigUpsert from '../../config/application';
|
||||
import StyleUpsert from '../../config/style';
|
||||
import StyleUpsert from '../../config/style/platform';
|
||||
import Styles from './web.pc.module.less';
|
||||
export default function Render(props) {
|
||||
const { id, config, oakFullpath, name, style } = props.data;
|
||||
|
|
@ -22,9 +22,7 @@ export default function Render(props) {
|
|||
{
|
||||
label: _jsx("div", { className: Styles.tabLabel, children: t('style') }),
|
||||
key: 'style',
|
||||
children: (_jsx(StyleUpsert, { value: style, onChange: (s) => {
|
||||
update({ style: s });
|
||||
} })),
|
||||
children: (_jsx(StyleUpsert, { style: style, entity: 'platform', entityId: id, name: name })),
|
||||
},
|
||||
] }) }));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
/// <reference types="react" />
|
||||
import { Style } from '../../../../types/Style';
|
||||
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<import("../../../../oak-app-domain").EntityDict, keyof import("../../../../oak-app-domain").EntityDict, false, {
|
||||
style: Style;
|
||||
entity: "application" | "system" | "platform";
|
||||
entityId: string;
|
||||
name: string;
|
||||
}>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
||||
export default _default;
|
||||
|
|
@ -0,0 +1,86 @@
|
|||
import { cloneDeep } from 'oak-domain/lib/utils/lodash';
|
||||
export default OakComponent({
|
||||
isList: false,
|
||||
properties: {
|
||||
style: {},
|
||||
entity: '',
|
||||
entityId: '',
|
||||
name: '',
|
||||
},
|
||||
data: {
|
||||
initialStyle: {},
|
||||
dirty: false,
|
||||
currentStyle: {},
|
||||
},
|
||||
// listeners: {
|
||||
// config(prev, next) {
|
||||
// if (prev.config !== next.config) {
|
||||
// const config2 = next.config || {};
|
||||
// this.setState({
|
||||
// initialConfig: config2,
|
||||
// dirty: false,
|
||||
// currentConfig: cloneDeep(config2),
|
||||
// });
|
||||
// }
|
||||
// },
|
||||
// },
|
||||
lifetimes: {
|
||||
ready() {
|
||||
const { style } = this.props;
|
||||
this.setState({
|
||||
initialStyle: style,
|
||||
dirty: false,
|
||||
currentStyle: cloneDeep(style),
|
||||
});
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
setValue(newStyle) {
|
||||
const newStyle2 = cloneDeep(newStyle || {});
|
||||
this.setState({
|
||||
currentStyle: newStyle2,
|
||||
dirty: true,
|
||||
});
|
||||
},
|
||||
// cleanKey(path: string, key: string) {
|
||||
// const { currentConfig } = this.state;
|
||||
// const obj = get(currentConfig, path);
|
||||
// const obj2 = omit(obj, [key]);
|
||||
// set(currentConfig, path, obj2);
|
||||
// const newConfig = cloneDeep(currentConfig);
|
||||
// this.setState({
|
||||
// currentConfig: newConfig,
|
||||
// dirty: true,
|
||||
// });
|
||||
// },
|
||||
// removeItem(path: string, index: number) {
|
||||
// const { currentConfig } = this.state;
|
||||
// const array = get(currentConfig, path);
|
||||
// (array as any[]).splice(index, 1);
|
||||
// const newConfig = cloneDeep(currentConfig || {});
|
||||
// this.setState({
|
||||
// currentConfig: newConfig,
|
||||
// dirty: true,
|
||||
// });
|
||||
// },
|
||||
resetStyle() {
|
||||
const { initialStyle } = this.state;
|
||||
this.setState({
|
||||
dirty: false,
|
||||
currentStyle: cloneDeep(initialStyle),
|
||||
});
|
||||
},
|
||||
async updateStyle() {
|
||||
const { currentStyle } = this.state;
|
||||
const { entity, entityId } = this.props;
|
||||
await this.features.style2.updateStyle(entity, entityId, currentStyle);
|
||||
this.setMessage({
|
||||
content: '操作成功',
|
||||
type: 'success',
|
||||
});
|
||||
this.setState({
|
||||
dirty: false,
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
.container {
|
||||
background: var(--oak-bg-color-container);
|
||||
// box-shadow: 0 2px 3px #0000001a;
|
||||
// border-radius: 3px;
|
||||
padding: 30px 32px;
|
||||
}
|
||||
|
||||
.padding {
|
||||
background-color: var(--oak-bg-color-page);
|
||||
width: 100%;
|
||||
height: 77px;
|
||||
}
|
||||
|
||||
.ctrl {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 10px;
|
||||
border: solid 0.4px;
|
||||
border-radius: 3px;
|
||||
border-color: var(--oak-border-color);
|
||||
position: absolute;
|
||||
z-index: 10;
|
||||
background-color: var(--oak-bg-color-container);
|
||||
width: calc(100vw - 138px);
|
||||
top: 85px;
|
||||
height: 55px;
|
||||
|
||||
text {
|
||||
color: var(--oak-text-color-secondary);
|
||||
|
||||
.weight {
|
||||
font-weight: bold;
|
||||
color: var(--oak-text-color-primary);
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.contains {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
import { Style as StyleDef } from '../../../../types/Style';
|
||||
import { EntityDict } from '../../../../oak-app-domain';
|
||||
import { WebComponentProps } from 'oak-frontend-base';
|
||||
export default function Render(props: WebComponentProps<EntityDict, 'user', false, {
|
||||
entity: string;
|
||||
name: string;
|
||||
currentStyle: StyleDef;
|
||||
dirty: boolean;
|
||||
}, {
|
||||
resetStyle: () => void;
|
||||
updateStyle: () => void;
|
||||
setValue: (style: StyleDef) => void;
|
||||
}>): import("react/jsx-runtime").JSX.Element;
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
||||
import { Button, Alert, Affix, Space, Typography } from 'antd';
|
||||
import Style from './web.module.less';
|
||||
import StyleUpsert from '../../style';
|
||||
export default function Render(props) {
|
||||
const { entity, currentStyle, dirty, name } = props.data;
|
||||
const { resetStyle, updateStyle, setValue, t } = props.methods;
|
||||
return (_jsxs(_Fragment, { children: [_jsx(Affix, { offsetTop: 64, children: _jsx(Alert, { message: _jsx("div", { children: _jsxs("text", { children: ["\u60A8\u6B63\u5728\u66F4\u65B0", _jsx(Typography.Text, { keyboard: true, className: Style.weight, children: entity }), "\u5BF9\u8C61", _jsx(Typography.Text, { keyboard: true, className: Style.weight, children: name }), "\u7684\u6837\u5F0F\uFF0C\u8BF7\u8C28\u614E\u64CD\u4F5C"] }) }), type: "info", showIcon: true, action: _jsxs(Space, { children: [_jsx(Button, { disabled: !dirty, type: "primary", danger: true, onClick: () => resetStyle(), style: {
|
||||
marginRight: 10,
|
||||
}, children: t('common::reset') }), _jsx(Button, { disabled: !dirty, type: "primary", onClick: () => updateStyle(), children: t('common::action.confirm') })] }) }) }), _jsx("div", { className: Style.contains, children: _jsx(StyleUpsert, { value: currentStyle, onChange: (s) => {
|
||||
setValue(s);
|
||||
} }) })] }));
|
||||
}
|
||||
|
|
@ -112,5 +112,5 @@ function AmapAccount(props) {
|
|||
export default function Account(props) {
|
||||
const { account, setValue, removeItem } = props;
|
||||
const { tencent, qiniu, ali, amap } = account;
|
||||
return (_jsxs(Space, { direction: "vertical", size: "middle", style: { display: 'flex' }, children: [_jsx(Row, { children: _jsx(Card, { className: Styles.tips, children: "\u6BCF\u79CD\u4E91\u5382\u5546\u5747\u53EF\u914D\u7F6E\u591A\u4E2A\u5E10\u53F7\uFF0C\u76F8\u5E94\u7684\u670D\u52A1\u6240\u4F7F\u7528\u7684\u5E10\u53F7\u8BF7\u51C6\u786E\u5BF9\u5E94" }) }), _jsx(TencentAccount, { accounts: tencent || [], setValue: (path, value) => setValue(`tencent.${path}`, value), removeItem: (path, index) => removeItem(`tencent`, index), addItem: (path, index) => setValue(`amap.${index}`, {}) }), _jsx(QiniuAccount, { accounts: qiniu || [], setValue: (path, value) => setValue(`qiniu.${path}`, value), removeItem: (path, index) => removeItem(`qiniu`, index), addItem: (path, index) => setValue(`amap.${index}`, {}) }), _jsx(AliAccount, { accounts: ali || [], setValue: (path, value) => setValue(`ali.${path}`, value), removeItem: (path, index) => removeItem(`ali`, index), addItem: (path, index) => setValue(`amap.${index}`, {}) }), _jsx(AmapAccount, { accounts: amap || [], setValue: (path, value) => setValue(`amap.${path}`, value), removeItem: (path, index) => removeItem(`amap`, index), addItem: (path, index) => setValue(`amap.${index}`, {}) })] }));
|
||||
return (_jsxs(Space, { direction: "vertical", size: "middle", style: { display: 'flex' }, children: [_jsx(Row, { children: _jsx(Card, { className: Styles.tips, children: "\u6BCF\u79CD\u4E91\u5382\u5546\u5747\u53EF\u914D\u7F6E\u591A\u4E2A\u5E10\u53F7\uFF0C\u76F8\u5E94\u7684\u670D\u52A1\u6240\u4F7F\u7528\u7684\u5E10\u53F7\u8BF7\u51C6\u786E\u5BF9\u5E94" }) }), _jsx(TencentAccount, { accounts: tencent || [], setValue: (path, value) => setValue(`tencent.${path}`, value), removeItem: (path, index) => removeItem(`tencent`, index), addItem: (path, index) => setValue(`tencent.${index}`, {}) }), _jsx(QiniuAccount, { accounts: qiniu || [], setValue: (path, value) => setValue(`qiniu.${path}`, value), removeItem: (path, index) => removeItem(`qiniu`, index), addItem: (path, index) => setValue(`qiniu.${index}`, {}) }), _jsx(AliAccount, { accounts: ali || [], setValue: (path, value) => setValue(`ali.${path}`, value), removeItem: (path, index) => removeItem(`ali`, index), addItem: (path, index) => setValue(`ali.${index}`, {}) }), _jsx(AmapAccount, { accounts: amap || [], setValue: (path, value) => setValue(`amap.${path}`, value), removeItem: (path, index) => removeItem(`amap`, index), addItem: (path, index) => setValue(`amap.${index}`, {}) })] }));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,11 +7,11 @@ function QiniuCos(props) {
|
|||
{
|
||||
key: '0',
|
||||
label: '配置项',
|
||||
children: (_jsxs(Form, { colon: true, labelAlign: "left", layout: "vertical", style: { marginTop: 10 }, children: [_jsx(Form.Item, { label: "accessKey", children: _jsx(_Fragment, { children: _jsx(Input, { placeholder: "\u8BF7\u8F93\u5165accessKey", type: "text", value: cos?.accessKey, onChange: (e) => setValue(`accessKey`, e.target.value) }) }) }), _jsx(Form.Item, { label: "uploadHost", children: _jsx(_Fragment, { children: _jsx(Input, { placeholder: "\u8BF7\u8F93\u5165uploadHost", type: "text", value: cos?.uploadHost, onChange: (e) => setValue(`uploadHost`, e.target.value) }) }) }), _jsx(Tabs, { tabPosition: 'top', size: 'middle', type: "editable-card",
|
||||
children: (_jsxs(Form, { colon: true, labelAlign: "left", layout: "vertical", style: { marginTop: 10 }, children: [_jsx(Form.Item, { label: "accessKey", children: _jsx(_Fragment, { children: _jsx(Input, { placeholder: "\u8BF7\u8F93\u5165accessKey", type: "text", value: cos?.accessKey, onChange: (e) => setValue(`accessKey`, e.target.value) }) }) }), _jsx(Form.Item, { label: "uploadHost", children: _jsx(_Fragment, { children: _jsx(Input, { placeholder: "\u8BF7\u8F93\u5165uploadHost", type: "text", value: cos?.uploadHost, onChange: (e) => setValue(`uploadHost`, e.target.value) }) }) }), _jsx(Divider, { orientation: "left", className: Styles.title, children: "bucket\u914D\u7F6E" }), _jsx(Tabs, { tabPosition: 'top', size: 'middle', type: "editable-card",
|
||||
// hideAdd={!(sms.length > 0)}
|
||||
onEdit: (targetKey, action) => {
|
||||
if (action === 'add') {
|
||||
setValue(`buckets.${cos.buckets.length}`, {});
|
||||
setValue(`buckets.${cos?.buckets?.length || 0}`, {});
|
||||
}
|
||||
else {
|
||||
removeItem('buckets', parseInt(targetKey, 10));
|
||||
|
|
|
|||
|
|
@ -123,7 +123,6 @@ export default OakComponent({
|
|||
this.addItem(Object.assign({}, updateData, {
|
||||
extra1: null,
|
||||
}), undefined, async () => {
|
||||
console.log(updateData);
|
||||
await this.features.extraFile.upload(updateData, extra1);
|
||||
});
|
||||
if (avatar) {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,6 @@ declare const _default: (props: import("oak-frontend-base").ReactComponentProps<
|
|||
type: string;
|
||||
executeText: string;
|
||||
buttonProps: {};
|
||||
afterCommit: () => undefined;
|
||||
afterCommit: () => void;
|
||||
}>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
||||
export default _default;
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ export default OakComponent({
|
|||
type: 'primary',
|
||||
executeText: '',
|
||||
buttonProps: {},
|
||||
afterCommit: () => undefined,
|
||||
afterCommit: () => { },
|
||||
},
|
||||
methods: {
|
||||
getEfIds() {
|
||||
|
|
|
|||
|
|
@ -163,7 +163,6 @@ export default OakComponent({
|
|||
type: 'image',
|
||||
tag1,
|
||||
tag2,
|
||||
objectId: generateNewId(),
|
||||
bucket: '',
|
||||
id: generateNewId(),
|
||||
};
|
||||
|
|
|
|||
|
|
@ -3,14 +3,12 @@ import { EntityDict as BaseEntityDict } from 'oak-domain/lib/types/Entity';
|
|||
import { ReactComponentProps } from 'oak-frontend-base/lib/types/Page';
|
||||
type SourceType = 'album' | 'camera';
|
||||
type Theme = 'file' | 'image' | 'image-flow' | 'custom';
|
||||
type FileType = 'all' | 'video' | 'image' | 'file';
|
||||
type ImgMode = 'scaleToFill' | 'aspectFit' | 'aspectFill' | 'widthFix' | "heightFix" | 'top' | 'bottom' | 'left' | 'right' | 'center' | 'top left' | 'top right' | 'bottom left' | 'bottom right';
|
||||
declare const _default: <ED2 extends EntityDict & BaseEntityDict, T2 extends keyof ED2>(props: ReactComponentProps<ED2, T2, true, {
|
||||
removeLater: boolean;
|
||||
autoUpload: boolean;
|
||||
maxNumber: number;
|
||||
extension: string[];
|
||||
fileType: FileType;
|
||||
selectCount: number;
|
||||
sourceType: SourceType[];
|
||||
mediaType: ('image' | 'video')[];
|
||||
|
|
@ -18,7 +16,7 @@ declare const _default: <ED2 extends EntityDict & BaseEntityDict, T2 extends key
|
|||
size: number;
|
||||
showUploadList: boolean;
|
||||
accept: string;
|
||||
preview: boolean;
|
||||
disablePreview: boolean;
|
||||
disableDelete: boolean;
|
||||
disableAdd: boolean;
|
||||
disableDownload: boolean;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { generateNewId } from 'oak-domain/lib/utils/uuid';
|
||||
import assert from 'assert';
|
||||
import { assert } from 'oak-domain/lib/utils/assert';
|
||||
import Dialog from '../../../utils/dialog/index';
|
||||
export default OakComponent({
|
||||
entity: 'extraFile',
|
||||
|
|
@ -23,8 +23,9 @@ export default OakComponent({
|
|||
uploadState: 1,
|
||||
},
|
||||
formData({ data: originalFiles, features }) {
|
||||
console.log(originalFiles);
|
||||
let files = originalFiles?.filter((ele) => !ele.$$deleteAt$$).sort((ele1, ele2) => ele1.sort - ele2.sort);
|
||||
let files = originalFiles
|
||||
?.filter((ele) => !ele.$$deleteAt$$)
|
||||
.sort((ele1, ele2) => ele1.sort - ele2.sort);
|
||||
if (this.props.tag1) {
|
||||
files = files?.filter((ele) => ele?.tag1 === this.props.tag1);
|
||||
}
|
||||
|
|
@ -40,7 +41,7 @@ export default OakComponent({
|
|||
data: {
|
||||
// 根据 size 不同,计算的图片显示大小不同
|
||||
itemSizePercentage: '',
|
||||
fileList: {}
|
||||
fileList: {},
|
||||
},
|
||||
wechatMp: {
|
||||
externalClasses: ['oak-class', 'oak-item-class'],
|
||||
|
|
@ -65,23 +66,17 @@ export default OakComponent({
|
|||
autoUpload: false,
|
||||
maxNumber: 20,
|
||||
extension: [],
|
||||
fileType: 'all',
|
||||
selectCount: 1,
|
||||
sourceType: ['album', 'camera'],
|
||||
mediaType: ['image'],
|
||||
// 图片显示模式
|
||||
mode: 'aspectFit',
|
||||
// 每行可显示的个数
|
||||
size: 3,
|
||||
showUploadList: true,
|
||||
showUploadProgress: false,
|
||||
accept: 'image/*',
|
||||
// 图片是否可预览
|
||||
preview: true,
|
||||
// 图片是否可删除
|
||||
disablePreview: false,
|
||||
disableDelete: false,
|
||||
// 上传按钮隐藏
|
||||
disableAdd: false,
|
||||
// 下按按钮隐藏
|
||||
disableDownload: false,
|
||||
disabled: false,
|
||||
type: '',
|
||||
|
|
@ -91,15 +86,14 @@ export default OakComponent({
|
|||
entity: '',
|
||||
entityId: '',
|
||||
theme: 'image',
|
||||
showUploadProgress: false,
|
||||
},
|
||||
methods: {
|
||||
getUrl(extraFile) {
|
||||
const { fileList } = this.state;
|
||||
if (fileList[extraFile?.id]) {
|
||||
console.log(fileList[extraFile?.id]);
|
||||
const url = this.features.extraFile.getUrl(Object.assign({}, extraFile, { extra1: fileList[extraFile?.id] }));
|
||||
console.log(url);
|
||||
const url = this.features.extraFile.getUrl(Object.assign({}, extraFile, {
|
||||
extra1: fileList[extraFile?.id],
|
||||
}));
|
||||
return url;
|
||||
}
|
||||
return this.features.extraFile.getUrl(extraFile);
|
||||
|
|
@ -107,7 +101,7 @@ export default OakComponent({
|
|||
getFileName(extraFile) {
|
||||
return this.features.extraFile.getFileName(extraFile);
|
||||
},
|
||||
eFFormatBytes(value) {
|
||||
formatBytes(value) {
|
||||
return this.features.extraFile.formatBytes(value);
|
||||
},
|
||||
/**
|
||||
|
|
@ -174,12 +168,12 @@ export default OakComponent({
|
|||
}
|
||||
},
|
||||
async chooseFileByMp() {
|
||||
const { selectCount, extension, fileType } = this.props;
|
||||
const { selectCount, extension } = this.props;
|
||||
try {
|
||||
const { errMsg, tempFiles } = await wx.chooseMessageFile({
|
||||
count: selectCount,
|
||||
type: 'all',
|
||||
...(fileType === 'file' ? { extension } : {}),
|
||||
extension,
|
||||
});
|
||||
if (errMsg !== 'chooseMessageFile:ok') {
|
||||
this.triggerEvent('error', {
|
||||
|
|
@ -220,7 +214,9 @@ export default OakComponent({
|
|||
},
|
||||
async onPickByWeb(uploadFiles, callback) {
|
||||
const { files } = this.state;
|
||||
const currentSort = files?.length ? files[files.length - 1].sort : 0;
|
||||
const currentSort = files?.length
|
||||
? files[files.length - 1].sort
|
||||
: 0;
|
||||
await Promise.all(uploadFiles.map(async (uploadFile, index) => {
|
||||
const { name, type, size, originFileObj } = uploadFile;
|
||||
await this.pushExtraFile({
|
||||
|
|
@ -228,7 +224,7 @@ export default OakComponent({
|
|||
fileType: type,
|
||||
size,
|
||||
extra1: originFileObj,
|
||||
sort: currentSort + (index + 1) * 100
|
||||
sort: currentSort + (index + 1) * 100,
|
||||
}, callback);
|
||||
}));
|
||||
},
|
||||
|
|
@ -239,7 +235,6 @@ export default OakComponent({
|
|||
const filename = name.substring(0, name.lastIndexOf('.'));
|
||||
assert(entity, '必须传入entity');
|
||||
assert(origin === 'qiniu', '目前只支持七牛上传'); // 目前只支持七牛上传
|
||||
const id = generateNewId();
|
||||
const updateData = {
|
||||
origin,
|
||||
type: type || 'file',
|
||||
|
|
@ -251,9 +246,8 @@ export default OakComponent({
|
|||
size,
|
||||
extension,
|
||||
fileType,
|
||||
id,
|
||||
entityId,
|
||||
sort
|
||||
sort,
|
||||
};
|
||||
// autoUpload为true, 选择直接上传七牛,再提交extraFile
|
||||
if (autoUpload) {
|
||||
|
|
@ -273,16 +267,17 @@ export default OakComponent({
|
|||
if (callback) {
|
||||
callback(updateData, 'failed');
|
||||
}
|
||||
//todo 保存extraFile失败 需要remove七牛图片
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.addItem(updateData, undefined, async () => {
|
||||
const id = this.addItem(updateData, undefined, async () => {
|
||||
await this.features.extraFile.upload(updateData, extra1);
|
||||
});
|
||||
this.setState({
|
||||
fileList: Object.assign(this.state.fileList, { [id]: extra1 })
|
||||
fileList: Object.assign(this.state.fileList, {
|
||||
[id]: extra1,
|
||||
}),
|
||||
});
|
||||
}
|
||||
},
|
||||
|
|
@ -301,7 +296,7 @@ export default OakComponent({
|
|||
};
|
||||
this.triggerEvent('tap', detail);
|
||||
// 预览图片
|
||||
if (this.props.preview) {
|
||||
if (!this.props.disablePreview) {
|
||||
const result = await wx.previewImage({
|
||||
urls: urls,
|
||||
current: imageUrl,
|
||||
|
|
@ -320,7 +315,7 @@ export default OakComponent({
|
|||
[id]: null,
|
||||
});
|
||||
this.setState({
|
||||
fileList
|
||||
fileList,
|
||||
});
|
||||
}
|
||||
else {
|
||||
|
|
@ -335,7 +330,7 @@ export default OakComponent({
|
|||
id: null,
|
||||
});
|
||||
this.setState({
|
||||
fileList
|
||||
fileList,
|
||||
});
|
||||
await this.execute();
|
||||
}
|
||||
|
|
@ -352,7 +347,7 @@ export default OakComponent({
|
|||
id: null,
|
||||
});
|
||||
this.setState({
|
||||
fileList
|
||||
fileList,
|
||||
});
|
||||
}
|
||||
else {
|
||||
|
|
@ -367,7 +362,7 @@ export default OakComponent({
|
|||
id: null,
|
||||
});
|
||||
this.setState({
|
||||
fileList
|
||||
fileList,
|
||||
});
|
||||
await this.execute();
|
||||
confirm.destroy();
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ interface NewUploadFile extends UploadFile {
|
|||
id?: string;
|
||||
}
|
||||
type Theme = "file" | "image" | "image-flow" | "custom";
|
||||
export default function render(props: WebComponentProps<EntityDict, "extraFile", true, {
|
||||
export default function render(props: WebComponentProps<EntityDict, 'extraFile', true, {
|
||||
accept?: string;
|
||||
maxNumber?: number;
|
||||
multiple?: boolean;
|
||||
|
|
@ -21,17 +21,17 @@ export default function render(props: WebComponentProps<EntityDict, "extraFile",
|
|||
onDownload?: (file: UploadFile<any>) => void;
|
||||
showUploadList?: boolean;
|
||||
children?: JSX.Element;
|
||||
files?: EntityDict["extraFile"]["OpSchema"][];
|
||||
files?: EntityDict['extraFile']['OpSchema'][];
|
||||
disableInsert?: boolean;
|
||||
disableAdd?: boolean;
|
||||
disableDownload?: boolean;
|
||||
disableDelete?: boolean;
|
||||
preview?: boolean;
|
||||
disablePreview?: boolean;
|
||||
}, {
|
||||
onPickByWeb: (files: UploadFile[], callback?: (file: NewUploadFile, status: string) => void) => void;
|
||||
onDeleteByWeb: (file: UploadFile) => void;
|
||||
getUrl: (extraFile: EntityDict['extraFile']['OpSchema']) => string;
|
||||
getFileName: (extraFile: EntityDict['extraFile']['OpSchema']) => string;
|
||||
eFFormatBytes: (value: number) => string;
|
||||
formatBytes: (value: number) => string;
|
||||
}>): import("react/jsx-runtime").JSX.Element;
|
||||
export {};
|
||||
|
|
|
|||
|
|
@ -49,8 +49,8 @@ const DragableUploadListItem = ({ 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, disabled, style, className, directory = false, onPreview, onDownload, children, showUploadList = true, files, disableInsert = false, disableAdd = false, disableDownload = false, disableDelete = false, preview = true, } = props.data;
|
||||
const { onPickByWeb, onDeleteByWeb, updateItem, t, getFileName, getUrl, eFFormatBytes } = props.methods;
|
||||
const { accept = 'image/*', maxNumber = 20, multiple = maxNumber !== 1, draggable = false, theme = 'image', tips, beforeUpload, disabled, style, className, directory = false, onPreview, onDownload, children, showUploadList = true, files, disableInsert = false, disableAdd = false, disableDownload = false, disableDelete = false, disablePreview = false, } = props.data;
|
||||
const { onPickByWeb, onDeleteByWeb, updateItem, t, getFileName, getUrl, formatBytes, } = props.methods;
|
||||
const [newFiles, setNewFiles] = useState([]);
|
||||
const [newUploadFiles, setNewUploadFiles] = useState([]);
|
||||
const listType = getListType(theme);
|
||||
|
|
@ -111,7 +111,7 @@ export default function render(props) {
|
|||
if (children) {
|
||||
return children;
|
||||
}
|
||||
if (listType === "picture-card") {
|
||||
if (listType === 'picture-card') {
|
||||
return (_jsxs("div", { children: [_jsx(PlusOutlined, {}), _jsx("div", { style: { marginTop: 8 }, children: "\u8BF7\u9009\u62E9\u56FE\u7247" })] }));
|
||||
}
|
||||
return _jsx(Button, { type: "default", children: "\u9009\u62E9\u6587\u4EF6" });
|
||||
|
|
@ -131,7 +131,10 @@ export default function render(props) {
|
|||
sort = newFiles[hoverIndex].sort + 100;
|
||||
}
|
||||
else {
|
||||
sort = (newFiles[hoverIndex].sort + newFiles[hoverIndex + 1].sort) / 2;
|
||||
sort =
|
||||
(newFiles[hoverIndex].sort +
|
||||
newFiles[hoverIndex + 1].sort) /
|
||||
2;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
@ -139,35 +142,38 @@ export default function render(props) {
|
|||
sort = newFiles[hoverIndex].sort / 2;
|
||||
}
|
||||
else {
|
||||
sort = (newFiles[hoverIndex].sort + newFiles[hoverIndex - 1].sort) / 2;
|
||||
sort =
|
||||
(newFiles[hoverIndex].sort +
|
||||
newFiles[hoverIndex - 1].sort) /
|
||||
2;
|
||||
}
|
||||
}
|
||||
if (checkLimit(sort)) {
|
||||
alert("当前的sort值为:" + sort);
|
||||
alert('当前的sort值为:' + sort);
|
||||
return;
|
||||
}
|
||||
updateItem({ sort }, dragRow.id);
|
||||
}, [newFiles]);
|
||||
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, disabled: disabled, directory: directory, showUploadList: showUploadList
|
||||
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, disabled: disabled, directory: directory, showUploadList: showUploadList
|
||||
? {
|
||||
showPreviewIcon: preview,
|
||||
showPreviewIcon: !disablePreview,
|
||||
showRemoveIcon: !disableDelete,
|
||||
showDownloadIcon: !disableDownload,
|
||||
}
|
||||
: false, beforeUpload: async (file) => {
|
||||
if (typeof beforeUpload === "function") {
|
||||
if (typeof beforeUpload === 'function') {
|
||||
const result = await beforeUpload(file);
|
||||
if (result) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}, multiple: multiple, maxCount: maxNumber, accept: accept, listType: listType, fileList: theme === "custom"
|
||||
}, multiple: multiple, maxCount: maxNumber, accept: accept, listType: listType, fileList: theme === 'custom'
|
||||
? []
|
||||
: newFiles?.map((ele) => extraFileToUploadFile(ele)), onChange: ({ file, fileList, event }) => {
|
||||
// id不存在就是file对象
|
||||
if (!file.id) {
|
||||
if (theme !== "custom") {
|
||||
if (theme !== 'custom') {
|
||||
onPickByWeb([file2Obj(file)]);
|
||||
}
|
||||
else {
|
||||
|
|
@ -176,53 +182,53 @@ export default function render(props) {
|
|||
}
|
||||
}, onRemove: onDeleteByWeb, onPreview: onPreview, onDownload: onDownload, itemRender: (originNode, currentFile, currentFileList) => {
|
||||
return (_jsx(DragableUploadListItem, { originNode: originNode, file: currentFile, fileList: currentFileList, moveRow: moveRow }));
|
||||
}, children: !disableInsert && !disableAdd ? getUploadButton() : null }) }), tips && _jsx("small", { className: Style["oak-upload__tips"], children: tips }), theme === "custom" && (_jsxs(_Fragment, { children: [_jsx(Table, { dataSource: newUploadFiles || [], rowKey: "id", columns: [
|
||||
}, children: !disableInsert && !disableAdd ? getUploadButton() : null }) }), tips && (_jsx("small", { className: Style['oak-upload__tips'], children: tips })), theme === 'custom' && (_jsxs(_Fragment, { children: [_jsx(Table, { dataSource: newUploadFiles || [], rowKey: "id", columns: [
|
||||
{
|
||||
align: "center",
|
||||
dataIndex: "tableIndex",
|
||||
title: "#",
|
||||
align: 'center',
|
||||
dataIndex: 'tableIndex',
|
||||
title: '#',
|
||||
render: (value, record, index) => index + 1,
|
||||
width: 50,
|
||||
},
|
||||
{
|
||||
dataIndex: "name",
|
||||
title: "文件名",
|
||||
dataIndex: 'name',
|
||||
title: '文件名',
|
||||
},
|
||||
{
|
||||
dataIndex: "size",
|
||||
title: "文件大小",
|
||||
dataIndex: 'size',
|
||||
title: '文件大小',
|
||||
render: (value, record, index) => {
|
||||
return eFFormatBytes(value);
|
||||
return formatBytes(value);
|
||||
},
|
||||
},
|
||||
{
|
||||
dataIndex: "status",
|
||||
title: "状态",
|
||||
dataIndex: 'status',
|
||||
title: '状态',
|
||||
render: (value, record, index) => {
|
||||
switch (value) {
|
||||
case "success":
|
||||
return _jsx(Tag, { color: "success", children: t("success") });
|
||||
case "uploading":
|
||||
return _jsx(Tag, { color: "processing", children: t("uploading") });
|
||||
case 'success':
|
||||
return (_jsx(Tag, { color: "success", children: t('success') }));
|
||||
case 'uploading':
|
||||
return (_jsx(Tag, { color: "processing", children: t('uploading') }));
|
||||
default:
|
||||
return _jsx(Tag, { color: "warning", children: t("waiting") });
|
||||
return (_jsx(Tag, { color: "warning", children: t('waiting') }));
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
dataIndex: "op",
|
||||
dataIndex: 'op',
|
||||
width: 300,
|
||||
title: "操作",
|
||||
align: "center",
|
||||
title: '操作',
|
||||
align: 'center',
|
||||
render: (value, record, index) => {
|
||||
// 只处理state的文件 这时候可以直接删除
|
||||
return (_jsx(_Fragment, { children: !record.id && (_jsx(Button, { type: "link", onClick: () => {
|
||||
customDelete(index);
|
||||
}, children: "\u5220\u9664" })) }));
|
||||
},
|
||||
fixed: "right",
|
||||
fixed: 'right',
|
||||
},
|
||||
] }), _jsx("div", { style: { display: "flex", justifyContent: "flex-end" }, children: _jsxs(Space, { children: [_jsx(Button, { danger: true, type: "default", onClick: () => setNewUploadFiles([]), children: "\u6E05\u7A7A" }), _jsx(Button, { type: "primary", onClick: () => {
|
||||
] }), _jsx("div", { style: { display: 'flex', justifyContent: 'flex-end' }, children: _jsxs(Space, { children: [_jsx(Button, { danger: true, type: "default", onClick: () => setNewUploadFiles([]), children: "\u6E05\u7A7A" }), _jsx(Button, { type: "primary", onClick: () => {
|
||||
onPickByWeb(newUploadFiles, (file, status) => {
|
||||
setNewUploadFilesByStatus(file, status);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ export interface EnhancedExtraFile extends ExtraFile {
|
|||
}
|
||||
type SourceType = 'album' | 'camera';
|
||||
export type Theme = 'file' | 'image' | 'image-flow' | 'custom';
|
||||
type FileType = 'all' | 'video' | 'image' | 'file';
|
||||
type ImgMode = 'scaleToFill' | 'aspectFit' | 'aspectFill' | 'widthFix' | "heightFix" | 'top' | 'bottom' | 'left' | 'right' | 'center' | 'top left' | 'top right' | 'bottom left' | 'bottom right';
|
||||
declare const _default: <ED2 extends EntityDict & BaseEntityDict, T2 extends keyof ED2>(props: ReactComponentProps<ED2, T2, true, {
|
||||
bucket: string;
|
||||
|
|
@ -20,15 +19,15 @@ declare const _default: <ED2 extends EntityDict & BaseEntityDict, T2 extends key
|
|||
autoUpload: boolean;
|
||||
maxNumber: number;
|
||||
extension: string[];
|
||||
fileType: FileType;
|
||||
selectCount: number;
|
||||
sourceType: SourceType[];
|
||||
mediaType: ('image' | 'video')[];
|
||||
mode: ImgMode;
|
||||
size: number;
|
||||
showUploadList: boolean;
|
||||
showUploadProgress: boolean;
|
||||
accept: string;
|
||||
preview: boolean;
|
||||
disablePreview: boolean;
|
||||
disableDelete: boolean;
|
||||
disableAdd: boolean;
|
||||
disableDownload: boolean;
|
||||
|
|
@ -40,7 +39,6 @@ declare const _default: <ED2 extends EntityDict & BaseEntityDict, T2 extends key
|
|||
entity: keyof ED2;
|
||||
entityId: string;
|
||||
theme: Theme;
|
||||
showUploadProgress: boolean;
|
||||
children?: React.ReactNode;
|
||||
}>) => React.ReactElement;
|
||||
export default _default;
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ export default OakComponent({
|
|||
itemSizePercentage: '',
|
||||
},
|
||||
wechatMp: {
|
||||
externalClasses: ['oak-class', 'oak-item-class'],
|
||||
externalClasses: ['oak-class', 'oak-item-class', 'oak-item-add-class'],
|
||||
},
|
||||
filters: [
|
||||
{
|
||||
|
|
@ -49,32 +49,25 @@ export default OakComponent({
|
|||
autoUpload: false,
|
||||
maxNumber: 20,
|
||||
extension: [],
|
||||
fileType: 'all',
|
||||
selectCount: 1,
|
||||
sourceType: ['album', 'camera'],
|
||||
mediaType: ['image'],
|
||||
// 图片显示模式
|
||||
mode: 'aspectFit',
|
||||
// 每行可显示的个数
|
||||
size: 3,
|
||||
showUploadList: true,
|
||||
showUploadProgress: false,
|
||||
accept: 'image/*',
|
||||
// 图片是否可预览
|
||||
preview: true,
|
||||
// 图片是否可删除
|
||||
disablePreview: false,
|
||||
disableDelete: false,
|
||||
// 上传按钮隐藏
|
||||
disableAdd: false,
|
||||
// 下按按钮隐藏
|
||||
disableDownload: false,
|
||||
type: 'file',
|
||||
type: 'image',
|
||||
origin: 'qiniu',
|
||||
tag1: '',
|
||||
tag2: '',
|
||||
entity: '',
|
||||
entityId: '',
|
||||
theme: 'image',
|
||||
showUploadProgress: false,
|
||||
},
|
||||
listeners: {
|
||||
maxNumber(prev, next) {
|
||||
|
|
@ -104,7 +97,9 @@ export default OakComponent({
|
|||
},
|
||||
features: ['extraFile2'],
|
||||
formData({ data, features }) {
|
||||
const files = data.map(ele => {
|
||||
const files = data
|
||||
?.sort((ele1, ele2) => ele1.sort - ele2.sort)
|
||||
.map((ele) => {
|
||||
const url = features.extraFile2.getUrl(ele);
|
||||
const thumbUrl = features.extraFile2.getUrl(ele, 'thumbnail');
|
||||
const fileState = features.extraFile2.getFileState(ele.id);
|
||||
|
|
@ -128,16 +123,17 @@ export default OakComponent({
|
|||
this.features.extraFile2.removeLocalFiles([file.id]);
|
||||
},
|
||||
addExtraFileInner(options, file) {
|
||||
const { type, origin, tag1, tag2, entity, entityId, bucket } = this.props;
|
||||
const { type, origin = 'qiniu', // 默认qiniu
|
||||
tag1, tag2, entity, entityId, bucket, } = this.props;
|
||||
const { name, fileType, size } = options;
|
||||
const extension = name.substring(name.lastIndexOf('.') + 1);
|
||||
const filename = name.substring(0, name.lastIndexOf('.'));
|
||||
const { files } = this.state;
|
||||
const sort = files.length * 10000;
|
||||
let bucket2 = bucket;
|
||||
if (!bucket2) {
|
||||
if (origin === 'qiniu' && !bucket2) {
|
||||
const context = this.features.cache.begin();
|
||||
const { config } = getConfig(context, 'Cos', 'qiniu');
|
||||
const { config } = getConfig(context, 'Cos', origin);
|
||||
this.features.cache.commit();
|
||||
const { defaultBucket } = config;
|
||||
bucket2 = defaultBucket;
|
||||
|
|
@ -169,6 +165,124 @@ export default OakComponent({
|
|||
fileType: type,
|
||||
size,
|
||||
}, file);
|
||||
}
|
||||
}
|
||||
},
|
||||
// 小程序端
|
||||
async chooseMediaByMp() {
|
||||
//图片和视频使用
|
||||
const { selectCount, mediaType, sourceType } = this.props;
|
||||
try {
|
||||
const { errMsg, tempFiles } = await wx.chooseMedia({
|
||||
count: selectCount,
|
||||
mediaType,
|
||||
sourceType,
|
||||
});
|
||||
if (errMsg !== 'chooseMedia:ok') {
|
||||
this.triggerEvent('onError', {
|
||||
level: 'warning',
|
||||
msg: errMsg,
|
||||
});
|
||||
}
|
||||
else {
|
||||
tempFiles.map((tempExtraFile) => {
|
||||
const { tempFilePath, thumbTempFilePath, fileType, size, } = tempExtraFile;
|
||||
const filePath = tempFilePath || thumbTempFilePath;
|
||||
const fileFullName = filePath.match(/[^/]+(?!.*\/)/g)[0];
|
||||
this.addExtraFileInner({
|
||||
name: fileFullName,
|
||||
fileType,
|
||||
size,
|
||||
}, filePath);
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
if (err.errMsg !== 'chooseMedia:fail cancel') {
|
||||
this.triggerEvent('onError', {
|
||||
level: 'error',
|
||||
msg: err.errMsg,
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
async chooseMessageFileByMp() {
|
||||
const { selectCount, extension } = this.props;
|
||||
try {
|
||||
const { errMsg, tempFiles } = await wx.chooseMessageFile({
|
||||
count: selectCount,
|
||||
type: 'all',
|
||||
extension,
|
||||
});
|
||||
if (errMsg !== 'chooseMessageFile:ok') {
|
||||
this.triggerEvent('onError', {
|
||||
level: 'warning',
|
||||
msg: errMsg,
|
||||
});
|
||||
}
|
||||
else {
|
||||
tempFiles.map((tempExtraFile) => {
|
||||
const { path, type, size, name } = tempExtraFile;
|
||||
this.addExtraFileInner({
|
||||
name,
|
||||
fileType: type,
|
||||
size,
|
||||
}, path);
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
if (err.errMsg !== 'chooseMessageFile:fail cancel') {
|
||||
this.triggerEvent('onError', {
|
||||
level: 'error',
|
||||
msg: err.errMsg,
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
async addFileByMp(evt) {
|
||||
const { type } = this.props;
|
||||
//小程序 根据type类型调用api
|
||||
if (['image', 'video'].includes(type)) {
|
||||
this.chooseMediaByMp();
|
||||
}
|
||||
else {
|
||||
this.chooseMessageFileByMp();
|
||||
}
|
||||
},
|
||||
onRemoveByMp(event) {
|
||||
const { value } = event.currentTarget.dataset;
|
||||
this.onRemove(value);
|
||||
},
|
||||
async onPreviewByMp(event) {
|
||||
const files = this.state.files;
|
||||
const { index } = event.currentTarget.dataset;
|
||||
const imageUrl = files[index].url;
|
||||
const urls = files?.filter((ele) => !!ele).map((ele) => ele.url);
|
||||
const detail = {
|
||||
all: files,
|
||||
index,
|
||||
urls,
|
||||
current: imageUrl,
|
||||
};
|
||||
// 预览图片
|
||||
if (!this.props.disablePreview) {
|
||||
const result = await wx.previewImage({
|
||||
urls: urls,
|
||||
current: imageUrl,
|
||||
});
|
||||
this.triggerEvent('onPreview', detail);
|
||||
}
|
||||
},
|
||||
//检查排序是否超过上限
|
||||
checkSort(sort) {
|
||||
const reg = /^\d+\.(?:9+)$/;
|
||||
if (reg.test(sort.toString())) {
|
||||
this.setMessage({
|
||||
type: 'warning',
|
||||
content: this.t('dragSort'),
|
||||
});
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -0,0 +1,162 @@
|
|||
@import "../../../config/styles/mp/index.less";
|
||||
@import "../../../config/styles/mp/mixins.less";
|
||||
|
||||
.file-list__container {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.file-list__item {
|
||||
position: relative;
|
||||
width: 220rpx;
|
||||
padding-bottom: 220rpx;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
// size 不同时,对应的图片间距设置
|
||||
// size 仅支持 1-10
|
||||
each(range(2, 10), {
|
||||
@valuePlusOne : @value+1;
|
||||
|
||||
.file-list__item--@{value}:nth-of-type(n+@{valuePlusOne}) {
|
||||
margin-top : 20rpx;
|
||||
}
|
||||
|
||||
.file-list__item--@{value}:not(:nth-of-type(@{value}n+1)) {
|
||||
margin-left : 20rpx;
|
||||
}
|
||||
}) // 当 size 为 null,每行会显示 3 张图片
|
||||
|
||||
.file-list__item--null:nth-of-type(n+4) {
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
|
||||
.file-list__item--null:not(:nth-of-type(3n+1)) {
|
||||
margin-left: 20rpx;
|
||||
}
|
||||
|
||||
.file-list__image {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border: 1rpx solid #eee;
|
||||
border-radius: 4rpx;
|
||||
}
|
||||
|
||||
.file-list__item--selected {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
z-index: 10;
|
||||
background-color: #000;
|
||||
filter: Alpha(Opacity=50);
|
||||
opacity: 0.5;
|
||||
position: absolute;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: space-around;
|
||||
}
|
||||
|
||||
.file-list__remove {
|
||||
position: absolute;
|
||||
right: 10rpx;
|
||||
top: 10rpx;
|
||||
height: 40rpx;
|
||||
width: 40rpx;
|
||||
border-radius: 50%;
|
||||
background: rgb(0 0 0 / 40%);
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.file-list__item--add {
|
||||
border: 1rpx solid #eee;
|
||||
border-radius: 4rpx;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
.file-list__item--image {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border: 1rpx solid #eee;
|
||||
border-radius: 4rpx;
|
||||
}
|
||||
|
||||
.file-list__image--add {
|
||||
visibility: hidden;
|
||||
position: absolute;
|
||||
width: 50%;
|
||||
height: 50%;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.file-list__item-slot-wrapper {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
top: 0;
|
||||
left: 0;
|
||||
}
|
||||
|
||||
.file-list__item-slot-wrapper:empty+.file-list__image--add {
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
|
||||
.file-list-flow__container {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
.file-list-flow__item {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
margin: 10rpx 10rpx 10rpx 0;
|
||||
}
|
||||
.file-list-flow__item--name {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
fleX: 1;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.file-list-flow__item--btns {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.file-list-flow__download {
|
||||
width: 48rpx;
|
||||
height: 48rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.file-list-flow__remove {
|
||||
width: 48rpx;
|
||||
height: 48rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
<block wx:if="{{ type === 'image' }}">
|
||||
<view class="file-list__container oak-class">
|
||||
<block wx:for="{{files}}" wx:key="index">
|
||||
<block wx:if="{{item}}">
|
||||
<view class="file-list__item file-list__item--{{size}} oak-item-class" style="{{itemSizePercentage?'width:'+itemSizePercentage+'padding-bottom:'+itemSizePercentage:'xxx'}}">
|
||||
<image data-index="{{index}}" bind:tap="onPreviewByMp" src="{{item.url}}" mode="{{mode}}" class="file-list__item--image"/>
|
||||
|
||||
<view wx:if="{{!disableDelete}}" mut-bind:tap="onRemoveByMp" class="file-list__remove" data-value="{{item}}">
|
||||
<l-icon name="close" color="#ffffff" size="18" />
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
</block>
|
||||
<view class="file-list__item file-list__item--add file-list__item--{{size}} oak-item-add-class" style="{{itemSizePercentage?'width:'+itemSizePercentage+'padding-bottom:'+itemSizePercentage:''}}" wx:if="{{!disableInsert && !disableAdd}}" bind:tap="addFileByMp">
|
||||
<view class="file-list__item-slot-wrapper">
|
||||
<slot />
|
||||
</view>
|
||||
<view class="file-list__image--add">
|
||||
<l-icon name="add" size="80" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
<block wx:else >
|
||||
<view class="file-list-flow__container oak-class">
|
||||
<view class="file-list-flow__item--add oak-item-add-class" wx:if="{{!disableInsert && !disableAdd}}">
|
||||
<l-button bind:lintap="addFileByMp" plain="{{true}}" type="default">{{ t('chooseFile') }}</l-button>
|
||||
</view>
|
||||
<block wx:for="{{files}}" wx:key="index">
|
||||
<block wx:if="{{item}}">
|
||||
<view class="file-list-flow__item oak-item-class">
|
||||
<view class="file-list-flow__item--name" mut-bind:tap="onOpenByMp" data-value="{{item}}">
|
||||
{{ item.filename }}
|
||||
</view>
|
||||
<view class="file-list-flow__item--btns">
|
||||
<!-- <view wx:if="{{!disableDownload}}" mut-bind:tap="onDownloadByMp" class="file-list-flow__download" data-value="{{item}}">
|
||||
<l-icon name="download" size="36" />
|
||||
</view> -->
|
||||
<view wx:if="{{!disableDelete}}" mut-bind:tap="onRemoveByMp" class="file-list-flow__remove" data-value="{{item}}">
|
||||
<l-icon name="delete" size="36" />
|
||||
</view>
|
||||
<view>
|
||||
</view>
|
||||
</block>
|
||||
</block>
|
||||
</view>
|
||||
</block>
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"choosePicture": "请选择图片",
|
||||
"chooseFile": "请选择文件"
|
||||
"chooseFile": "请选择文件",
|
||||
"dragSort": "当前拖拽排序值超过上限范围"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,8 +21,9 @@ export default function render(props: WebComponentProps<EntityDict, 'extraFile',
|
|||
disableInsert?: boolean;
|
||||
disableDownload?: boolean;
|
||||
disableDelete?: boolean;
|
||||
preview?: boolean;
|
||||
disablePreview?: boolean;
|
||||
}, {
|
||||
onRemove: (file: UploadFile) => void;
|
||||
addFileByWeb: (file: UploadFile) => void;
|
||||
checkSort: (sort: number) => boolean;
|
||||
}>): import("react/jsx-runtime").JSX.Element;
|
||||
|
|
|
|||
|
|
@ -48,14 +48,14 @@ const DragableUploadListItem = ({ 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, preview = true, } = props.data;
|
||||
const { t, onRemove, addFileByWeb } = props.methods;
|
||||
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 { t, updateItem, onRemove, addFileByWeb, checkSort } = props.methods;
|
||||
const listType = getListType(theme);
|
||||
const getUploadButton = () => {
|
||||
if (children) {
|
||||
return children;
|
||||
}
|
||||
if (listType === "picture-card") {
|
||||
if (listType === 'picture-card') {
|
||||
return (_jsxs("div", { children: [_jsx(PlusOutlined, {}), _jsx("div", { style: { marginTop: 8 }, children: t('choosePicture') })] }));
|
||||
}
|
||||
return _jsx(Button, { type: "default", children: t('chooseFile') });
|
||||
|
|
@ -114,16 +114,45 @@ export default function render(props) {
|
|||
});
|
||||
};
|
||||
const moveRow = useCallback((dragIndex, hoverIndex) => {
|
||||
console.log('dragIndex', dragIndex, 'hoverIndex', hoverIndex);
|
||||
const dragRow = files[dragIndex];
|
||||
let sort;
|
||||
if (hoverIndex === dragIndex) {
|
||||
return;
|
||||
}
|
||||
else if (hoverIndex > dragIndex) {
|
||||
if (hoverIndex === files.length - 1) {
|
||||
sort = files[hoverIndex].sort + 100;
|
||||
}
|
||||
else {
|
||||
sort =
|
||||
(files[hoverIndex].sort +
|
||||
files[hoverIndex + 1].sort) /
|
||||
2;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (hoverIndex === 0) {
|
||||
sort = files[hoverIndex].sort / 2;
|
||||
}
|
||||
else {
|
||||
sort =
|
||||
(files[hoverIndex].sort +
|
||||
files[hoverIndex - 1].sort) /
|
||||
2;
|
||||
}
|
||||
}
|
||||
if (checkSort(sort)) {
|
||||
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
|
||||
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: preview,
|
||||
showPreviewIcon: !disablePreview,
|
||||
showRemoveIcon: !disableDelete,
|
||||
showDownloadIcon: !disableDownload,
|
||||
}
|
||||
: false, beforeUpload: async (file) => {
|
||||
if (typeof beforeUpload === "function") {
|
||||
if (typeof beforeUpload === 'function') {
|
||||
const result = await beforeUpload(file);
|
||||
if (result) {
|
||||
return false;
|
||||
|
|
@ -136,5 +165,7 @@ export default function render(props) {
|
|||
}
|
||||
}, onRemove: onRemove, onPreview: onPreview, onDownload: onDownload, itemRender: (originNode, currentFile, currentFileList) => {
|
||||
return (_jsx(DragableUploadListItem, { 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 })] }));
|
||||
}, children: !disableInsert && files.length < maxNumber
|
||||
? getUploadButton()
|
||||
: null }) }), tips && (_jsx("small", { className: Style['oak-upload__tips'], children: tips }))] }));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|||
import { Tabs } from 'antd';
|
||||
import Styles from './web.pc.module.less';
|
||||
import ConfigUpsert from '../../config/upsert';
|
||||
import StyleUpsert from '../../config/style';
|
||||
import StyleUpsert from '../../config/style/platform';
|
||||
import PlatformDetail from '../detail';
|
||||
import PlatformSystem from '../system';
|
||||
export default function render(props) {
|
||||
|
|
@ -23,9 +23,7 @@ export default function render(props) {
|
|||
{
|
||||
label: _jsx("div", { className: Styles.tabLabel, children: t('style') }),
|
||||
key: 'style',
|
||||
children: (_jsx(StyleUpsert, { value: style, onChange: (s) => {
|
||||
update({ style: s });
|
||||
} })),
|
||||
children: (_jsx(StyleUpsert, { style: style, entity: 'platform', entityId: id, name: name })),
|
||||
},
|
||||
{
|
||||
label: _jsx("div", { className: Styles.tabLabel, children: t('system-list') }),
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|||
import { Tabs } from 'antd';
|
||||
import SystemDetail from '../detail';
|
||||
import ConfigUpsert from '../../config/upsert';
|
||||
import StyleUpsert from '../../config/style';
|
||||
import StyleUpsert from '../../config/style/platform';
|
||||
import DomainList from '../../domain/list';
|
||||
import ApplicationList from '../application';
|
||||
import Styles from './web.pc.module.less';
|
||||
|
|
@ -24,9 +24,7 @@ export default function Render(props) {
|
|||
{
|
||||
label: _jsx("div", { className: Styles.tabLabel, children: t('style') }),
|
||||
key: 'style',
|
||||
children: (_jsx(StyleUpsert, { value: style, onChange: (s) => {
|
||||
update({ style: s });
|
||||
} })),
|
||||
children: (_jsx(StyleUpsert, { style: style, entity: 'system', entityId: id, name: name })),
|
||||
},
|
||||
{
|
||||
label: _jsx("div", { className: Styles.tabLabel, children: t('application-list') }),
|
||||
|
|
|
|||
|
|
@ -73,7 +73,6 @@ export default function Render(props) {
|
|||
}
|
||||
};
|
||||
useEffect(() => {
|
||||
console.log(config);
|
||||
if (config && config.button && config.button[0] && onlyOne) {
|
||||
setMenuName(config.button[0].name);
|
||||
setOnlyOne(false);
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ export declare abstract class BackendRuntimeContext<ED extends EntityDict & Base
|
|||
* 异步等待初始化完成
|
||||
*/
|
||||
protected initialized(): Promise<void>;
|
||||
private initialize;
|
||||
protected initialize(data?: SerializedData): Promise<void>;
|
||||
getApplicationId(): ED["application"]["Schema"]["id"] | undefined;
|
||||
getSystemId(): ED["application"]["Schema"]["systemId"] | undefined;
|
||||
getApplication(): Partial<ED["application"]["Schema"]> | undefined;
|
||||
|
|
@ -34,7 +34,7 @@ export declare abstract class BackendRuntimeContext<ED extends EntityDict & Base
|
|||
getToken(allowUnloggedIn?: boolean): Partial<ED["token"]["Schema"]> | undefined;
|
||||
getCurrentUserId(allowUnloggedIn?: boolean): string;
|
||||
setTemporaryUserId(userId: string | undefined): void;
|
||||
toString(): string;
|
||||
protected getSerializedData(): SerializedData;
|
||||
isRoot(): boolean;
|
||||
isReallyRoot(): boolean;
|
||||
sendMessage(data: ED['message']['CreateSingle']['data']): Promise<import("oak-domain").OperationResult<ED>>;
|
||||
|
|
|
|||
|
|
@ -189,11 +189,14 @@ export class BackendRuntimeContext extends BRC {
|
|||
setTemporaryUserId(userId) {
|
||||
this.temporaryUserId = userId;
|
||||
}
|
||||
toString() {
|
||||
if (this.rootMode) {
|
||||
return JSON.stringify({ rootMode: true });
|
||||
}
|
||||
return JSON.stringify({ a: this.application?.id, t: this.token?.id });
|
||||
getSerializedData() {
|
||||
const data = super.getSerializedData();
|
||||
return {
|
||||
...data,
|
||||
a: this.application?.id,
|
||||
t: this.token?.id,
|
||||
rm: this.rootMode,
|
||||
};
|
||||
}
|
||||
isRoot() {
|
||||
if (this.rootMode) {
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ export type AspectDict<ED extends EntityDict & BaseEntityDict, Cxt extends Backe
|
|||
export interface SerializedData extends Fsd {
|
||||
a?: string;
|
||||
t?: string;
|
||||
rm?: boolean;
|
||||
}
|
||||
export declare abstract class FrontendRuntimeContext<ED extends EntityDict & BaseEntityDict, Cxt extends BackendRuntimeContext<ED>, AD extends AspectDict<ED, Cxt>> extends Frc<ED, Cxt, AD> implements RuntimeContext {
|
||||
private application;
|
||||
|
|
|
|||
|
|
@ -203,7 +203,8 @@ const i18ns = [
|
|||
position: "src/components/extraFile/upload",
|
||||
data: {
|
||||
"choosePicture": "请选择图片",
|
||||
"chooseFile": "请选择文件"
|
||||
"chooseFile": "请选择文件",
|
||||
"dragSort": "当前拖拽排序值超过上限范围"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -17,13 +17,6 @@ export declare class ExtraFile<ED extends EntityDict, Cxt extends BackendRuntime
|
|||
}>;
|
||||
upload(extraFile: EntityDict['extraFile']['CreateSingle']['data'], file: string | File): Promise<void>;
|
||||
getUrl(extraFile?: EntityDict['extraFile']['OpSchema'] | EntityDict['extraFile']['Schema'] | null, style?: string): string;
|
||||
/**
|
||||
* 使用该方法,要在使用完url时,通过URL.revokeObjectURL释放缓存
|
||||
*
|
||||
* @param url 需要桥接访问的图片链接
|
||||
* @returns 浏览器 img可访问的url
|
||||
*/
|
||||
getBridgeUrl(url: string): Promise<string>;
|
||||
getFileName(extraFile: EntityDict['extraFile']['OpSchema']): string;
|
||||
formatBytes(size: number): string;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,21 +113,6 @@ export class ExtraFile extends Feature {
|
|||
url = cos.composeFileUrl(extraFile, context, style);
|
||||
return url;
|
||||
}
|
||||
/**
|
||||
* 使用该方法,要在使用完url时,通过URL.revokeObjectURL释放缓存
|
||||
*
|
||||
* @param url 需要桥接访问的图片链接
|
||||
* @returns 浏览器 img可访问的url
|
||||
*/
|
||||
async getBridgeUrl(url) {
|
||||
const { result } = await this.cache.exec('crossBridge', {
|
||||
url,
|
||||
});
|
||||
const blob = new Blob([result], {
|
||||
type: 'image/png',
|
||||
});
|
||||
return URL.createObjectURL(blob);
|
||||
}
|
||||
getFileName(extraFile) {
|
||||
const name = extraFile.filename +
|
||||
(extraFile.extension ? `.${extraFile.extension}` : '');
|
||||
|
|
|
|||
|
|
@ -22,13 +22,6 @@ export declare class ExtraFile2<ED extends EntityDict, Cxt extends BackendRuntim
|
|||
state: FileState;
|
||||
percentage?: number;
|
||||
} | undefined;
|
||||
/**
|
||||
* 使用该方法,要在使用完url时,通过URL.revokeObjectURL释放缓存
|
||||
*
|
||||
* @param url 需要桥接访问的图片链接
|
||||
* @returns 浏览器 img可访问的url
|
||||
*/
|
||||
getBridgeUrl(url: string): Promise<string>;
|
||||
getFileName(extraFile: EntityDict['extraFile']['OpSchema']): string;
|
||||
formatBytes(size: number): string;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -115,21 +115,6 @@ export class ExtraFile2 extends Feature {
|
|||
return this.files[id];
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 使用该方法,要在使用完url时,通过URL.revokeObjectURL释放缓存
|
||||
*
|
||||
* @param url 需要桥接访问的图片链接
|
||||
* @returns 浏览器 img可访问的url
|
||||
*/
|
||||
async getBridgeUrl(url) {
|
||||
const { result } = await this.cache.exec('crossBridge', {
|
||||
url,
|
||||
});
|
||||
const blob = new Blob([result], {
|
||||
type: 'image/png',
|
||||
});
|
||||
return URL.createObjectURL(blob);
|
||||
}
|
||||
getFileName(extraFile) {
|
||||
const name = extraFile.filename +
|
||||
(extraFile.extension ? `.${extraFile.extension}` : '');
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import { ExtraFile } from './extraFile';
|
|||
import { ExtraFile2 } from './extraFile2';
|
||||
import { Application } from './application';
|
||||
import { Config } from './config';
|
||||
import { Style2 } from './style2';
|
||||
import { WeiXinJsSdk } from './weiXinJsSdk';
|
||||
import { WechatMenu } from './wechatMenu';
|
||||
import { WechatPublicTag } from './wechatPublicTag';
|
||||
|
|
@ -21,6 +22,7 @@ export type GeneralFeatures<ED extends EntityDict, Cxt extends BackendRuntimeCon
|
|||
extraFile2: ExtraFile2<ED, Cxt, FrontCxt, AD>;
|
||||
application: Application<ED, Cxt, FrontCxt, AD>;
|
||||
config: Config<ED, Cxt, FrontCxt, AD>;
|
||||
style2: Style2<ED, Cxt, FrontCxt, AD>;
|
||||
weiXinJsSdk: WeiXinJsSdk<ED, Cxt, FrontCxt, AD>;
|
||||
theme: Theme<ED, Cxt, FrontCxt, AD>;
|
||||
wechatMenu: WechatMenu<ED, Cxt, FrontCxt, AD>;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import { ExtraFile } from './extraFile';
|
|||
import { ExtraFile2 } from './extraFile2';
|
||||
import { Application } from './application';
|
||||
import { Config } from './config';
|
||||
import { Style2 } from './style2';
|
||||
import { WeiXinJsSdk } from './weiXinJsSdk';
|
||||
import { WechatMenu } from './wechatMenu';
|
||||
import { WechatPublicTag } from './wechatPublicTag';
|
||||
|
|
@ -16,6 +17,7 @@ export function initialize(basicFeatures, type, domain) {
|
|||
const extraFile = new ExtraFile(basicFeatures.cache, application, basicFeatures.locales);
|
||||
const extraFile2 = new ExtraFile2(basicFeatures.cache, application, basicFeatures.locales);
|
||||
const config = new Config(basicFeatures.cache);
|
||||
const style2 = new Style2(basicFeatures.cache);
|
||||
const weiXinJsSdk = new WeiXinJsSdk(basicFeatures.cache, basicFeatures.localStorage, basicFeatures.environment);
|
||||
const theme = new Theme(basicFeatures.cache, basicFeatures.localStorage);
|
||||
return {
|
||||
|
|
@ -24,6 +26,7 @@ export function initialize(basicFeatures, type, domain) {
|
|||
extraFile2,
|
||||
application,
|
||||
config,
|
||||
style2,
|
||||
weiXinJsSdk,
|
||||
theme,
|
||||
wechatMenu,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
import { Feature } from 'oak-frontend-base';
|
||||
import AspectDict from '../aspects/AspectDict';
|
||||
import { EntityDict } from '../oak-app-domain';
|
||||
import { Cache } from 'oak-frontend-base/es/features/cache';
|
||||
import { Style as StyleDef } from '../types/Style';
|
||||
import { BackendRuntimeContext } from '../context/BackendRuntimeContext';
|
||||
import { CommonAspectDict } from 'oak-common-aspect';
|
||||
import { FrontendRuntimeContext } from '../context/FrontendRuntimeContext';
|
||||
export declare class Style<ED extends EntityDict, Cxt extends BackendRuntimeContext<ED>, FrontCxt extends FrontendRuntimeContext<ED, Cxt, AD>, AD extends AspectDict<ED, Cxt> & CommonAspectDict<ED, Cxt>> extends Feature {
|
||||
private cache;
|
||||
constructor(cache: Cache<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>);
|
||||
updateStyle(entity: 'platform' | 'system' | 'application', entityId: string, style: StyleDef): Promise<void>;
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
import { Feature } from 'oak-frontend-base';
|
||||
export class Style extends Feature {
|
||||
cache;
|
||||
constructor(cache) {
|
||||
super();
|
||||
this.cache = cache;
|
||||
}
|
||||
async updateStyle(entity, entityId, style) {
|
||||
await this.cache.exec('updateStyle', {
|
||||
entity,
|
||||
entityId,
|
||||
style,
|
||||
});
|
||||
this.publish();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
import { Feature } from 'oak-frontend-base';
|
||||
import AspectDict from '../aspects/AspectDict';
|
||||
import { EntityDict } from '../oak-app-domain';
|
||||
import { Cache } from 'oak-frontend-base/es/features/cache';
|
||||
import { Style as StyleDef } from '../types/Style';
|
||||
import { BackendRuntimeContext } from '../context/BackendRuntimeContext';
|
||||
import { CommonAspectDict } from 'oak-common-aspect';
|
||||
import { FrontendRuntimeContext } from '../context/FrontendRuntimeContext';
|
||||
export declare class Style2<ED extends EntityDict, Cxt extends BackendRuntimeContext<ED>, FrontCxt extends FrontendRuntimeContext<ED, Cxt, AD>, AD extends AspectDict<ED, Cxt> & CommonAspectDict<ED, Cxt>> extends Feature {
|
||||
private cache;
|
||||
constructor(cache: Cache<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>);
|
||||
updateStyle(entity: 'platform' | 'system' | 'application', entityId: string, style: StyleDef): Promise<void>;
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
import { Feature } from 'oak-frontend-base';
|
||||
export class Style2 extends Feature {
|
||||
cache;
|
||||
constructor(cache) {
|
||||
super();
|
||||
this.cache = cache;
|
||||
}
|
||||
async updateStyle(entity, entityId, style) {
|
||||
await this.cache.exec('updateStyle', {
|
||||
entity,
|
||||
entityId,
|
||||
style,
|
||||
});
|
||||
this.publish();
|
||||
}
|
||||
}
|
||||
|
|
@ -29,41 +29,15 @@ const triggers = [
|
|||
},
|
||||
{
|
||||
name: '删除extraFile时远端也进行删除',
|
||||
when: 'before',
|
||||
when: 'commit',
|
||||
strict: 'makeSure',
|
||||
entity: 'extraFile',
|
||||
action: 'remove',
|
||||
fn: async ({ operation }, context) => {
|
||||
const { filter } = operation;
|
||||
const extraFileList = await context.select('extraFile', {
|
||||
data: {
|
||||
id: 1,
|
||||
origin: 1,
|
||||
type: 1,
|
||||
bucket: 1,
|
||||
objectId: 1,
|
||||
tag1: 1,
|
||||
tag2: 1,
|
||||
filename: 1,
|
||||
md5: 1,
|
||||
entity: 1,
|
||||
entityId: 1,
|
||||
extra1: 1,
|
||||
extension: 1,
|
||||
size: 1,
|
||||
sort: 1,
|
||||
fileType: 1,
|
||||
isBridge: 1,
|
||||
uploadState: 1,
|
||||
uploadMeta: 1,
|
||||
},
|
||||
filter,
|
||||
}, {
|
||||
dontCollect: true,
|
||||
});
|
||||
for (const extraFile of extraFileList) {
|
||||
fn: async ({ rows }, context) => {
|
||||
for (const extraFile of rows) {
|
||||
const { origin } = extraFile;
|
||||
const uploader = getCos(origin);
|
||||
await uploader.checkWhetherSuccess(extraFile, context);
|
||||
await uploader.removeFile(extraFile, context);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -240,17 +240,11 @@ const triggers = [
|
|||
action: 'create',
|
||||
when: 'commit',
|
||||
strict: 'takeEasy',
|
||||
fn: async ({ operation }, context) => {
|
||||
const { data } = operation;
|
||||
fn: async ({ rows }, context) => {
|
||||
const closeRootMode = context.openRootMode();
|
||||
try {
|
||||
if (data instanceof Array) {
|
||||
for (const d of data) {
|
||||
await sendNotification(d, context);
|
||||
}
|
||||
}
|
||||
else {
|
||||
await sendNotification(data, context);
|
||||
for (const row of rows) {
|
||||
await sendNotification(row, context);
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import { WebEnv, WechatMpEnv } from 'oak-domain/lib/types/Environment';
|
|||
import { AppType } from '../oak-app-domain/Application/Schema';
|
||||
import { EntityDict } from '../oak-app-domain';
|
||||
import { Config } from '../types/Config';
|
||||
import { Style } from '../types/Style';
|
||||
import { MenuType } from '../types/WeChat';
|
||||
import { BackendRuntimeContext } from '../context/BackendRuntimeContext';
|
||||
import { WechatPublicEventData, WechatMpEventData } from 'oak-external-sdk';
|
||||
|
|
@ -65,6 +66,11 @@ export type GeneralAspectDict<ED extends EntityDict, Cxt extends BackendRuntimeC
|
|||
entityId: string;
|
||||
config: Config;
|
||||
}, context: Cxt) => Promise<void>;
|
||||
updateStyle: (params: {
|
||||
entity: 'platform' | 'system' | 'application';
|
||||
entityId: string;
|
||||
style: Style;
|
||||
}, context: Cxt) => Promise<void>;
|
||||
updateApplicationConfig: (params: {
|
||||
entity: 'application';
|
||||
entityId: string;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import { loginByMobile, loginWechat, loginWechatMp, syncUserInfoWechatMp, sendCa
|
|||
import { getInfoByUrl } from './extraFile';
|
||||
import { getApplication, signatureJsSDK, uploadWechatMedia } from './application';
|
||||
import { updateConfig, updateApplicationConfig } from './config';
|
||||
import { updateStyle } from './style2';
|
||||
import { mergeUser, getChangePasswordChannels, updateUserPassword } from './user';
|
||||
import { createWechatLogin } from './wechatLogin';
|
||||
import { unbindingWechat } from './wechatUser';
|
||||
|
|
@ -22,6 +23,7 @@ declare const aspectDict: {
|
|||
sendCaptcha: typeof sendCaptcha;
|
||||
getApplication: typeof getApplication;
|
||||
updateConfig: typeof updateConfig;
|
||||
updateStyle: typeof updateStyle;
|
||||
updateApplicationConfig: typeof updateApplicationConfig;
|
||||
getWechatMpUserPhoneNumber: typeof getWechatMpUserPhoneNumber;
|
||||
logout: typeof logout;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ const token_1 = require("./token");
|
|||
const extraFile_1 = require("./extraFile");
|
||||
const application_1 = require("./application");
|
||||
const config_1 = require("./config");
|
||||
const style2_1 = require("./style2");
|
||||
const user_1 = require("./user");
|
||||
const wechatLogin_1 = require("./wechatLogin");
|
||||
const wechatUser_1 = require("./wechatUser");
|
||||
|
|
@ -24,6 +25,7 @@ const aspectDict = {
|
|||
sendCaptcha: token_1.sendCaptcha,
|
||||
getApplication: application_1.getApplication,
|
||||
updateConfig: config_1.updateConfig,
|
||||
updateStyle: style2_1.updateStyle,
|
||||
updateApplicationConfig: config_1.updateApplicationConfig,
|
||||
getWechatMpUserPhoneNumber: token_1.getWechatMpUserPhoneNumber,
|
||||
logout: token_1.logout,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
import { BackendRuntimeContext } from '../context/BackendRuntimeContext';
|
||||
import { EntityDict } from '../oak-app-domain';
|
||||
import { Style } from '../types/Style';
|
||||
export declare function updateStyle<ED extends EntityDict, Cxt extends BackendRuntimeContext<ED>>(params: {
|
||||
entity: 'platform' | 'system';
|
||||
entityId: string;
|
||||
style: Style;
|
||||
}, context: Cxt): Promise<void>;
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.updateStyle = void 0;
|
||||
const uuid_1 = require("oak-domain/lib/utils/uuid");
|
||||
async function updateStyle(params, context) {
|
||||
const { entity, entityId, style } = params;
|
||||
await context.operate(entity, {
|
||||
id: (0, uuid_1.generateNewId)(),
|
||||
action: 'update',
|
||||
data: {
|
||||
style,
|
||||
},
|
||||
filter: {
|
||||
id: entityId,
|
||||
}
|
||||
}, {});
|
||||
}
|
||||
exports.updateStyle = updateStyle;
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
import { BackendRuntimeContext } from '../context/BackendRuntimeContext';
|
||||
import { EntityDict } from '../oak-app-domain';
|
||||
import { Style } from '../types/Style';
|
||||
export declare function updateStyle<ED extends EntityDict, Cxt extends BackendRuntimeContext<ED>>(params: {
|
||||
entity: 'platform' | 'system';
|
||||
entityId: string;
|
||||
style: Style;
|
||||
}, context: Cxt): Promise<void>;
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.updateStyle = void 0;
|
||||
const uuid_1 = require("oak-domain/lib/utils/uuid");
|
||||
async function updateStyle(params, context) {
|
||||
const { entity, entityId, style } = params;
|
||||
await context.operate(entity, {
|
||||
id: (0, uuid_1.generateNewId)(),
|
||||
action: 'update',
|
||||
data: {
|
||||
style,
|
||||
},
|
||||
filter: {
|
||||
id: entityId,
|
||||
}
|
||||
}, {});
|
||||
}
|
||||
exports.updateStyle = updateStyle;
|
||||
|
|
@ -5,7 +5,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|||
const antd_1 = require("antd");
|
||||
const detail_1 = tslib_1.__importDefault(require("../detail"));
|
||||
const application_1 = tslib_1.__importDefault(require("../../config/application"));
|
||||
const style_1 = tslib_1.__importDefault(require("../../config/style"));
|
||||
const platform_1 = tslib_1.__importDefault(require("../../config/style/platform"));
|
||||
const web_pc_module_less_1 = tslib_1.__importDefault(require("./web.pc.module.less"));
|
||||
function Render(props) {
|
||||
const { id, config, oakFullpath, name, style } = props.data;
|
||||
|
|
@ -25,9 +25,7 @@ function Render(props) {
|
|||
{
|
||||
label: (0, jsx_runtime_1.jsx)("div", { className: web_pc_module_less_1.default.tabLabel, children: t('style') }),
|
||||
key: 'style',
|
||||
children: ((0, jsx_runtime_1.jsx)(style_1.default, { value: style, onChange: (s) => {
|
||||
update({ style: s });
|
||||
} })),
|
||||
children: ((0, jsx_runtime_1.jsx)(platform_1.default, { style: style, entity: 'platform', entityId: id, name: name })),
|
||||
},
|
||||
] }) }));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
/// <reference types="react" />
|
||||
import { Style } from '../../../../types/Style';
|
||||
declare const _default: (props: import("oak-frontend-base").ReactComponentProps<import("../../../../oak-app-domain").EntityDict, keyof import("../../../../oak-app-domain").EntityDict, false, {
|
||||
style: Style;
|
||||
entity: "application" | "system" | "platform";
|
||||
entityId: string;
|
||||
name: string;
|
||||
}>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
||||
export default _default;
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const lodash_1 = require("oak-domain/lib/utils/lodash");
|
||||
exports.default = OakComponent({
|
||||
isList: false,
|
||||
properties: {
|
||||
style: {},
|
||||
entity: '',
|
||||
entityId: '',
|
||||
name: '',
|
||||
},
|
||||
data: {
|
||||
initialStyle: {},
|
||||
dirty: false,
|
||||
currentStyle: {},
|
||||
},
|
||||
// listeners: {
|
||||
// config(prev, next) {
|
||||
// if (prev.config !== next.config) {
|
||||
// const config2 = next.config || {};
|
||||
// this.setState({
|
||||
// initialConfig: config2,
|
||||
// dirty: false,
|
||||
// currentConfig: cloneDeep(config2),
|
||||
// });
|
||||
// }
|
||||
// },
|
||||
// },
|
||||
lifetimes: {
|
||||
ready() {
|
||||
const { style } = this.props;
|
||||
this.setState({
|
||||
initialStyle: style,
|
||||
dirty: false,
|
||||
currentStyle: (0, lodash_1.cloneDeep)(style),
|
||||
});
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
setValue(newStyle) {
|
||||
const newStyle2 = (0, lodash_1.cloneDeep)(newStyle || {});
|
||||
this.setState({
|
||||
currentStyle: newStyle2,
|
||||
dirty: true,
|
||||
});
|
||||
},
|
||||
// cleanKey(path: string, key: string) {
|
||||
// const { currentConfig } = this.state;
|
||||
// const obj = get(currentConfig, path);
|
||||
// const obj2 = omit(obj, [key]);
|
||||
// set(currentConfig, path, obj2);
|
||||
// const newConfig = cloneDeep(currentConfig);
|
||||
// this.setState({
|
||||
// currentConfig: newConfig,
|
||||
// dirty: true,
|
||||
// });
|
||||
// },
|
||||
// removeItem(path: string, index: number) {
|
||||
// const { currentConfig } = this.state;
|
||||
// const array = get(currentConfig, path);
|
||||
// (array as any[]).splice(index, 1);
|
||||
// const newConfig = cloneDeep(currentConfig || {});
|
||||
// this.setState({
|
||||
// currentConfig: newConfig,
|
||||
// dirty: true,
|
||||
// });
|
||||
// },
|
||||
resetStyle() {
|
||||
const { initialStyle } = this.state;
|
||||
this.setState({
|
||||
dirty: false,
|
||||
currentStyle: (0, lodash_1.cloneDeep)(initialStyle),
|
||||
});
|
||||
},
|
||||
async updateStyle() {
|
||||
const { currentStyle } = this.state;
|
||||
const { entity, entityId } = this.props;
|
||||
await this.features.style2.updateStyle(entity, entityId, currentStyle);
|
||||
this.setMessage({
|
||||
content: '操作成功',
|
||||
type: 'success',
|
||||
});
|
||||
this.setState({
|
||||
dirty: false,
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
.container {
|
||||
background: var(--oak-bg-color-container);
|
||||
// box-shadow: 0 2px 3px #0000001a;
|
||||
// border-radius: 3px;
|
||||
padding: 30px 32px;
|
||||
}
|
||||
|
||||
.padding {
|
||||
background-color: var(--oak-bg-color-page);
|
||||
width: 100%;
|
||||
height: 77px;
|
||||
}
|
||||
|
||||
.ctrl {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 10px;
|
||||
border: solid 0.4px;
|
||||
border-radius: 3px;
|
||||
border-color: var(--oak-border-color);
|
||||
position: absolute;
|
||||
z-index: 10;
|
||||
background-color: var(--oak-bg-color-container);
|
||||
width: calc(100vw - 138px);
|
||||
top: 85px;
|
||||
height: 55px;
|
||||
|
||||
text {
|
||||
color: var(--oak-text-color-secondary);
|
||||
|
||||
.weight {
|
||||
font-weight: bold;
|
||||
color: var(--oak-text-color-primary);
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.contains {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
import { Style as StyleDef } from '../../../../types/Style';
|
||||
import { EntityDict } from '../../../../oak-app-domain';
|
||||
import { WebComponentProps } from 'oak-frontend-base';
|
||||
export default function Render(props: WebComponentProps<EntityDict, 'user', false, {
|
||||
entity: string;
|
||||
name: string;
|
||||
currentStyle: StyleDef;
|
||||
dirty: boolean;
|
||||
}, {
|
||||
resetStyle: () => void;
|
||||
updateStyle: () => void;
|
||||
setValue: (style: StyleDef) => void;
|
||||
}>): import("react/jsx-runtime").JSX.Element;
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const tslib_1 = require("tslib");
|
||||
const jsx_runtime_1 = require("react/jsx-runtime");
|
||||
const antd_1 = require("antd");
|
||||
const web_module_less_1 = tslib_1.__importDefault(require("./web.module.less"));
|
||||
const style_1 = tslib_1.__importDefault(require("../../style"));
|
||||
function Render(props) {
|
||||
const { entity, currentStyle, dirty, name } = props.data;
|
||||
const { resetStyle, updateStyle, setValue, t } = props.methods;
|
||||
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(antd_1.Affix, { offsetTop: 64, children: (0, jsx_runtime_1.jsx)(antd_1.Alert, { message: (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsxs)("text", { children: ["\u60A8\u6B63\u5728\u66F4\u65B0", (0, jsx_runtime_1.jsx)(antd_1.Typography.Text, { keyboard: true, className: web_module_less_1.default.weight, children: entity }), "\u5BF9\u8C61", (0, jsx_runtime_1.jsx)(antd_1.Typography.Text, { keyboard: true, className: web_module_less_1.default.weight, children: name }), "\u7684\u6837\u5F0F\uFF0C\u8BF7\u8C28\u614E\u64CD\u4F5C"] }) }), type: "info", showIcon: true, action: (0, jsx_runtime_1.jsxs)(antd_1.Space, { children: [(0, jsx_runtime_1.jsx)(antd_1.Button, { disabled: !dirty, type: "primary", danger: true, onClick: () => resetStyle(), style: {
|
||||
marginRight: 10,
|
||||
}, children: t('common::reset') }), (0, jsx_runtime_1.jsx)(antd_1.Button, { disabled: !dirty, type: "primary", onClick: () => updateStyle(), children: t('common::action.confirm') })] }) }) }), (0, jsx_runtime_1.jsx)("div", { className: web_module_less_1.default.contains, children: (0, jsx_runtime_1.jsx)(style_1.default, { value: currentStyle, onChange: (s) => {
|
||||
setValue(s);
|
||||
} }) })] }));
|
||||
}
|
||||
exports.default = Render;
|
||||
|
|
@ -115,6 +115,6 @@ function AmapAccount(props) {
|
|||
function Account(props) {
|
||||
const { account, setValue, removeItem } = props;
|
||||
const { tencent, qiniu, ali, amap } = account;
|
||||
return ((0, jsx_runtime_1.jsxs)(antd_1.Space, { direction: "vertical", size: "middle", style: { display: 'flex' }, children: [(0, jsx_runtime_1.jsx)(antd_1.Row, { children: (0, jsx_runtime_1.jsx)(antd_1.Card, { className: web_module_less_1.default.tips, children: "\u6BCF\u79CD\u4E91\u5382\u5546\u5747\u53EF\u914D\u7F6E\u591A\u4E2A\u5E10\u53F7\uFF0C\u76F8\u5E94\u7684\u670D\u52A1\u6240\u4F7F\u7528\u7684\u5E10\u53F7\u8BF7\u51C6\u786E\u5BF9\u5E94" }) }), (0, jsx_runtime_1.jsx)(TencentAccount, { accounts: tencent || [], setValue: (path, value) => setValue(`tencent.${path}`, value), removeItem: (path, index) => removeItem(`tencent`, index), addItem: (path, index) => setValue(`amap.${index}`, {}) }), (0, jsx_runtime_1.jsx)(QiniuAccount, { accounts: qiniu || [], setValue: (path, value) => setValue(`qiniu.${path}`, value), removeItem: (path, index) => removeItem(`qiniu`, index), addItem: (path, index) => setValue(`amap.${index}`, {}) }), (0, jsx_runtime_1.jsx)(AliAccount, { accounts: ali || [], setValue: (path, value) => setValue(`ali.${path}`, value), removeItem: (path, index) => removeItem(`ali`, index), addItem: (path, index) => setValue(`amap.${index}`, {}) }), (0, jsx_runtime_1.jsx)(AmapAccount, { accounts: amap || [], setValue: (path, value) => setValue(`amap.${path}`, value), removeItem: (path, index) => removeItem(`amap`, index), addItem: (path, index) => setValue(`amap.${index}`, {}) })] }));
|
||||
return ((0, jsx_runtime_1.jsxs)(antd_1.Space, { direction: "vertical", size: "middle", style: { display: 'flex' }, children: [(0, jsx_runtime_1.jsx)(antd_1.Row, { children: (0, jsx_runtime_1.jsx)(antd_1.Card, { className: web_module_less_1.default.tips, children: "\u6BCF\u79CD\u4E91\u5382\u5546\u5747\u53EF\u914D\u7F6E\u591A\u4E2A\u5E10\u53F7\uFF0C\u76F8\u5E94\u7684\u670D\u52A1\u6240\u4F7F\u7528\u7684\u5E10\u53F7\u8BF7\u51C6\u786E\u5BF9\u5E94" }) }), (0, jsx_runtime_1.jsx)(TencentAccount, { accounts: tencent || [], setValue: (path, value) => setValue(`tencent.${path}`, value), removeItem: (path, index) => removeItem(`tencent`, index), addItem: (path, index) => setValue(`tencent.${index}`, {}) }), (0, jsx_runtime_1.jsx)(QiniuAccount, { accounts: qiniu || [], setValue: (path, value) => setValue(`qiniu.${path}`, value), removeItem: (path, index) => removeItem(`qiniu`, index), addItem: (path, index) => setValue(`qiniu.${index}`, {}) }), (0, jsx_runtime_1.jsx)(AliAccount, { accounts: ali || [], setValue: (path, value) => setValue(`ali.${path}`, value), removeItem: (path, index) => removeItem(`ali`, index), addItem: (path, index) => setValue(`ali.${index}`, {}) }), (0, jsx_runtime_1.jsx)(AmapAccount, { accounts: amap || [], setValue: (path, value) => setValue(`amap.${path}`, value), removeItem: (path, index) => removeItem(`amap`, index), addItem: (path, index) => setValue(`amap.${index}`, {}) })] }));
|
||||
}
|
||||
exports.default = Account;
|
||||
|
|
|
|||
|
|
@ -10,11 +10,11 @@ function QiniuCos(props) {
|
|||
{
|
||||
key: '0',
|
||||
label: '配置项',
|
||||
children: ((0, jsx_runtime_1.jsxs)(antd_1.Form, { colon: true, labelAlign: "left", layout: "vertical", style: { marginTop: 10 }, children: [(0, jsx_runtime_1.jsx)(antd_1.Form.Item, { label: "accessKey", children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(antd_1.Input, { placeholder: "\u8BF7\u8F93\u5165accessKey", type: "text", value: cos?.accessKey, onChange: (e) => setValue(`accessKey`, e.target.value) }) }) }), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, { label: "uploadHost", children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(antd_1.Input, { placeholder: "\u8BF7\u8F93\u5165uploadHost", type: "text", value: cos?.uploadHost, onChange: (e) => setValue(`uploadHost`, e.target.value) }) }) }), (0, jsx_runtime_1.jsx)(antd_1.Tabs, { tabPosition: 'top', size: 'middle', type: "editable-card",
|
||||
children: ((0, jsx_runtime_1.jsxs)(antd_1.Form, { colon: true, labelAlign: "left", layout: "vertical", style: { marginTop: 10 }, children: [(0, jsx_runtime_1.jsx)(antd_1.Form.Item, { label: "accessKey", children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(antd_1.Input, { placeholder: "\u8BF7\u8F93\u5165accessKey", type: "text", value: cos?.accessKey, onChange: (e) => setValue(`accessKey`, e.target.value) }) }) }), (0, jsx_runtime_1.jsx)(antd_1.Form.Item, { label: "uploadHost", children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(antd_1.Input, { placeholder: "\u8BF7\u8F93\u5165uploadHost", type: "text", value: cos?.uploadHost, onChange: (e) => setValue(`uploadHost`, e.target.value) }) }) }), (0, jsx_runtime_1.jsx)(antd_1.Divider, { orientation: "left", className: web_module_less_1.default.title, children: "bucket\u914D\u7F6E" }), (0, jsx_runtime_1.jsx)(antd_1.Tabs, { tabPosition: 'top', size: 'middle', type: "editable-card",
|
||||
// hideAdd={!(sms.length > 0)}
|
||||
onEdit: (targetKey, action) => {
|
||||
if (action === 'add') {
|
||||
setValue(`buckets.${cos.buckets.length}`, {});
|
||||
setValue(`buckets.${cos?.buckets?.length || 0}`, {});
|
||||
}
|
||||
else {
|
||||
removeItem('buckets', parseInt(targetKey, 10));
|
||||
|
|
|
|||
|
|
@ -125,7 +125,6 @@ exports.default = OakComponent({
|
|||
this.addItem(Object.assign({}, updateData, {
|
||||
extra1: null,
|
||||
}), undefined, async () => {
|
||||
console.log(updateData);
|
||||
await this.features.extraFile.upload(updateData, extra1);
|
||||
});
|
||||
if (avatar) {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,6 @@ declare const _default: (props: import("oak-frontend-base").ReactComponentProps<
|
|||
type: string;
|
||||
executeText: string;
|
||||
buttonProps: {};
|
||||
afterCommit: () => undefined;
|
||||
afterCommit: () => void;
|
||||
}>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
||||
export default _default;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ exports.default = OakComponent({
|
|||
type: 'primary',
|
||||
executeText: '',
|
||||
buttonProps: {},
|
||||
afterCommit: () => undefined,
|
||||
afterCommit: () => { },
|
||||
},
|
||||
methods: {
|
||||
getEfIds() {
|
||||
|
|
|
|||
|
|
@ -165,7 +165,6 @@ exports.default = OakComponent({
|
|||
type: 'image',
|
||||
tag1,
|
||||
tag2,
|
||||
objectId: (0, uuid_1.generateNewId)(),
|
||||
bucket: '',
|
||||
id: (0, uuid_1.generateNewId)(),
|
||||
};
|
||||
|
|
|
|||
|
|
@ -3,14 +3,12 @@ import { EntityDict as BaseEntityDict } from 'oak-domain/lib/types/Entity';
|
|||
import { ReactComponentProps } from 'oak-frontend-base/lib/types/Page';
|
||||
type SourceType = 'album' | 'camera';
|
||||
type Theme = 'file' | 'image' | 'image-flow' | 'custom';
|
||||
type FileType = 'all' | 'video' | 'image' | 'file';
|
||||
type ImgMode = 'scaleToFill' | 'aspectFit' | 'aspectFill' | 'widthFix' | "heightFix" | 'top' | 'bottom' | 'left' | 'right' | 'center' | 'top left' | 'top right' | 'bottom left' | 'bottom right';
|
||||
declare const _default: <ED2 extends EntityDict & BaseEntityDict, T2 extends keyof ED2>(props: ReactComponentProps<ED2, T2, true, {
|
||||
removeLater: boolean;
|
||||
autoUpload: boolean;
|
||||
maxNumber: number;
|
||||
extension: string[];
|
||||
fileType: FileType;
|
||||
selectCount: number;
|
||||
sourceType: SourceType[];
|
||||
mediaType: ('image' | 'video')[];
|
||||
|
|
@ -18,7 +16,7 @@ declare const _default: <ED2 extends EntityDict & BaseEntityDict, T2 extends key
|
|||
size: number;
|
||||
showUploadList: boolean;
|
||||
accept: string;
|
||||
preview: boolean;
|
||||
disablePreview: boolean;
|
||||
disableDelete: boolean;
|
||||
disableAdd: boolean;
|
||||
disableDownload: boolean;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const tslib_1 = require("tslib");
|
||||
const uuid_1 = require("oak-domain/lib/utils/uuid");
|
||||
const assert_1 = tslib_1.__importDefault(require("assert"));
|
||||
const assert_1 = require("oak-domain/lib/utils/assert");
|
||||
const index_1 = tslib_1.__importDefault(require("../../../utils/dialog/index"));
|
||||
exports.default = OakComponent({
|
||||
entity: 'extraFile',
|
||||
|
|
@ -26,8 +26,9 @@ exports.default = OakComponent({
|
|||
uploadState: 1,
|
||||
},
|
||||
formData({ data: originalFiles, features }) {
|
||||
console.log(originalFiles);
|
||||
let files = originalFiles?.filter((ele) => !ele.$$deleteAt$$).sort((ele1, ele2) => ele1.sort - ele2.sort);
|
||||
let files = originalFiles
|
||||
?.filter((ele) => !ele.$$deleteAt$$)
|
||||
.sort((ele1, ele2) => ele1.sort - ele2.sort);
|
||||
if (this.props.tag1) {
|
||||
files = files?.filter((ele) => ele?.tag1 === this.props.tag1);
|
||||
}
|
||||
|
|
@ -43,7 +44,7 @@ exports.default = OakComponent({
|
|||
data: {
|
||||
// 根据 size 不同,计算的图片显示大小不同
|
||||
itemSizePercentage: '',
|
||||
fileList: {}
|
||||
fileList: {},
|
||||
},
|
||||
wechatMp: {
|
||||
externalClasses: ['oak-class', 'oak-item-class'],
|
||||
|
|
@ -68,23 +69,17 @@ exports.default = OakComponent({
|
|||
autoUpload: false,
|
||||
maxNumber: 20,
|
||||
extension: [],
|
||||
fileType: 'all',
|
||||
selectCount: 1,
|
||||
sourceType: ['album', 'camera'],
|
||||
mediaType: ['image'],
|
||||
// 图片显示模式
|
||||
mode: 'aspectFit',
|
||||
// 每行可显示的个数
|
||||
size: 3,
|
||||
showUploadList: true,
|
||||
showUploadProgress: false,
|
||||
accept: 'image/*',
|
||||
// 图片是否可预览
|
||||
preview: true,
|
||||
// 图片是否可删除
|
||||
disablePreview: false,
|
||||
disableDelete: false,
|
||||
// 上传按钮隐藏
|
||||
disableAdd: false,
|
||||
// 下按按钮隐藏
|
||||
disableDownload: false,
|
||||
disabled: false,
|
||||
type: '',
|
||||
|
|
@ -94,15 +89,14 @@ exports.default = OakComponent({
|
|||
entity: '',
|
||||
entityId: '',
|
||||
theme: 'image',
|
||||
showUploadProgress: false,
|
||||
},
|
||||
methods: {
|
||||
getUrl(extraFile) {
|
||||
const { fileList } = this.state;
|
||||
if (fileList[extraFile?.id]) {
|
||||
console.log(fileList[extraFile?.id]);
|
||||
const url = this.features.extraFile.getUrl(Object.assign({}, extraFile, { extra1: fileList[extraFile?.id] }));
|
||||
console.log(url);
|
||||
const url = this.features.extraFile.getUrl(Object.assign({}, extraFile, {
|
||||
extra1: fileList[extraFile?.id],
|
||||
}));
|
||||
return url;
|
||||
}
|
||||
return this.features.extraFile.getUrl(extraFile);
|
||||
|
|
@ -110,7 +104,7 @@ exports.default = OakComponent({
|
|||
getFileName(extraFile) {
|
||||
return this.features.extraFile.getFileName(extraFile);
|
||||
},
|
||||
eFFormatBytes(value) {
|
||||
formatBytes(value) {
|
||||
return this.features.extraFile.formatBytes(value);
|
||||
},
|
||||
/**
|
||||
|
|
@ -177,12 +171,12 @@ exports.default = OakComponent({
|
|||
}
|
||||
},
|
||||
async chooseFileByMp() {
|
||||
const { selectCount, extension, fileType } = this.props;
|
||||
const { selectCount, extension } = this.props;
|
||||
try {
|
||||
const { errMsg, tempFiles } = await wx.chooseMessageFile({
|
||||
count: selectCount,
|
||||
type: 'all',
|
||||
...(fileType === 'file' ? { extension } : {}),
|
||||
extension,
|
||||
});
|
||||
if (errMsg !== 'chooseMessageFile:ok') {
|
||||
this.triggerEvent('error', {
|
||||
|
|
@ -223,7 +217,9 @@ exports.default = OakComponent({
|
|||
},
|
||||
async onPickByWeb(uploadFiles, callback) {
|
||||
const { files } = this.state;
|
||||
const currentSort = files?.length ? files[files.length - 1].sort : 0;
|
||||
const currentSort = files?.length
|
||||
? files[files.length - 1].sort
|
||||
: 0;
|
||||
await Promise.all(uploadFiles.map(async (uploadFile, index) => {
|
||||
const { name, type, size, originFileObj } = uploadFile;
|
||||
await this.pushExtraFile({
|
||||
|
|
@ -231,7 +227,7 @@ exports.default = OakComponent({
|
|||
fileType: type,
|
||||
size,
|
||||
extra1: originFileObj,
|
||||
sort: currentSort + (index + 1) * 100
|
||||
sort: currentSort + (index + 1) * 100,
|
||||
}, callback);
|
||||
}));
|
||||
},
|
||||
|
|
@ -240,9 +236,8 @@ exports.default = OakComponent({
|
|||
const { name, extra1, fileType, size, sort } = options;
|
||||
const extension = name.substring(name.lastIndexOf('.') + 1);
|
||||
const filename = name.substring(0, name.lastIndexOf('.'));
|
||||
(0, assert_1.default)(entity, '必须传入entity');
|
||||
(0, assert_1.default)(origin === 'qiniu', '目前只支持七牛上传'); // 目前只支持七牛上传
|
||||
const id = (0, uuid_1.generateNewId)();
|
||||
(0, assert_1.assert)(entity, '必须传入entity');
|
||||
(0, assert_1.assert)(origin === 'qiniu', '目前只支持七牛上传'); // 目前只支持七牛上传
|
||||
const updateData = {
|
||||
origin,
|
||||
type: type || 'file',
|
||||
|
|
@ -254,9 +249,8 @@ exports.default = OakComponent({
|
|||
size,
|
||||
extension,
|
||||
fileType,
|
||||
id,
|
||||
entityId,
|
||||
sort
|
||||
sort,
|
||||
};
|
||||
// autoUpload为true, 选择直接上传七牛,再提交extraFile
|
||||
if (autoUpload) {
|
||||
|
|
@ -276,16 +270,17 @@ exports.default = OakComponent({
|
|||
if (callback) {
|
||||
callback(updateData, 'failed');
|
||||
}
|
||||
//todo 保存extraFile失败 需要remove七牛图片
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.addItem(updateData, undefined, async () => {
|
||||
const id = this.addItem(updateData, undefined, async () => {
|
||||
await this.features.extraFile.upload(updateData, extra1);
|
||||
});
|
||||
this.setState({
|
||||
fileList: Object.assign(this.state.fileList, { [id]: extra1 })
|
||||
fileList: Object.assign(this.state.fileList, {
|
||||
[id]: extra1,
|
||||
}),
|
||||
});
|
||||
}
|
||||
},
|
||||
|
|
@ -304,7 +299,7 @@ exports.default = OakComponent({
|
|||
};
|
||||
this.triggerEvent('tap', detail);
|
||||
// 预览图片
|
||||
if (this.props.preview) {
|
||||
if (!this.props.disablePreview) {
|
||||
const result = await wx.previewImage({
|
||||
urls: urls,
|
||||
current: imageUrl,
|
||||
|
|
@ -323,7 +318,7 @@ exports.default = OakComponent({
|
|||
[id]: null,
|
||||
});
|
||||
this.setState({
|
||||
fileList
|
||||
fileList,
|
||||
});
|
||||
}
|
||||
else {
|
||||
|
|
@ -338,7 +333,7 @@ exports.default = OakComponent({
|
|||
id: null,
|
||||
});
|
||||
this.setState({
|
||||
fileList
|
||||
fileList,
|
||||
});
|
||||
await this.execute();
|
||||
}
|
||||
|
|
@ -355,7 +350,7 @@ exports.default = OakComponent({
|
|||
id: null,
|
||||
});
|
||||
this.setState({
|
||||
fileList
|
||||
fileList,
|
||||
});
|
||||
}
|
||||
else {
|
||||
|
|
@ -370,7 +365,7 @@ exports.default = OakComponent({
|
|||
id: null,
|
||||
});
|
||||
this.setState({
|
||||
fileList
|
||||
fileList,
|
||||
});
|
||||
await this.execute();
|
||||
confirm.destroy();
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ interface NewUploadFile extends UploadFile {
|
|||
id?: string;
|
||||
}
|
||||
type Theme = "file" | "image" | "image-flow" | "custom";
|
||||
export default function render(props: WebComponentProps<EntityDict, "extraFile", true, {
|
||||
export default function render(props: WebComponentProps<EntityDict, 'extraFile', true, {
|
||||
accept?: string;
|
||||
maxNumber?: number;
|
||||
multiple?: boolean;
|
||||
|
|
@ -21,17 +21,17 @@ export default function render(props: WebComponentProps<EntityDict, "extraFile",
|
|||
onDownload?: (file: UploadFile<any>) => void;
|
||||
showUploadList?: boolean;
|
||||
children?: JSX.Element;
|
||||
files?: EntityDict["extraFile"]["OpSchema"][];
|
||||
files?: EntityDict['extraFile']['OpSchema'][];
|
||||
disableInsert?: boolean;
|
||||
disableAdd?: boolean;
|
||||
disableDownload?: boolean;
|
||||
disableDelete?: boolean;
|
||||
preview?: boolean;
|
||||
disablePreview?: boolean;
|
||||
}, {
|
||||
onPickByWeb: (files: UploadFile[], callback?: (file: NewUploadFile, status: string) => void) => void;
|
||||
onDeleteByWeb: (file: UploadFile) => void;
|
||||
getUrl: (extraFile: EntityDict['extraFile']['OpSchema']) => string;
|
||||
getFileName: (extraFile: EntityDict['extraFile']['OpSchema']) => string;
|
||||
eFFormatBytes: (value: number) => string;
|
||||
formatBytes: (value: number) => string;
|
||||
}>): import("react/jsx-runtime").JSX.Element;
|
||||
export {};
|
||||
|
|
|
|||
|
|
@ -52,8 +52,8 @@ const DragableUploadListItem = ({ 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, disabled, style, className, directory = false, onPreview, onDownload, children, showUploadList = true, files, disableInsert = false, disableAdd = false, disableDownload = false, disableDelete = false, preview = true, } = props.data;
|
||||
const { onPickByWeb, onDeleteByWeb, updateItem, t, getFileName, getUrl, eFFormatBytes } = props.methods;
|
||||
const { accept = 'image/*', maxNumber = 20, multiple = maxNumber !== 1, draggable = false, theme = 'image', tips, beforeUpload, disabled, style, className, directory = false, onPreview, onDownload, children, showUploadList = true, files, disableInsert = false, disableAdd = false, disableDownload = false, disableDelete = false, disablePreview = false, } = props.data;
|
||||
const { onPickByWeb, onDeleteByWeb, updateItem, t, getFileName, getUrl, formatBytes, } = props.methods;
|
||||
const [newFiles, setNewFiles] = (0, react_1.useState)([]);
|
||||
const [newUploadFiles, setNewUploadFiles] = (0, react_1.useState)([]);
|
||||
const listType = getListType(theme);
|
||||
|
|
@ -114,7 +114,7 @@ function render(props) {
|
|||
if (children) {
|
||||
return children;
|
||||
}
|
||||
if (listType === "picture-card") {
|
||||
if (listType === 'picture-card') {
|
||||
return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)(icons_1.PlusOutlined, {}), (0, jsx_runtime_1.jsx)("div", { style: { marginTop: 8 }, children: "\u8BF7\u9009\u62E9\u56FE\u7247" })] }));
|
||||
}
|
||||
return (0, jsx_runtime_1.jsx)(antd_1.Button, { type: "default", children: "\u9009\u62E9\u6587\u4EF6" });
|
||||
|
|
@ -134,7 +134,10 @@ function render(props) {
|
|||
sort = newFiles[hoverIndex].sort + 100;
|
||||
}
|
||||
else {
|
||||
sort = (newFiles[hoverIndex].sort + newFiles[hoverIndex + 1].sort) / 2;
|
||||
sort =
|
||||
(newFiles[hoverIndex].sort +
|
||||
newFiles[hoverIndex + 1].sort) /
|
||||
2;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
@ -142,35 +145,38 @@ function render(props) {
|
|||
sort = newFiles[hoverIndex].sort / 2;
|
||||
}
|
||||
else {
|
||||
sort = (newFiles[hoverIndex].sort + newFiles[hoverIndex - 1].sort) / 2;
|
||||
sort =
|
||||
(newFiles[hoverIndex].sort +
|
||||
newFiles[hoverIndex - 1].sort) /
|
||||
2;
|
||||
}
|
||||
}
|
||||
if (checkLimit(sort)) {
|
||||
alert("当前的sort值为:" + sort);
|
||||
alert('当前的sort值为:' + sort);
|
||||
return;
|
||||
}
|
||||
updateItem({ sort }, dragRow.id);
|
||||
}, [newFiles]);
|
||||
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_2.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, disabled: disabled, directory: directory, showUploadList: showUploadList
|
||||
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_2.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, disabled: disabled, directory: directory, showUploadList: showUploadList
|
||||
? {
|
||||
showPreviewIcon: preview,
|
||||
showPreviewIcon: !disablePreview,
|
||||
showRemoveIcon: !disableDelete,
|
||||
showDownloadIcon: !disableDownload,
|
||||
}
|
||||
: false, beforeUpload: async (file) => {
|
||||
if (typeof beforeUpload === "function") {
|
||||
if (typeof beforeUpload === 'function') {
|
||||
const result = await beforeUpload(file);
|
||||
if (result) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}, multiple: multiple, maxCount: maxNumber, accept: accept, listType: listType, fileList: theme === "custom"
|
||||
}, multiple: multiple, maxCount: maxNumber, accept: accept, listType: listType, fileList: theme === 'custom'
|
||||
? []
|
||||
: newFiles?.map((ele) => extraFileToUploadFile(ele)), onChange: ({ file, fileList, event }) => {
|
||||
// id不存在就是file对象
|
||||
if (!file.id) {
|
||||
if (theme !== "custom") {
|
||||
if (theme !== 'custom') {
|
||||
onPickByWeb([(0, utils_1.file2Obj)(file)]);
|
||||
}
|
||||
else {
|
||||
|
|
@ -179,53 +185,53 @@ function render(props) {
|
|||
}
|
||||
}, onRemove: onDeleteByWeb, onPreview: onPreview, onDownload: onDownload, itemRender: (originNode, currentFile, currentFileList) => {
|
||||
return ((0, jsx_runtime_1.jsx)(DragableUploadListItem, { originNode: originNode, file: currentFile, fileList: currentFileList, moveRow: moveRow }));
|
||||
}, children: !disableInsert && !disableAdd ? getUploadButton() : null }) }), tips && (0, jsx_runtime_1.jsx)("small", { className: web_module_less_1.default["oak-upload__tips"], children: tips }), theme === "custom" && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(antd_1.Table, { dataSource: newUploadFiles || [], rowKey: "id", columns: [
|
||||
}, children: !disableInsert && !disableAdd ? getUploadButton() : null }) }), tips && ((0, jsx_runtime_1.jsx)("small", { className: web_module_less_1.default['oak-upload__tips'], children: tips })), theme === 'custom' && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(antd_1.Table, { dataSource: newUploadFiles || [], rowKey: "id", columns: [
|
||||
{
|
||||
align: "center",
|
||||
dataIndex: "tableIndex",
|
||||
title: "#",
|
||||
align: 'center',
|
||||
dataIndex: 'tableIndex',
|
||||
title: '#',
|
||||
render: (value, record, index) => index + 1,
|
||||
width: 50,
|
||||
},
|
||||
{
|
||||
dataIndex: "name",
|
||||
title: "文件名",
|
||||
dataIndex: 'name',
|
||||
title: '文件名',
|
||||
},
|
||||
{
|
||||
dataIndex: "size",
|
||||
title: "文件大小",
|
||||
dataIndex: 'size',
|
||||
title: '文件大小',
|
||||
render: (value, record, index) => {
|
||||
return eFFormatBytes(value);
|
||||
return formatBytes(value);
|
||||
},
|
||||
},
|
||||
{
|
||||
dataIndex: "status",
|
||||
title: "状态",
|
||||
dataIndex: 'status',
|
||||
title: '状态',
|
||||
render: (value, record, index) => {
|
||||
switch (value) {
|
||||
case "success":
|
||||
return (0, jsx_runtime_1.jsx)(antd_1.Tag, { color: "success", children: t("success") });
|
||||
case "uploading":
|
||||
return (0, jsx_runtime_1.jsx)(antd_1.Tag, { color: "processing", children: t("uploading") });
|
||||
case 'success':
|
||||
return ((0, jsx_runtime_1.jsx)(antd_1.Tag, { color: "success", children: t('success') }));
|
||||
case 'uploading':
|
||||
return ((0, jsx_runtime_1.jsx)(antd_1.Tag, { color: "processing", children: t('uploading') }));
|
||||
default:
|
||||
return (0, jsx_runtime_1.jsx)(antd_1.Tag, { color: "warning", children: t("waiting") });
|
||||
return ((0, jsx_runtime_1.jsx)(antd_1.Tag, { color: "warning", children: t('waiting') }));
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
dataIndex: "op",
|
||||
dataIndex: 'op',
|
||||
width: 300,
|
||||
title: "操作",
|
||||
align: "center",
|
||||
title: '操作',
|
||||
align: 'center',
|
||||
render: (value, record, index) => {
|
||||
// 只处理state的文件 这时候可以直接删除
|
||||
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: !record.id && ((0, jsx_runtime_1.jsx)(antd_1.Button, { type: "link", onClick: () => {
|
||||
customDelete(index);
|
||||
}, children: "\u5220\u9664" })) }));
|
||||
},
|
||||
fixed: "right",
|
||||
fixed: 'right',
|
||||
},
|
||||
] }), (0, jsx_runtime_1.jsx)("div", { style: { display: "flex", justifyContent: "flex-end" }, children: (0, jsx_runtime_1.jsxs)(antd_1.Space, { children: [(0, jsx_runtime_1.jsx)(antd_1.Button, { danger: true, type: "default", onClick: () => setNewUploadFiles([]), children: "\u6E05\u7A7A" }), (0, jsx_runtime_1.jsx)(antd_1.Button, { type: "primary", onClick: () => {
|
||||
] }), (0, jsx_runtime_1.jsx)("div", { style: { display: 'flex', justifyContent: 'flex-end' }, children: (0, jsx_runtime_1.jsxs)(antd_1.Space, { children: [(0, jsx_runtime_1.jsx)(antd_1.Button, { danger: true, type: "default", onClick: () => setNewUploadFiles([]), children: "\u6E05\u7A7A" }), (0, jsx_runtime_1.jsx)(antd_1.Button, { type: "primary", onClick: () => {
|
||||
onPickByWeb(newUploadFiles, (file, status) => {
|
||||
setNewUploadFilesByStatus(file, status);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ export interface EnhancedExtraFile extends ExtraFile {
|
|||
}
|
||||
type SourceType = 'album' | 'camera';
|
||||
export type Theme = 'file' | 'image' | 'image-flow' | 'custom';
|
||||
type FileType = 'all' | 'video' | 'image' | 'file';
|
||||
type ImgMode = 'scaleToFill' | 'aspectFit' | 'aspectFill' | 'widthFix' | "heightFix" | 'top' | 'bottom' | 'left' | 'right' | 'center' | 'top left' | 'top right' | 'bottom left' | 'bottom right';
|
||||
declare const _default: <ED2 extends EntityDict & BaseEntityDict, T2 extends keyof ED2>(props: ReactComponentProps<ED2, T2, true, {
|
||||
bucket: string;
|
||||
|
|
@ -20,15 +19,15 @@ declare const _default: <ED2 extends EntityDict & BaseEntityDict, T2 extends key
|
|||
autoUpload: boolean;
|
||||
maxNumber: number;
|
||||
extension: string[];
|
||||
fileType: FileType;
|
||||
selectCount: number;
|
||||
sourceType: SourceType[];
|
||||
mediaType: ('image' | 'video')[];
|
||||
mode: ImgMode;
|
||||
size: number;
|
||||
showUploadList: boolean;
|
||||
showUploadProgress: boolean;
|
||||
accept: string;
|
||||
preview: boolean;
|
||||
disablePreview: boolean;
|
||||
disableDelete: boolean;
|
||||
disableAdd: boolean;
|
||||
disableDownload: boolean;
|
||||
|
|
@ -40,7 +39,6 @@ declare const _default: <ED2 extends EntityDict & BaseEntityDict, T2 extends key
|
|||
entity: keyof ED2;
|
||||
entityId: string;
|
||||
theme: Theme;
|
||||
showUploadProgress: boolean;
|
||||
children?: React.ReactNode;
|
||||
}>) => React.ReactElement;
|
||||
export default _default;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ exports.default = OakComponent({
|
|||
itemSizePercentage: '',
|
||||
},
|
||||
wechatMp: {
|
||||
externalClasses: ['oak-class', 'oak-item-class'],
|
||||
externalClasses: ['oak-class', 'oak-item-class', 'oak-item-add-class'],
|
||||
},
|
||||
filters: [
|
||||
{
|
||||
|
|
@ -51,32 +51,25 @@ exports.default = OakComponent({
|
|||
autoUpload: false,
|
||||
maxNumber: 20,
|
||||
extension: [],
|
||||
fileType: 'all',
|
||||
selectCount: 1,
|
||||
sourceType: ['album', 'camera'],
|
||||
mediaType: ['image'],
|
||||
// 图片显示模式
|
||||
mode: 'aspectFit',
|
||||
// 每行可显示的个数
|
||||
size: 3,
|
||||
showUploadList: true,
|
||||
showUploadProgress: false,
|
||||
accept: 'image/*',
|
||||
// 图片是否可预览
|
||||
preview: true,
|
||||
// 图片是否可删除
|
||||
disablePreview: false,
|
||||
disableDelete: false,
|
||||
// 上传按钮隐藏
|
||||
disableAdd: false,
|
||||
// 下按按钮隐藏
|
||||
disableDownload: false,
|
||||
type: 'file',
|
||||
type: 'image',
|
||||
origin: 'qiniu',
|
||||
tag1: '',
|
||||
tag2: '',
|
||||
entity: '',
|
||||
entityId: '',
|
||||
theme: 'image',
|
||||
showUploadProgress: false,
|
||||
},
|
||||
listeners: {
|
||||
maxNumber(prev, next) {
|
||||
|
|
@ -106,7 +99,9 @@ exports.default = OakComponent({
|
|||
},
|
||||
features: ['extraFile2'],
|
||||
formData({ data, features }) {
|
||||
const files = data.map(ele => {
|
||||
const files = data
|
||||
?.sort((ele1, ele2) => ele1.sort - ele2.sort)
|
||||
.map((ele) => {
|
||||
const url = features.extraFile2.getUrl(ele);
|
||||
const thumbUrl = features.extraFile2.getUrl(ele, 'thumbnail');
|
||||
const fileState = features.extraFile2.getFileState(ele.id);
|
||||
|
|
@ -130,16 +125,17 @@ exports.default = OakComponent({
|
|||
this.features.extraFile2.removeLocalFiles([file.id]);
|
||||
},
|
||||
addExtraFileInner(options, file) {
|
||||
const { type, origin, tag1, tag2, entity, entityId, bucket } = this.props;
|
||||
const { type, origin = 'qiniu', // 默认qiniu
|
||||
tag1, tag2, entity, entityId, bucket, } = this.props;
|
||||
const { name, fileType, size } = options;
|
||||
const extension = name.substring(name.lastIndexOf('.') + 1);
|
||||
const filename = name.substring(0, name.lastIndexOf('.'));
|
||||
const { files } = this.state;
|
||||
const sort = files.length * 10000;
|
||||
let bucket2 = bucket;
|
||||
if (!bucket2) {
|
||||
if (origin === 'qiniu' && !bucket2) {
|
||||
const context = this.features.cache.begin();
|
||||
const { config } = (0, getContextConfig_1.getConfig)(context, 'Cos', 'qiniu');
|
||||
const { config } = (0, getContextConfig_1.getConfig)(context, 'Cos', origin);
|
||||
this.features.cache.commit();
|
||||
const { defaultBucket } = config;
|
||||
bucket2 = defaultBucket;
|
||||
|
|
@ -171,6 +167,124 @@ exports.default = OakComponent({
|
|||
fileType: type,
|
||||
size,
|
||||
}, file);
|
||||
}
|
||||
}
|
||||
},
|
||||
// 小程序端
|
||||
async chooseMediaByMp() {
|
||||
//图片和视频使用
|
||||
const { selectCount, mediaType, sourceType } = this.props;
|
||||
try {
|
||||
const { errMsg, tempFiles } = await wx.chooseMedia({
|
||||
count: selectCount,
|
||||
mediaType,
|
||||
sourceType,
|
||||
});
|
||||
if (errMsg !== 'chooseMedia:ok') {
|
||||
this.triggerEvent('onError', {
|
||||
level: 'warning',
|
||||
msg: errMsg,
|
||||
});
|
||||
}
|
||||
else {
|
||||
tempFiles.map((tempExtraFile) => {
|
||||
const { tempFilePath, thumbTempFilePath, fileType, size, } = tempExtraFile;
|
||||
const filePath = tempFilePath || thumbTempFilePath;
|
||||
const fileFullName = filePath.match(/[^/]+(?!.*\/)/g)[0];
|
||||
this.addExtraFileInner({
|
||||
name: fileFullName,
|
||||
fileType,
|
||||
size,
|
||||
}, filePath);
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
if (err.errMsg !== 'chooseMedia:fail cancel') {
|
||||
this.triggerEvent('onError', {
|
||||
level: 'error',
|
||||
msg: err.errMsg,
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
async chooseMessageFileByMp() {
|
||||
const { selectCount, extension } = this.props;
|
||||
try {
|
||||
const { errMsg, tempFiles } = await wx.chooseMessageFile({
|
||||
count: selectCount,
|
||||
type: 'all',
|
||||
extension,
|
||||
});
|
||||
if (errMsg !== 'chooseMessageFile:ok') {
|
||||
this.triggerEvent('onError', {
|
||||
level: 'warning',
|
||||
msg: errMsg,
|
||||
});
|
||||
}
|
||||
else {
|
||||
tempFiles.map((tempExtraFile) => {
|
||||
const { path, type, size, name } = tempExtraFile;
|
||||
this.addExtraFileInner({
|
||||
name,
|
||||
fileType: type,
|
||||
size,
|
||||
}, path);
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
if (err.errMsg !== 'chooseMessageFile:fail cancel') {
|
||||
this.triggerEvent('onError', {
|
||||
level: 'error',
|
||||
msg: err.errMsg,
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
async addFileByMp(evt) {
|
||||
const { type } = this.props;
|
||||
//小程序 根据type类型调用api
|
||||
if (['image', 'video'].includes(type)) {
|
||||
this.chooseMediaByMp();
|
||||
}
|
||||
else {
|
||||
this.chooseMessageFileByMp();
|
||||
}
|
||||
},
|
||||
onRemoveByMp(event) {
|
||||
const { value } = event.currentTarget.dataset;
|
||||
this.onRemove(value);
|
||||
},
|
||||
async onPreviewByMp(event) {
|
||||
const files = this.state.files;
|
||||
const { index } = event.currentTarget.dataset;
|
||||
const imageUrl = files[index].url;
|
||||
const urls = files?.filter((ele) => !!ele).map((ele) => ele.url);
|
||||
const detail = {
|
||||
all: files,
|
||||
index,
|
||||
urls,
|
||||
current: imageUrl,
|
||||
};
|
||||
// 预览图片
|
||||
if (!this.props.disablePreview) {
|
||||
const result = await wx.previewImage({
|
||||
urls: urls,
|
||||
current: imageUrl,
|
||||
});
|
||||
this.triggerEvent('onPreview', detail);
|
||||
}
|
||||
},
|
||||
//检查排序是否超过上限
|
||||
checkSort(sort) {
|
||||
const reg = /^\d+\.(?:9+)$/;
|
||||
if (reg.test(sort.toString())) {
|
||||
this.setMessage({
|
||||
type: 'warning',
|
||||
content: this.t('dragSort'),
|
||||
});
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -0,0 +1,162 @@
|
|||
@import "../../../config/styles/mp/index.less";
|
||||
@import "../../../config/styles/mp/mixins.less";
|
||||
|
||||
.file-list__container {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.file-list__item {
|
||||
position: relative;
|
||||
width: 220rpx;
|
||||
padding-bottom: 220rpx;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
// size 不同时,对应的图片间距设置
|
||||
// size 仅支持 1-10
|
||||
each(range(2, 10), {
|
||||
@valuePlusOne : @value+1;
|
||||
|
||||
.file-list__item--@{value}:nth-of-type(n+@{valuePlusOne}) {
|
||||
margin-top : 20rpx;
|
||||
}
|
||||
|
||||
.file-list__item--@{value}:not(:nth-of-type(@{value}n+1)) {
|
||||
margin-left : 20rpx;
|
||||
}
|
||||
}) // 当 size 为 null,每行会显示 3 张图片
|
||||
|
||||
.file-list__item--null:nth-of-type(n+4) {
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
|
||||
.file-list__item--null:not(:nth-of-type(3n+1)) {
|
||||
margin-left: 20rpx;
|
||||
}
|
||||
|
||||
.file-list__image {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border: 1rpx solid #eee;
|
||||
border-radius: 4rpx;
|
||||
}
|
||||
|
||||
.file-list__item--selected {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
z-index: 10;
|
||||
background-color: #000;
|
||||
filter: Alpha(Opacity=50);
|
||||
opacity: 0.5;
|
||||
position: absolute;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: space-around;
|
||||
}
|
||||
|
||||
.file-list__remove {
|
||||
position: absolute;
|
||||
right: 10rpx;
|
||||
top: 10rpx;
|
||||
height: 40rpx;
|
||||
width: 40rpx;
|
||||
border-radius: 50%;
|
||||
background: rgb(0 0 0 / 40%);
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.file-list__item--add {
|
||||
border: 1rpx solid #eee;
|
||||
border-radius: 4rpx;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
.file-list__item--image {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border: 1rpx solid #eee;
|
||||
border-radius: 4rpx;
|
||||
}
|
||||
|
||||
.file-list__image--add {
|
||||
visibility: hidden;
|
||||
position: absolute;
|
||||
width: 50%;
|
||||
height: 50%;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.file-list__item-slot-wrapper {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
top: 0;
|
||||
left: 0;
|
||||
}
|
||||
|
||||
.file-list__item-slot-wrapper:empty+.file-list__image--add {
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
|
||||
.file-list-flow__container {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
.file-list-flow__item {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
margin: 10rpx 10rpx 10rpx 0;
|
||||
}
|
||||
.file-list-flow__item--name {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
fleX: 1;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.file-list-flow__item--btns {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.file-list-flow__download {
|
||||
width: 48rpx;
|
||||
height: 48rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.file-list-flow__remove {
|
||||
width: 48rpx;
|
||||
height: 48rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
<block wx:if="{{ type === 'image' }}">
|
||||
<view class="file-list__container oak-class">
|
||||
<block wx:for="{{files}}" wx:key="index">
|
||||
<block wx:if="{{item}}">
|
||||
<view class="file-list__item file-list__item--{{size}} oak-item-class" style="{{itemSizePercentage?'width:'+itemSizePercentage+'padding-bottom:'+itemSizePercentage:'xxx'}}">
|
||||
<image data-index="{{index}}" bind:tap="onPreviewByMp" src="{{item.url}}" mode="{{mode}}" class="file-list__item--image"/>
|
||||
|
||||
<view wx:if="{{!disableDelete}}" mut-bind:tap="onRemoveByMp" class="file-list__remove" data-value="{{item}}">
|
||||
<l-icon name="close" color="#ffffff" size="18" />
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
</block>
|
||||
<view class="file-list__item file-list__item--add file-list__item--{{size}} oak-item-add-class" style="{{itemSizePercentage?'width:'+itemSizePercentage+'padding-bottom:'+itemSizePercentage:''}}" wx:if="{{!disableInsert && !disableAdd}}" bind:tap="addFileByMp">
|
||||
<view class="file-list__item-slot-wrapper">
|
||||
<slot />
|
||||
</view>
|
||||
<view class="file-list__image--add">
|
||||
<l-icon name="add" size="80" />
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
<block wx:else >
|
||||
<view class="file-list-flow__container oak-class">
|
||||
<view class="file-list-flow__item--add oak-item-add-class" wx:if="{{!disableInsert && !disableAdd}}">
|
||||
<l-button bind:lintap="addFileByMp" plain="{{true}}" type="default">{{ t('chooseFile') }}</l-button>
|
||||
</view>
|
||||
<block wx:for="{{files}}" wx:key="index">
|
||||
<block wx:if="{{item}}">
|
||||
<view class="file-list-flow__item oak-item-class">
|
||||
<view class="file-list-flow__item--name" mut-bind:tap="onOpenByMp" data-value="{{item}}">
|
||||
{{ item.filename }}
|
||||
</view>
|
||||
<view class="file-list-flow__item--btns">
|
||||
<!-- <view wx:if="{{!disableDownload}}" mut-bind:tap="onDownloadByMp" class="file-list-flow__download" data-value="{{item}}">
|
||||
<l-icon name="download" size="36" />
|
||||
</view> -->
|
||||
<view wx:if="{{!disableDelete}}" mut-bind:tap="onRemoveByMp" class="file-list-flow__remove" data-value="{{item}}">
|
||||
<l-icon name="delete" size="36" />
|
||||
</view>
|
||||
<view>
|
||||
</view>
|
||||
</block>
|
||||
</block>
|
||||
</view>
|
||||
</block>
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
"choosePicture": "请选择图片",
|
||||
"chooseFile": "请选择文件"
|
||||
"chooseFile": "请选择文件",
|
||||
"dragSort": "当前拖拽排序值超过上限范围"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,8 +21,9 @@ export default function render(props: WebComponentProps<EntityDict, 'extraFile',
|
|||
disableInsert?: boolean;
|
||||
disableDownload?: boolean;
|
||||
disableDelete?: boolean;
|
||||
preview?: boolean;
|
||||
disablePreview?: boolean;
|
||||
}, {
|
||||
onRemove: (file: UploadFile) => void;
|
||||
addFileByWeb: (file: UploadFile) => void;
|
||||
checkSort: (sort: number) => boolean;
|
||||
}>): import("react/jsx-runtime").JSX.Element;
|
||||
|
|
|
|||
|
|
@ -51,14 +51,14 @@ const DragableUploadListItem = ({ 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, preview = true, } = props.data;
|
||||
const { t, onRemove, addFileByWeb } = props.methods;
|
||||
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 { t, updateItem, onRemove, addFileByWeb, checkSort } = props.methods;
|
||||
const listType = getListType(theme);
|
||||
const getUploadButton = () => {
|
||||
if (children) {
|
||||
return children;
|
||||
}
|
||||
if (listType === "picture-card") {
|
||||
if (listType === 'picture-card') {
|
||||
return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)(icons_1.PlusOutlined, {}), (0, jsx_runtime_1.jsx)("div", { style: { marginTop: 8 }, children: t('choosePicture') })] }));
|
||||
}
|
||||
return (0, jsx_runtime_1.jsx)(antd_1.Button, { type: "default", children: t('chooseFile') });
|
||||
|
|
@ -117,16 +117,45 @@ function render(props) {
|
|||
});
|
||||
};
|
||||
const moveRow = (0, react_1.useCallback)((dragIndex, hoverIndex) => {
|
||||
console.log('dragIndex', dragIndex, 'hoverIndex', hoverIndex);
|
||||
const dragRow = files[dragIndex];
|
||||
let sort;
|
||||
if (hoverIndex === dragIndex) {
|
||||
return;
|
||||
}
|
||||
else if (hoverIndex > dragIndex) {
|
||||
if (hoverIndex === files.length - 1) {
|
||||
sort = files[hoverIndex].sort + 100;
|
||||
}
|
||||
else {
|
||||
sort =
|
||||
(files[hoverIndex].sort +
|
||||
files[hoverIndex + 1].sort) /
|
||||
2;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (hoverIndex === 0) {
|
||||
sort = files[hoverIndex].sort / 2;
|
||||
}
|
||||
else {
|
||||
sort =
|
||||
(files[hoverIndex].sort +
|
||||
files[hoverIndex - 1].sort) /
|
||||
2;
|
||||
}
|
||||
}
|
||||
if (checkSort(sort)) {
|
||||
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
|
||||
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: preview,
|
||||
showPreviewIcon: !disablePreview,
|
||||
showRemoveIcon: !disableDelete,
|
||||
showDownloadIcon: !disableDownload,
|
||||
}
|
||||
: false, beforeUpload: async (file) => {
|
||||
if (typeof beforeUpload === "function") {
|
||||
if (typeof beforeUpload === 'function') {
|
||||
const result = await beforeUpload(file);
|
||||
if (result) {
|
||||
return false;
|
||||
|
|
@ -139,6 +168,8 @@ function render(props) {
|
|||
}
|
||||
}, onRemove: onRemove, onPreview: onPreview, onDownload: onDownload, itemRender: (originNode, currentFile, currentFileList) => {
|
||||
return ((0, jsx_runtime_1.jsx)(DragableUploadListItem, { 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 })] }));
|
||||
}, 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 }))] }));
|
||||
}
|
||||
exports.default = render;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|||
const antd_1 = require("antd");
|
||||
const web_pc_module_less_1 = tslib_1.__importDefault(require("./web.pc.module.less"));
|
||||
const upsert_1 = tslib_1.__importDefault(require("../../config/upsert"));
|
||||
const style_1 = tslib_1.__importDefault(require("../../config/style"));
|
||||
const platform_1 = tslib_1.__importDefault(require("../../config/style/platform"));
|
||||
const detail_1 = tslib_1.__importDefault(require("../detail"));
|
||||
const system_1 = tslib_1.__importDefault(require("../system"));
|
||||
function render(props) {
|
||||
|
|
@ -26,9 +26,7 @@ function render(props) {
|
|||
{
|
||||
label: (0, jsx_runtime_1.jsx)("div", { className: web_pc_module_less_1.default.tabLabel, children: t('style') }),
|
||||
key: 'style',
|
||||
children: ((0, jsx_runtime_1.jsx)(style_1.default, { value: style, onChange: (s) => {
|
||||
update({ style: s });
|
||||
} })),
|
||||
children: ((0, jsx_runtime_1.jsx)(platform_1.default, { style: style, entity: 'platform', entityId: id, name: name })),
|
||||
},
|
||||
{
|
||||
label: (0, jsx_runtime_1.jsx)("div", { className: web_pc_module_less_1.default.tabLabel, children: t('system-list') }),
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|||
const antd_1 = require("antd");
|
||||
const detail_1 = tslib_1.__importDefault(require("../detail"));
|
||||
const upsert_1 = tslib_1.__importDefault(require("../../config/upsert"));
|
||||
const style_1 = tslib_1.__importDefault(require("../../config/style"));
|
||||
const platform_1 = tslib_1.__importDefault(require("../../config/style/platform"));
|
||||
const list_1 = tslib_1.__importDefault(require("../../domain/list"));
|
||||
const application_1 = tslib_1.__importDefault(require("../application"));
|
||||
const web_pc_module_less_1 = tslib_1.__importDefault(require("./web.pc.module.less"));
|
||||
|
|
@ -27,9 +27,7 @@ function Render(props) {
|
|||
{
|
||||
label: (0, jsx_runtime_1.jsx)("div", { className: web_pc_module_less_1.default.tabLabel, children: t('style') }),
|
||||
key: 'style',
|
||||
children: ((0, jsx_runtime_1.jsx)(style_1.default, { value: style, onChange: (s) => {
|
||||
update({ style: s });
|
||||
} })),
|
||||
children: ((0, jsx_runtime_1.jsx)(platform_1.default, { style: style, entity: 'system', entityId: id, name: name })),
|
||||
},
|
||||
{
|
||||
label: (0, jsx_runtime_1.jsx)("div", { className: web_pc_module_less_1.default.tabLabel, children: t('application-list') }),
|
||||
|
|
|
|||
|
|
@ -76,7 +76,6 @@ function Render(props) {
|
|||
}
|
||||
};
|
||||
(0, react_1.useEffect)(() => {
|
||||
console.log(config);
|
||||
if (config && config.button && config.button[0] && onlyOne) {
|
||||
setMenuName(config.button[0].name);
|
||||
setOnlyOne(false);
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ export declare abstract class BackendRuntimeContext<ED extends EntityDict & Base
|
|||
* 异步等待初始化完成
|
||||
*/
|
||||
protected initialized(): Promise<void>;
|
||||
private initialize;
|
||||
protected initialize(data?: SerializedData): Promise<void>;
|
||||
getApplicationId(): ED["application"]["Schema"]["id"] | undefined;
|
||||
getSystemId(): ED["application"]["Schema"]["systemId"] | undefined;
|
||||
getApplication(): Partial<ED["application"]["Schema"]> | undefined;
|
||||
|
|
@ -34,7 +34,7 @@ export declare abstract class BackendRuntimeContext<ED extends EntityDict & Base
|
|||
getToken(allowUnloggedIn?: boolean): Partial<ED["token"]["Schema"]> | undefined;
|
||||
getCurrentUserId(allowUnloggedIn?: boolean): string;
|
||||
setTemporaryUserId(userId: string | undefined): void;
|
||||
toString(): string;
|
||||
protected getSerializedData(): SerializedData;
|
||||
isRoot(): boolean;
|
||||
isReallyRoot(): boolean;
|
||||
sendMessage(data: ED['message']['CreateSingle']['data']): Promise<import("oak-domain").OperationResult<ED>>;
|
||||
|
|
|
|||
|
|
@ -192,11 +192,14 @@ class BackendRuntimeContext extends oak_frontend_base_1.BackendRuntimeContext {
|
|||
setTemporaryUserId(userId) {
|
||||
this.temporaryUserId = userId;
|
||||
}
|
||||
toString() {
|
||||
if (this.rootMode) {
|
||||
return JSON.stringify({ rootMode: true });
|
||||
}
|
||||
return JSON.stringify({ a: this.application?.id, t: this.token?.id });
|
||||
getSerializedData() {
|
||||
const data = super.getSerializedData();
|
||||
return {
|
||||
...data,
|
||||
a: this.application?.id,
|
||||
t: this.token?.id,
|
||||
rm: this.rootMode,
|
||||
};
|
||||
}
|
||||
isRoot() {
|
||||
if (this.rootMode) {
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ export type AspectDict<ED extends EntityDict & BaseEntityDict, Cxt extends Backe
|
|||
export interface SerializedData extends Fsd {
|
||||
a?: string;
|
||||
t?: string;
|
||||
rm?: boolean;
|
||||
}
|
||||
export declare abstract class FrontendRuntimeContext<ED extends EntityDict & BaseEntityDict, Cxt extends BackendRuntimeContext<ED>, AD extends AspectDict<ED, Cxt>> extends Frc<ED, Cxt, AD> implements RuntimeContext {
|
||||
private application;
|
||||
|
|
|
|||
|
|
@ -205,7 +205,8 @@ const i18ns = [
|
|||
position: "src/components/extraFile/upload",
|
||||
data: {
|
||||
"choosePicture": "请选择图片",
|
||||
"chooseFile": "请选择文件"
|
||||
"chooseFile": "请选择文件",
|
||||
"dragSort": "当前拖拽排序值超过上限范围"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -17,13 +17,6 @@ export declare class ExtraFile<ED extends EntityDict, Cxt extends BackendRuntime
|
|||
}>;
|
||||
upload(extraFile: EntityDict['extraFile']['CreateSingle']['data'], file: string | File): Promise<void>;
|
||||
getUrl(extraFile?: EntityDict['extraFile']['OpSchema'] | EntityDict['extraFile']['Schema'] | null, style?: string): string;
|
||||
/**
|
||||
* 使用该方法,要在使用完url时,通过URL.revokeObjectURL释放缓存
|
||||
*
|
||||
* @param url 需要桥接访问的图片链接
|
||||
* @returns 浏览器 img可访问的url
|
||||
*/
|
||||
getBridgeUrl(url: string): Promise<string>;
|
||||
getFileName(extraFile: EntityDict['extraFile']['OpSchema']): string;
|
||||
formatBytes(size: number): string;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,21 +116,6 @@ class ExtraFile extends oak_frontend_base_1.Feature {
|
|||
url = cos.composeFileUrl(extraFile, context, style);
|
||||
return url;
|
||||
}
|
||||
/**
|
||||
* 使用该方法,要在使用完url时,通过URL.revokeObjectURL释放缓存
|
||||
*
|
||||
* @param url 需要桥接访问的图片链接
|
||||
* @returns 浏览器 img可访问的url
|
||||
*/
|
||||
async getBridgeUrl(url) {
|
||||
const { result } = await this.cache.exec('crossBridge', {
|
||||
url,
|
||||
});
|
||||
const blob = new Blob([result], {
|
||||
type: 'image/png',
|
||||
});
|
||||
return URL.createObjectURL(blob);
|
||||
}
|
||||
getFileName(extraFile) {
|
||||
const name = extraFile.filename +
|
||||
(extraFile.extension ? `.${extraFile.extension}` : '');
|
||||
|
|
|
|||
|
|
@ -22,13 +22,6 @@ export declare class ExtraFile2<ED extends EntityDict, Cxt extends BackendRuntim
|
|||
state: FileState;
|
||||
percentage?: number;
|
||||
} | undefined;
|
||||
/**
|
||||
* 使用该方法,要在使用完url时,通过URL.revokeObjectURL释放缓存
|
||||
*
|
||||
* @param url 需要桥接访问的图片链接
|
||||
* @returns 浏览器 img可访问的url
|
||||
*/
|
||||
getBridgeUrl(url: string): Promise<string>;
|
||||
getFileName(extraFile: EntityDict['extraFile']['OpSchema']): string;
|
||||
formatBytes(size: number): string;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,21 +118,6 @@ class ExtraFile2 extends oak_frontend_base_1.Feature {
|
|||
return this.files[id];
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 使用该方法,要在使用完url时,通过URL.revokeObjectURL释放缓存
|
||||
*
|
||||
* @param url 需要桥接访问的图片链接
|
||||
* @returns 浏览器 img可访问的url
|
||||
*/
|
||||
async getBridgeUrl(url) {
|
||||
const { result } = await this.cache.exec('crossBridge', {
|
||||
url,
|
||||
});
|
||||
const blob = new Blob([result], {
|
||||
type: 'image/png',
|
||||
});
|
||||
return URL.createObjectURL(blob);
|
||||
}
|
||||
getFileName(extraFile) {
|
||||
const name = extraFile.filename +
|
||||
(extraFile.extension ? `.${extraFile.extension}` : '');
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import { ExtraFile } from './extraFile';
|
|||
import { ExtraFile2 } from './extraFile2';
|
||||
import { Application } from './application';
|
||||
import { Config } from './config';
|
||||
import { Style2 } from './style2';
|
||||
import { WeiXinJsSdk } from './weiXinJsSdk';
|
||||
import { WechatMenu } from './wechatMenu';
|
||||
import { WechatPublicTag } from './wechatPublicTag';
|
||||
|
|
@ -21,6 +22,7 @@ export type GeneralFeatures<ED extends EntityDict, Cxt extends BackendRuntimeCon
|
|||
extraFile2: ExtraFile2<ED, Cxt, FrontCxt, AD>;
|
||||
application: Application<ED, Cxt, FrontCxt, AD>;
|
||||
config: Config<ED, Cxt, FrontCxt, AD>;
|
||||
style2: Style2<ED, Cxt, FrontCxt, AD>;
|
||||
weiXinJsSdk: WeiXinJsSdk<ED, Cxt, FrontCxt, AD>;
|
||||
theme: Theme<ED, Cxt, FrontCxt, AD>;
|
||||
wechatMenu: WechatMenu<ED, Cxt, FrontCxt, AD>;
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ const extraFile_1 = require("./extraFile");
|
|||
const extraFile2_1 = require("./extraFile2");
|
||||
const application_1 = require("./application");
|
||||
const config_1 = require("./config");
|
||||
const style2_1 = require("./style2");
|
||||
const weiXinJsSdk_1 = require("./weiXinJsSdk");
|
||||
const wechatMenu_1 = require("./wechatMenu");
|
||||
const wechatPublicTag_1 = require("./wechatPublicTag");
|
||||
|
|
@ -20,6 +21,7 @@ function initialize(basicFeatures, type, domain) {
|
|||
const extraFile = new extraFile_1.ExtraFile(basicFeatures.cache, application, basicFeatures.locales);
|
||||
const extraFile2 = new extraFile2_1.ExtraFile2(basicFeatures.cache, application, basicFeatures.locales);
|
||||
const config = new config_1.Config(basicFeatures.cache);
|
||||
const style2 = new style2_1.Style2(basicFeatures.cache);
|
||||
const weiXinJsSdk = new weiXinJsSdk_1.WeiXinJsSdk(basicFeatures.cache, basicFeatures.localStorage, basicFeatures.environment);
|
||||
const theme = new theme_1.default(basicFeatures.cache, basicFeatures.localStorage);
|
||||
return {
|
||||
|
|
@ -28,6 +30,7 @@ function initialize(basicFeatures, type, domain) {
|
|||
extraFile2,
|
||||
application,
|
||||
config,
|
||||
style2,
|
||||
weiXinJsSdk,
|
||||
theme,
|
||||
wechatMenu,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
import { Feature } from 'oak-frontend-base';
|
||||
import AspectDict from '../aspects/AspectDict';
|
||||
import { EntityDict } from '../oak-app-domain';
|
||||
import { Cache } from 'oak-frontend-base/es/features/cache';
|
||||
import { Style as StyleDef } from '../types/Style';
|
||||
import { BackendRuntimeContext } from '../context/BackendRuntimeContext';
|
||||
import { CommonAspectDict } from 'oak-common-aspect';
|
||||
import { FrontendRuntimeContext } from '../context/FrontendRuntimeContext';
|
||||
export declare class Style<ED extends EntityDict, Cxt extends BackendRuntimeContext<ED>, FrontCxt extends FrontendRuntimeContext<ED, Cxt, AD>, AD extends AspectDict<ED, Cxt> & CommonAspectDict<ED, Cxt>> extends Feature {
|
||||
private cache;
|
||||
constructor(cache: Cache<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>);
|
||||
updateStyle(entity: 'platform' | 'system' | 'application', entityId: string, style: StyleDef): Promise<void>;
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Style = void 0;
|
||||
const oak_frontend_base_1 = require("oak-frontend-base");
|
||||
class Style extends oak_frontend_base_1.Feature {
|
||||
cache;
|
||||
constructor(cache) {
|
||||
super();
|
||||
this.cache = cache;
|
||||
}
|
||||
async updateStyle(entity, entityId, style) {
|
||||
await this.cache.exec('updateStyle', {
|
||||
entity,
|
||||
entityId,
|
||||
style,
|
||||
});
|
||||
this.publish();
|
||||
}
|
||||
}
|
||||
exports.Style = Style;
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
import { Feature } from 'oak-frontend-base';
|
||||
import AspectDict from '../aspects/AspectDict';
|
||||
import { EntityDict } from '../oak-app-domain';
|
||||
import { Cache } from 'oak-frontend-base/es/features/cache';
|
||||
import { Style as StyleDef } from '../types/Style';
|
||||
import { BackendRuntimeContext } from '../context/BackendRuntimeContext';
|
||||
import { CommonAspectDict } from 'oak-common-aspect';
|
||||
import { FrontendRuntimeContext } from '../context/FrontendRuntimeContext';
|
||||
export declare class Style2<ED extends EntityDict, Cxt extends BackendRuntimeContext<ED>, FrontCxt extends FrontendRuntimeContext<ED, Cxt, AD>, AD extends AspectDict<ED, Cxt> & CommonAspectDict<ED, Cxt>> extends Feature {
|
||||
private cache;
|
||||
constructor(cache: Cache<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>);
|
||||
updateStyle(entity: 'platform' | 'system' | 'application', entityId: string, style: StyleDef): Promise<void>;
|
||||
}
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Style2 = void 0;
|
||||
const oak_frontend_base_1 = require("oak-frontend-base");
|
||||
class Style2 extends oak_frontend_base_1.Feature {
|
||||
cache;
|
||||
constructor(cache) {
|
||||
super();
|
||||
this.cache = cache;
|
||||
}
|
||||
async updateStyle(entity, entityId, style) {
|
||||
await this.cache.exec('updateStyle', {
|
||||
entity,
|
||||
entityId,
|
||||
style,
|
||||
});
|
||||
this.publish();
|
||||
}
|
||||
}
|
||||
exports.Style2 = Style2;
|
||||
|
|
@ -31,41 +31,15 @@ const triggers = [
|
|||
},
|
||||
{
|
||||
name: '删除extraFile时远端也进行删除',
|
||||
when: 'before',
|
||||
when: 'commit',
|
||||
strict: 'makeSure',
|
||||
entity: 'extraFile',
|
||||
action: 'remove',
|
||||
fn: async ({ operation }, context) => {
|
||||
const { filter } = operation;
|
||||
const extraFileList = await context.select('extraFile', {
|
||||
data: {
|
||||
id: 1,
|
||||
origin: 1,
|
||||
type: 1,
|
||||
bucket: 1,
|
||||
objectId: 1,
|
||||
tag1: 1,
|
||||
tag2: 1,
|
||||
filename: 1,
|
||||
md5: 1,
|
||||
entity: 1,
|
||||
entityId: 1,
|
||||
extra1: 1,
|
||||
extension: 1,
|
||||
size: 1,
|
||||
sort: 1,
|
||||
fileType: 1,
|
||||
isBridge: 1,
|
||||
uploadState: 1,
|
||||
uploadMeta: 1,
|
||||
},
|
||||
filter,
|
||||
}, {
|
||||
dontCollect: true,
|
||||
});
|
||||
for (const extraFile of extraFileList) {
|
||||
fn: async ({ rows }, context) => {
|
||||
for (const extraFile of rows) {
|
||||
const { origin } = extraFile;
|
||||
const uploader = (0, cos_1.getCos)(origin);
|
||||
await uploader.checkWhetherSuccess(extraFile, context);
|
||||
await uploader.removeFile(extraFile, context);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -242,17 +242,11 @@ const triggers = [
|
|||
action: 'create',
|
||||
when: 'commit',
|
||||
strict: 'takeEasy',
|
||||
fn: async ({ operation }, context) => {
|
||||
const { data } = operation;
|
||||
fn: async ({ rows }, context) => {
|
||||
const closeRootMode = context.openRootMode();
|
||||
try {
|
||||
if (data instanceof Array) {
|
||||
for (const d of data) {
|
||||
await sendNotification(d, context);
|
||||
}
|
||||
}
|
||||
else {
|
||||
await sendNotification(data, context);
|
||||
for (const row of rows) {
|
||||
await sendNotification(row, context);
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import { WebEnv, WechatMpEnv } from 'oak-domain/lib/types/Environment';
|
|||
import { AppType } from '../oak-app-domain/Application/Schema';
|
||||
import { EntityDict } from '../oak-app-domain';
|
||||
import { Config, Origin } from '../types/Config';
|
||||
import { Style } from '../types/Style';
|
||||
import { MediaType, MenuType } from '../types/WeChat';
|
||||
import { BackendRuntimeContext } from '../context/BackendRuntimeContext';
|
||||
import { MediaVideoDescription } from '../types/WeChat'
|
||||
|
|
@ -109,6 +110,14 @@ export type GeneralAspectDict<
|
|||
},
|
||||
context: Cxt
|
||||
) => Promise<void>;
|
||||
updateStyle: (
|
||||
params: {
|
||||
entity: 'platform' | 'system' | 'application';
|
||||
entityId: string;
|
||||
style: Style;
|
||||
},
|
||||
context: Cxt
|
||||
) => Promise<void>;
|
||||
updateApplicationConfig: (
|
||||
params: {
|
||||
entity: 'application';
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import {
|
|||
uploadWechatMedia,
|
||||
} from './application';
|
||||
import { updateConfig, updateApplicationConfig } from './config';
|
||||
import { updateStyle } from './style2';
|
||||
import { mergeUser, getChangePasswordChannels, updateUserPassword } from './user';
|
||||
import { createWechatLogin } from './wechatLogin';
|
||||
import { unbindingWechat } from './wechatUser';
|
||||
|
|
@ -55,6 +56,7 @@ const aspectDict = {
|
|||
sendCaptcha,
|
||||
getApplication,
|
||||
updateConfig,
|
||||
updateStyle,
|
||||
updateApplicationConfig,
|
||||
getWechatMpUserPhoneNumber,
|
||||
logout,
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue