build
This commit is contained in:
parent
de32625bfd
commit
fb6d793a4a
|
|
@ -207,13 +207,18 @@ export async function batchGetMaterialList(params, context) {
|
|||
dontCollect: true,
|
||||
});
|
||||
assert(application);
|
||||
const { type, config, systemId } = application;
|
||||
const { type, config } = application;
|
||||
assert(type === 'wechatPublic');
|
||||
let appId, appSecret;
|
||||
const config2 = config;
|
||||
appId = config2.appId;
|
||||
appSecret = config2.appSecret;
|
||||
const wechatInstance = WechatSDK.getInstance(appId, type, appSecret);
|
||||
const result = await wechatInstance.batchGetMaterialList(params);
|
||||
const { type: materialType, offset, count } = params;
|
||||
const result = await wechatInstance.batchGetMaterialList({
|
||||
type: materialType,
|
||||
offset,
|
||||
count,
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,6 @@ declare const _default: (props: import("oak-frontend-base").ReactComponentProps<
|
|||
executeText: string;
|
||||
buttonProps: {};
|
||||
afterCommit: () => void;
|
||||
beforeCommit: () => true;
|
||||
beforeCommit: () => boolean | undefined;
|
||||
}>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
||||
export default _default;
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ export default OakComponent({
|
|||
executeText: '',
|
||||
buttonProps: {},
|
||||
afterCommit: () => { },
|
||||
beforeCommit: () => true,
|
||||
beforeCommit: (() => true),
|
||||
},
|
||||
methods: {
|
||||
getEfIds() {
|
||||
|
|
@ -34,12 +34,17 @@ export default OakComponent({
|
|||
const { oakFullpath } = this.state;
|
||||
assert(efPaths && efPaths.length > 0);
|
||||
if (oakFullpath) {
|
||||
const ids = efPaths.map((path) => {
|
||||
const path2 = path ? `${oakFullpath}.${path}` : oakFullpath;
|
||||
const ids = efPaths
|
||||
.map((path) => {
|
||||
const path2 = path
|
||||
? `${oakFullpath}.${path}`
|
||||
: oakFullpath;
|
||||
const data = this.features.runningTree.getFreshValue(path2);
|
||||
assert(data, `efPath为${path}的路径上取不到extraFile数据,请设置正确的相对路径`);
|
||||
return data.map(ele => ele.id);
|
||||
}).flat().filter(ele => !!ele);
|
||||
return data.map((ele) => ele.id);
|
||||
})
|
||||
.flat()
|
||||
.filter((ele) => !!ele);
|
||||
return ids;
|
||||
}
|
||||
return [];
|
||||
|
|
|
|||
|
|
@ -242,10 +242,7 @@ export default OakComponent({
|
|||
});
|
||||
},
|
||||
async sendMessage() {
|
||||
const { text, wechatUserId, sessionMessageId } = this.state;
|
||||
const { sessionId, isEntity } = this.props;
|
||||
const userId = this.features.token.getUserId();
|
||||
const applicationId = this.features.application.getApplicationId();
|
||||
const { sessionMessageId } = this.state;
|
||||
this.updateItem({
|
||||
createTime: Date.now(),
|
||||
type: 'text',
|
||||
|
|
@ -262,7 +259,7 @@ export default OakComponent({
|
|||
const extension = name.substring(name.lastIndexOf('.') + 1);
|
||||
const filename = name.substring(0, name.lastIndexOf('.'));
|
||||
let origin = 'qiniu';
|
||||
//需要获取用户方回复的applicationId
|
||||
//需要获取用户方回复的applicationId,判断用户是否从微信公众号或小程序发起客服消息
|
||||
if (isEntity && userLastMessage?.wechatUserId) {
|
||||
applicationId = userLastMessage?.applicationId;
|
||||
origin = 'wechat';
|
||||
|
|
@ -279,6 +276,8 @@ export default OakComponent({
|
|||
entity: 'sessionMessage',
|
||||
objectId: generateNewId(),
|
||||
id: generateNewId(),
|
||||
uploadState: 'uploading',
|
||||
sort: 1000,
|
||||
};
|
||||
try {
|
||||
this.updateItem({
|
||||
|
|
@ -300,24 +299,24 @@ export default OakComponent({
|
|||
throw err;
|
||||
}
|
||||
},
|
||||
async createMessage() {
|
||||
const { text, wechatUserId } = this.state;
|
||||
const { sessionId, isEntity } = this.props;
|
||||
const userId = this.features.token.getUserId();
|
||||
const applicationId = this.features.application.getApplicationId();
|
||||
this.addItem({
|
||||
applicationId,
|
||||
text,
|
||||
userId,
|
||||
wechatUserId,
|
||||
sessionId: sessionId,
|
||||
type: 'text',
|
||||
createTime: Date.now(),
|
||||
aaoe: isEntity,
|
||||
});
|
||||
await this.execute(undefined, false);
|
||||
this.pageScroll('comment');
|
||||
},
|
||||
// async createMessage() {
|
||||
// const { text, wechatUserId } = this.state;
|
||||
// const { sessionId, isEntity } = this.props;
|
||||
// const userId = this.features.token.getUserId();
|
||||
// const applicationId = this.features.application.getApplicationId();
|
||||
// this.addItem({
|
||||
// applicationId,
|
||||
// text,
|
||||
// userId,
|
||||
// wechatUserId,
|
||||
// sessionId: sessionId,
|
||||
// type: 'text',
|
||||
// createTime: Date.now(),
|
||||
// aaoe: isEntity,
|
||||
// } as EntityDict['sessionMessage']['CreateSingle']['data']);
|
||||
// await this.execute(undefined, false);
|
||||
// this.pageScroll('comment');
|
||||
// },
|
||||
// async customUpload(file: {
|
||||
// name: string;
|
||||
// size: number;
|
||||
|
|
|
|||
|
|
@ -3,14 +3,11 @@ import { WebComponentProps, RowWithActions } from 'oak-frontend-base';
|
|||
import { EntityDict } from '../../../oak-app-domain';
|
||||
export default function Render(props: WebComponentProps<EntityDict, 'sessionMessage', true, {
|
||||
sessionMessages: EntityDict['sessionMessage']['Schema'][];
|
||||
text: string;
|
||||
buttonHidden: boolean;
|
||||
sessionId: string;
|
||||
isEntity: boolean;
|
||||
sessionMessageId: string;
|
||||
entityDisplay: (data: EntityDict['session']['Schema'][] | RowWithActions<EntityDict, 'session'>[]) => any[];
|
||||
entityProjection: object;
|
||||
isWeChat: boolean;
|
||||
}, {
|
||||
customUpload: (file: UploadFile) => void;
|
||||
setContent: (text: string) => void;
|
||||
|
|
|
|||
|
|
@ -129,7 +129,10 @@ export class ExtraFile2 extends Feature {
|
|||
const extraFileId = extraFile.id || generateNewId();
|
||||
await this.cache.operate('extraFile', {
|
||||
action: 'create',
|
||||
data: Object.assign(extraFile, { id: extraFileId, applicationId: this.application.getApplicationId() }),
|
||||
data: Object.assign(extraFile, {
|
||||
id: extraFileId,
|
||||
applicationId: this.application.getApplicationId(),
|
||||
}),
|
||||
id: await generateNewIdAsync(),
|
||||
});
|
||||
const [newExtraFile] = this.cache.get('extraFile', {
|
||||
|
|
@ -153,12 +156,12 @@ export class ExtraFile2 extends Feature {
|
|||
isBridge: 1,
|
||||
uploadState: 1,
|
||||
uploadMeta: 1,
|
||||
applicationId: 1,
|
||||
},
|
||||
filter: {
|
||||
id: extraFileId
|
||||
}
|
||||
id: extraFileId,
|
||||
},
|
||||
});
|
||||
console.log(newExtraFile);
|
||||
const up = new Upload();
|
||||
try {
|
||||
const cos = getCos(newExtraFile.origin);
|
||||
|
|
@ -170,7 +173,7 @@ export class ExtraFile2 extends Feature {
|
|||
action: 'remove',
|
||||
data: {},
|
||||
filter: {
|
||||
id: extraFileId
|
||||
id: extraFileId,
|
||||
},
|
||||
id: await generateNewIdAsync(),
|
||||
});
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ export default class Wechat {
|
|||
const url = '/uploadWechatMedia';
|
||||
result = (await uploadFn(file, 'file', url, {
|
||||
applicationId,
|
||||
type: 'image'
|
||||
}, true));
|
||||
}
|
||||
catch (err) {
|
||||
|
|
|
|||
|
|
@ -217,14 +217,19 @@ async function batchGetMaterialList(params, context) {
|
|||
dontCollect: true,
|
||||
});
|
||||
(0, assert_1.assert)(application);
|
||||
const { type, config, systemId } = application;
|
||||
const { type, config } = application;
|
||||
(0, assert_1.assert)(type === 'wechatPublic');
|
||||
let appId, appSecret;
|
||||
const config2 = config;
|
||||
appId = config2.appId;
|
||||
appSecret = config2.appSecret;
|
||||
const wechatInstance = oak_external_sdk_1.WechatSDK.getInstance(appId, type, appSecret);
|
||||
const result = await wechatInstance.batchGetMaterialList(params);
|
||||
const { type: materialType, offset, count } = params;
|
||||
const result = await wechatInstance.batchGetMaterialList({
|
||||
type: materialType,
|
||||
offset,
|
||||
count,
|
||||
});
|
||||
return result;
|
||||
}
|
||||
exports.batchGetMaterialList = batchGetMaterialList;
|
||||
|
|
|
|||
|
|
@ -8,6 +8,6 @@ declare const _default: (props: import("oak-frontend-base").ReactComponentProps<
|
|||
executeText: string;
|
||||
buttonProps: {};
|
||||
afterCommit: () => void;
|
||||
beforeCommit: () => true;
|
||||
beforeCommit: () => boolean | undefined;
|
||||
}>) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
||||
export default _default;
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ exports.default = OakComponent({
|
|||
executeText: '',
|
||||
buttonProps: {},
|
||||
afterCommit: () => { },
|
||||
beforeCommit: () => true,
|
||||
beforeCommit: (() => true),
|
||||
},
|
||||
methods: {
|
||||
getEfIds() {
|
||||
|
|
@ -37,12 +37,17 @@ exports.default = OakComponent({
|
|||
const { oakFullpath } = this.state;
|
||||
(0, assert_1.default)(efPaths && efPaths.length > 0);
|
||||
if (oakFullpath) {
|
||||
const ids = efPaths.map((path) => {
|
||||
const path2 = path ? `${oakFullpath}.${path}` : oakFullpath;
|
||||
const ids = efPaths
|
||||
.map((path) => {
|
||||
const path2 = path
|
||||
? `${oakFullpath}.${path}`
|
||||
: oakFullpath;
|
||||
const data = this.features.runningTree.getFreshValue(path2);
|
||||
(0, assert_1.default)(data, `efPath为${path}的路径上取不到extraFile数据,请设置正确的相对路径`);
|
||||
return data.map(ele => ele.id);
|
||||
}).flat().filter(ele => !!ele);
|
||||
return data.map((ele) => ele.id);
|
||||
})
|
||||
.flat()
|
||||
.filter((ele) => !!ele);
|
||||
return ids;
|
||||
}
|
||||
return [];
|
||||
|
|
|
|||
|
|
@ -244,10 +244,7 @@ exports.default = OakComponent({
|
|||
});
|
||||
},
|
||||
async sendMessage() {
|
||||
const { text, wechatUserId, sessionMessageId } = this.state;
|
||||
const { sessionId, isEntity } = this.props;
|
||||
const userId = this.features.token.getUserId();
|
||||
const applicationId = this.features.application.getApplicationId();
|
||||
const { sessionMessageId } = this.state;
|
||||
this.updateItem({
|
||||
createTime: Date.now(),
|
||||
type: 'text',
|
||||
|
|
@ -264,7 +261,7 @@ exports.default = OakComponent({
|
|||
const extension = name.substring(name.lastIndexOf('.') + 1);
|
||||
const filename = name.substring(0, name.lastIndexOf('.'));
|
||||
let origin = 'qiniu';
|
||||
//需要获取用户方回复的applicationId
|
||||
//需要获取用户方回复的applicationId,判断用户是否从微信公众号或小程序发起客服消息
|
||||
if (isEntity && userLastMessage?.wechatUserId) {
|
||||
applicationId = userLastMessage?.applicationId;
|
||||
origin = 'wechat';
|
||||
|
|
@ -281,6 +278,8 @@ exports.default = OakComponent({
|
|||
entity: 'sessionMessage',
|
||||
objectId: (0, uuid_1.generateNewId)(),
|
||||
id: (0, uuid_1.generateNewId)(),
|
||||
uploadState: 'uploading',
|
||||
sort: 1000,
|
||||
};
|
||||
try {
|
||||
this.updateItem({
|
||||
|
|
@ -302,24 +301,24 @@ exports.default = OakComponent({
|
|||
throw err;
|
||||
}
|
||||
},
|
||||
async createMessage() {
|
||||
const { text, wechatUserId } = this.state;
|
||||
const { sessionId, isEntity } = this.props;
|
||||
const userId = this.features.token.getUserId();
|
||||
const applicationId = this.features.application.getApplicationId();
|
||||
this.addItem({
|
||||
applicationId,
|
||||
text,
|
||||
userId,
|
||||
wechatUserId,
|
||||
sessionId: sessionId,
|
||||
type: 'text',
|
||||
createTime: Date.now(),
|
||||
aaoe: isEntity,
|
||||
});
|
||||
await this.execute(undefined, false);
|
||||
this.pageScroll('comment');
|
||||
},
|
||||
// async createMessage() {
|
||||
// const { text, wechatUserId } = this.state;
|
||||
// const { sessionId, isEntity } = this.props;
|
||||
// const userId = this.features.token.getUserId();
|
||||
// const applicationId = this.features.application.getApplicationId();
|
||||
// this.addItem({
|
||||
// applicationId,
|
||||
// text,
|
||||
// userId,
|
||||
// wechatUserId,
|
||||
// sessionId: sessionId,
|
||||
// type: 'text',
|
||||
// createTime: Date.now(),
|
||||
// aaoe: isEntity,
|
||||
// } as EntityDict['sessionMessage']['CreateSingle']['data']);
|
||||
// await this.execute(undefined, false);
|
||||
// this.pageScroll('comment');
|
||||
// },
|
||||
// async customUpload(file: {
|
||||
// name: string;
|
||||
// size: number;
|
||||
|
|
|
|||
|
|
@ -3,14 +3,11 @@ import { WebComponentProps, RowWithActions } from 'oak-frontend-base';
|
|||
import { EntityDict } from '../../../oak-app-domain';
|
||||
export default function Render(props: WebComponentProps<EntityDict, 'sessionMessage', true, {
|
||||
sessionMessages: EntityDict['sessionMessage']['Schema'][];
|
||||
text: string;
|
||||
buttonHidden: boolean;
|
||||
sessionId: string;
|
||||
isEntity: boolean;
|
||||
sessionMessageId: string;
|
||||
entityDisplay: (data: EntityDict['session']['Schema'][] | RowWithActions<EntityDict, 'session'>[]) => any[];
|
||||
entityProjection: object;
|
||||
isWeChat: boolean;
|
||||
}, {
|
||||
customUpload: (file: UploadFile) => void;
|
||||
setContent: (text: string) => void;
|
||||
|
|
|
|||
|
|
@ -132,7 +132,10 @@ class ExtraFile2 extends oak_frontend_base_1.Feature {
|
|||
const extraFileId = extraFile.id || (0, oak_domain_1.generateNewId)();
|
||||
await this.cache.operate('extraFile', {
|
||||
action: 'create',
|
||||
data: Object.assign(extraFile, { id: extraFileId, applicationId: this.application.getApplicationId() }),
|
||||
data: Object.assign(extraFile, {
|
||||
id: extraFileId,
|
||||
applicationId: this.application.getApplicationId(),
|
||||
}),
|
||||
id: await (0, oak_domain_1.generateNewIdAsync)(),
|
||||
});
|
||||
const [newExtraFile] = this.cache.get('extraFile', {
|
||||
|
|
@ -156,12 +159,12 @@ class ExtraFile2 extends oak_frontend_base_1.Feature {
|
|||
isBridge: 1,
|
||||
uploadState: 1,
|
||||
uploadMeta: 1,
|
||||
applicationId: 1,
|
||||
},
|
||||
filter: {
|
||||
id: extraFileId
|
||||
}
|
||||
id: extraFileId,
|
||||
},
|
||||
});
|
||||
console.log(newExtraFile);
|
||||
const up = new upload_1.Upload();
|
||||
try {
|
||||
const cos = (0, cos_1.getCos)(newExtraFile.origin);
|
||||
|
|
@ -173,7 +176,7 @@ class ExtraFile2 extends oak_frontend_base_1.Feature {
|
|||
action: 'remove',
|
||||
data: {},
|
||||
filter: {
|
||||
id: extraFileId
|
||||
id: extraFileId,
|
||||
},
|
||||
id: await (0, oak_domain_1.generateNewIdAsync)(),
|
||||
});
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ const assert_1 = require("oak-domain/lib/utils/assert");
|
|||
const getContextConfig_1 = require("../getContextConfig");
|
||||
const Exception_1 = require("../../types/Exception");
|
||||
const oak_domain_1 = require("oak-domain");
|
||||
const QiniuSearchUrl = 'https://rs.qiniuapi.com/stat/EncodedEntryURI';
|
||||
class Qiniu {
|
||||
name = 'qiniu';
|
||||
autoInform() {
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ class Wechat {
|
|||
const url = '/uploadWechatMedia';
|
||||
result = (await uploadFn(file, 'file', url, {
|
||||
applicationId,
|
||||
type: 'image'
|
||||
}, true));
|
||||
}
|
||||
catch (err) {
|
||||
|
|
|
|||
|
|
@ -384,7 +384,7 @@ export async function batchGetMaterialList<
|
|||
}
|
||||
);
|
||||
assert(application);
|
||||
const { type, config, systemId } = application!;
|
||||
const { type, config } = application!;
|
||||
assert(type === 'wechatPublic');
|
||||
let appId: string, appSecret: string;
|
||||
const config2 = config as WechatPublicConfig;
|
||||
|
|
@ -395,6 +395,11 @@ export async function batchGetMaterialList<
|
|||
type!,
|
||||
appSecret!
|
||||
) as WechatPublicInstance;
|
||||
const result = await wechatInstance.batchGetMaterialList(params);
|
||||
const { type: materialType, offset, count } = params;
|
||||
const result = await wechatInstance.batchGetMaterialList({
|
||||
type: materialType,
|
||||
offset,
|
||||
count,
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ export default OakComponent({
|
|||
executeText: '',
|
||||
buttonProps: {},
|
||||
afterCommit: () => {},
|
||||
beforeCommit: () => true,
|
||||
beforeCommit: (() => true) as () => boolean | undefined,
|
||||
},
|
||||
methods: {
|
||||
getEfIds() {
|
||||
|
|
@ -36,18 +36,23 @@ export default OakComponent({
|
|||
const { oakFullpath } = this.state;
|
||||
assert(efPaths && efPaths.length > 0);
|
||||
if (oakFullpath) {
|
||||
const ids = efPaths.map(
|
||||
(path) => {
|
||||
const path2 = path ? `${oakFullpath}.${path}` : oakFullpath;
|
||||
const data = this.features.runningTree.getFreshValue(path2);
|
||||
assert(data, `efPath为${path}的路径上取不到extraFile数据,请设置正确的相对路径`);
|
||||
return (data as EntityDict['extraFile']['OpSchema'][]).map(
|
||||
ele => ele.id
|
||||
const ids = efPaths
|
||||
.map((path) => {
|
||||
const path2 = path
|
||||
? `${oakFullpath}.${path}`
|
||||
: oakFullpath;
|
||||
const data =
|
||||
this.features.runningTree.getFreshValue(path2);
|
||||
assert(
|
||||
data,
|
||||
`efPath为${path}的路径上取不到extraFile数据,请设置正确的相对路径`
|
||||
);
|
||||
}
|
||||
).flat().filter(
|
||||
ele => !!ele
|
||||
) as string[];
|
||||
return (
|
||||
data as EntityDict['extraFile']['OpSchema'][]
|
||||
).map((ele) => ele.id);
|
||||
})
|
||||
.flat()
|
||||
.filter((ele) => !!ele) as string[];
|
||||
return ids;
|
||||
}
|
||||
return [];
|
||||
|
|
|
|||
|
|
@ -271,10 +271,7 @@ export default OakComponent({
|
|||
},
|
||||
|
||||
async sendMessage() {
|
||||
const { text, wechatUserId, sessionMessageId } = this.state;
|
||||
const { sessionId, isEntity } = this.props;
|
||||
const userId = this.features.token.getUserId();
|
||||
const applicationId = this.features.application.getApplicationId();
|
||||
const { sessionMessageId } = this.state;
|
||||
|
||||
this.updateItem(
|
||||
{
|
||||
|
|
@ -302,11 +299,10 @@ export default OakComponent({
|
|||
const extension = name.substring(name.lastIndexOf('.') + 1);
|
||||
const filename = name.substring(0, name.lastIndexOf('.'));
|
||||
|
||||
let origin = 'qiniu';
|
||||
//需要获取用户方回复的applicationId
|
||||
let origin: EntityDict['extraFile']['Schema']['origin'] = 'qiniu';
|
||||
//需要获取用户方回复的applicationId,判断用户是否从微信公众号或小程序发起客服消息
|
||||
if (isEntity && userLastMessage?.wechatUserId) {
|
||||
applicationId = userLastMessage?.applicationId;
|
||||
|
||||
origin = 'wechat';
|
||||
}
|
||||
|
||||
|
|
@ -322,6 +318,8 @@ export default OakComponent({
|
|||
entity: 'sessionMessage',
|
||||
objectId: generateNewId(),
|
||||
id: generateNewId(),
|
||||
uploadState: 'uploading',
|
||||
sort: 1000,
|
||||
} as EntityDict['extraFile']['CreateSingle']['data'];
|
||||
|
||||
try {
|
||||
|
|
@ -350,25 +348,25 @@ export default OakComponent({
|
|||
}
|
||||
},
|
||||
|
||||
async createMessage() {
|
||||
const { text, wechatUserId } = this.state;
|
||||
const { sessionId, isEntity } = this.props;
|
||||
const userId = this.features.token.getUserId();
|
||||
const applicationId = this.features.application.getApplicationId();
|
||||
// async createMessage() {
|
||||
// const { text, wechatUserId } = this.state;
|
||||
// const { sessionId, isEntity } = this.props;
|
||||
// const userId = this.features.token.getUserId();
|
||||
// const applicationId = this.features.application.getApplicationId();
|
||||
|
||||
this.addItem({
|
||||
applicationId,
|
||||
text,
|
||||
userId,
|
||||
wechatUserId,
|
||||
sessionId: sessionId,
|
||||
type: 'text',
|
||||
createTime: Date.now(),
|
||||
aaoe: isEntity,
|
||||
} as EntityDict['sessionMessage']['CreateSingle']['data']);
|
||||
await this.execute(undefined, false);
|
||||
this.pageScroll('comment');
|
||||
},
|
||||
// this.addItem({
|
||||
// applicationId,
|
||||
// text,
|
||||
// userId,
|
||||
// wechatUserId,
|
||||
// sessionId: sessionId,
|
||||
// type: 'text',
|
||||
// createTime: Date.now(),
|
||||
// aaoe: isEntity,
|
||||
// } as EntityDict['sessionMessage']['CreateSingle']['data']);
|
||||
// await this.execute(undefined, false);
|
||||
// this.pageScroll('comment');
|
||||
// },
|
||||
|
||||
// async customUpload(file: {
|
||||
// name: string;
|
||||
|
|
|
|||
|
|
@ -10,13 +10,6 @@ import Style from './web.module.less';
|
|||
import { WebComponentProps, RowWithActions } from 'oak-frontend-base';
|
||||
import { EntityDict } from '../../../oak-app-domain';
|
||||
|
||||
interface customFile {
|
||||
name: string;
|
||||
size: number;
|
||||
type: string;
|
||||
originFileObj: File;
|
||||
}
|
||||
|
||||
export default function Render(
|
||||
props: WebComponentProps<
|
||||
EntityDict,
|
||||
|
|
@ -24,8 +17,6 @@ export default function Render(
|
|||
true,
|
||||
{
|
||||
sessionMessages: EntityDict['sessionMessage']['Schema'][];
|
||||
text: string;
|
||||
buttonHidden: boolean;
|
||||
sessionId: string;
|
||||
isEntity: boolean;
|
||||
sessionMessageId: string;
|
||||
|
|
@ -35,7 +26,6 @@ export default function Render(
|
|||
| RowWithActions<EntityDict, 'session'>[]
|
||||
) => any[];
|
||||
entityProjection: object;
|
||||
isWeChat: boolean;
|
||||
},
|
||||
{
|
||||
customUpload: (file: UploadFile) => void;
|
||||
|
|
|
|||
|
|
@ -26,11 +26,14 @@ export class ExtraFile2<
|
|||
private cache: Cache<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>;
|
||||
private application: Application<ED, Cxt, FrontCxt, AD>;
|
||||
private locales: Locales<ED, Cxt, FrontCxt, AD>;
|
||||
private files: Record<string, {
|
||||
file: File | string;
|
||||
state: FileState;
|
||||
percentage?: number;
|
||||
}>;
|
||||
private files: Record<
|
||||
string,
|
||||
{
|
||||
file: File | string;
|
||||
state: FileState;
|
||||
percentage?: number;
|
||||
}
|
||||
>;
|
||||
|
||||
constructor(
|
||||
cache: Cache<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>,
|
||||
|
|
@ -54,9 +57,7 @@ export class ExtraFile2<
|
|||
}
|
||||
|
||||
removeLocalFiles(ids: string[]) {
|
||||
ids.forEach(
|
||||
(id) => unset(this.files, id)
|
||||
);
|
||||
ids.forEach((id) => unset(this.files, id));
|
||||
this.publish();
|
||||
}
|
||||
|
||||
|
|
@ -98,11 +99,7 @@ export class ExtraFile2<
|
|||
const up = new Upload();
|
||||
try {
|
||||
const cos = getCos<ED, Cxt, FrontCxt>(extraFile.origin!);
|
||||
await cos.upload(
|
||||
extraFile as OpSchema,
|
||||
up.uploadFile,
|
||||
file
|
||||
);
|
||||
await cos.upload(extraFile as OpSchema, up.uploadFile, file);
|
||||
if (!cos.autoInform()) {
|
||||
/* await this.cache.exec('operate', {
|
||||
entity: 'extraFile',
|
||||
|
|
@ -144,8 +141,7 @@ export class ExtraFile2<
|
|||
const { file } = this.files[id];
|
||||
if (file instanceof File) {
|
||||
return getFileURL(file);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return file;
|
||||
}
|
||||
}
|
||||
|
|
@ -156,10 +152,12 @@ export class ExtraFile2<
|
|||
return cos.composeFileUrl(extraFile, context, style);
|
||||
}
|
||||
|
||||
getFileState(id: string): {
|
||||
state: FileState;
|
||||
percentage?: number;
|
||||
} | undefined {
|
||||
getFileState(id: string):
|
||||
| {
|
||||
state: FileState;
|
||||
percentage?: number;
|
||||
}
|
||||
| undefined {
|
||||
if (this.files[id]) {
|
||||
return this.files[id];
|
||||
}
|
||||
|
|
@ -177,58 +175,59 @@ export class ExtraFile2<
|
|||
return bytesToSize(size);
|
||||
}
|
||||
|
||||
async autoUpload(extraFile: EntityDict['extraFile']['OpSchema'], file: File | string) {
|
||||
async autoUpload(
|
||||
extraFile: EntityDict['extraFile']['OpSchema'],
|
||||
file: File | string
|
||||
) {
|
||||
const extraFileId = extraFile.id || generateNewId();
|
||||
await this.cache.operate('extraFile', {
|
||||
action: 'create',
|
||||
data: Object.assign(extraFile, { id: extraFileId, applicationId: this.application.getApplicationId() }),
|
||||
data: Object.assign(extraFile, {
|
||||
id: extraFileId,
|
||||
applicationId: this.application.getApplicationId(),
|
||||
}),
|
||||
id: await generateNewIdAsync(),
|
||||
} as EntityDict['extraFile']['Operation']);
|
||||
const [newExtraFile] = this.cache.get(
|
||||
'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: {
|
||||
id: extraFileId
|
||||
}
|
||||
}
|
||||
);
|
||||
console.log(newExtraFile);
|
||||
const [newExtraFile] = this.cache.get('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,
|
||||
applicationId: 1,
|
||||
},
|
||||
filter: {
|
||||
id: extraFileId,
|
||||
},
|
||||
});
|
||||
const up = new Upload();
|
||||
try {
|
||||
const cos = getCos<ED, Cxt, FrontCxt>(newExtraFile.origin!);
|
||||
await cos.upload(
|
||||
newExtraFile as OpSchema,
|
||||
up.uploadFile,
|
||||
file
|
||||
await cos.upload(newExtraFile as OpSchema, up.uploadFile, file);
|
||||
return this.getUrl(
|
||||
newExtraFile as EntityDict['extraFile']['Schema']
|
||||
);
|
||||
return this.getUrl(newExtraFile as EntityDict['extraFile']['Schema']);
|
||||
} catch (err) {
|
||||
await this.cache.operate('extraFile', {
|
||||
action: 'remove',
|
||||
data: {},
|
||||
filter: {
|
||||
id: extraFileId
|
||||
id: extraFileId,
|
||||
},
|
||||
id: await generateNewIdAsync(),
|
||||
} as EntityDict['extraFile']['Operation']);
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ export default class Wechat implements Cos<ED, BRC, FRC> {
|
|||
url,
|
||||
{
|
||||
applicationId,
|
||||
type: 'image'
|
||||
},
|
||||
true
|
||||
)) as response;
|
||||
|
|
|
|||
Loading…
Reference in New Issue