extraFileUpsert
This commit is contained in:
parent
4d9cd11ac7
commit
7936ded926
|
|
@ -1,6 +1,6 @@
|
|||
import { String, Text } from 'oak-domain/lib/types/DataType';
|
||||
import { EntityShape } from 'oak-domain/lib/types/Entity';
|
||||
export interface Schema extends EntityShape {
|
||||
import { FileCarrierEntityShape } from 'oak-domain/lib/types/Entity';
|
||||
export interface Schema extends FileCarrierEntityShape {
|
||||
origin: 'qiniu' | 'unknown';
|
||||
type: 'image' | 'pdf' | 'video' | 'audio' | 'file';
|
||||
bucket: String<16>;
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
import { OpSchema as ExtraFile } from 'oak-app-domain/ExtraFile/Schema';
|
||||
export declare function composeFileUrl(extraFile: ExtraFile): string;
|
||||
export declare function composeFileUrl(extraFile: Pick<ExtraFile, 'type' | 'bucket' | 'filename' | 'origin' | 'extra1'>): string;
|
||||
export declare function decomposeFileUrl(url: string): Pick<ExtraFile, 'bucket' | 'filename' | 'origin' | 'type' | 'extra1'>;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { OpSchema as ExtraFile } from 'oak-app-domain/ExtraFile/Schema';
|
||||
|
||||
export function composeFileUrl(extraFile: ExtraFile) {
|
||||
export function composeFileUrl(extraFile: Pick<ExtraFile, 'type' | 'bucket' | 'filename' | 'origin' | 'extra1'>) {
|
||||
const { type, bucket, filename, origin, extra1 } = extraFile;
|
||||
if (origin === 'unknown') {
|
||||
// 未知第三方源
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@
|
|||
"node_modules",
|
||||
"**/*.spec.ts",
|
||||
"test",
|
||||
"scripts",/*
|
||||
"wechatMp" */
|
||||
"scripts",
|
||||
"wechatMp"
|
||||
]
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
{
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
/** index.wxss **/
|
||||
.container {
|
||||
display: block;
|
||||
}
|
||||
|
||||
|
|
@ -1,17 +1,22 @@
|
|||
import assert from 'assert';
|
||||
import { WechatMpFileCarrier } from 'oak-frontend-base';
|
||||
import { composeFileUrl } from '../../../../src/utils/extraFile';
|
||||
OakComponent({
|
||||
entity: 'extraFile',
|
||||
formData: async (_rows, _features, _fileCarrier) => {
|
||||
return {
|
||||
name: 1,
|
||||
if (_fileCarrier) {
|
||||
return {
|
||||
src: '11',
|
||||
};
|
||||
}
|
||||
else {
|
||||
assert(_rows);
|
||||
return {
|
||||
src: composeFileUrl(_rows[0]!),
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
methods: {
|
||||
async onFilePicked() {
|
||||
const fileCarrier = new WechatMpFileCarrier();
|
||||
|
||||
this.setFileCarrier(fileCarrier);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
<!-- index.wxml -->
|
||||
<view class="container">
|
||||
<image src="{{src}}" mode="aspectFit" />
|
||||
</view>
|
||||
|
|
@ -23,6 +23,7 @@ OakPage({
|
|||
objectId: 1,
|
||||
filename: 1,
|
||||
extra1: 1,
|
||||
type: 1,
|
||||
},
|
||||
filter: {
|
||||
tag1: 'avatar',
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ OakPage({
|
|||
objectId: 1,
|
||||
filename: 1,
|
||||
extra1: 1,
|
||||
type: 1,
|
||||
},
|
||||
filter: {
|
||||
tag1: 'avatar',
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ OakPage({
|
|||
objectId: 1,
|
||||
filename: 1,
|
||||
extra1: 1,
|
||||
type: 1,
|
||||
},
|
||||
filter: {
|
||||
tag1: 'avatar',
|
||||
|
|
|
|||
Loading…
Reference in New Issue