extraFileUpsert

This commit is contained in:
Xu Chang 2022-05-17 11:57:16 +08:00
parent 4d9cd11ac7
commit 7936ded926
11 changed files with 32 additions and 13 deletions

View File

@ -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>;

View File

@ -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'>;

View File

@ -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') {
// 未知第三方源

View File

@ -77,7 +77,7 @@
"node_modules",
"**/*.spec.ts",
"test",
"scripts",/*
"wechatMp" */
"scripts",
"wechatMp"
]
}

View File

@ -0,0 +1,2 @@
{
}

View File

@ -0,0 +1,5 @@
/** index.wxss **/
.container {
display: block;
}

View File

@ -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);
}
}
});

View File

@ -0,0 +1,4 @@
<!-- index.wxml -->
<view class="container">
<image src="{{src}}" mode="aspectFit" />
</view>

View File

@ -23,6 +23,7 @@ OakPage({
objectId: 1,
filename: 1,
extra1: 1,
type: 1,
},
filter: {
tag1: 'avatar',

View File

@ -21,6 +21,7 @@ OakPage({
objectId: 1,
filename: 1,
extra1: 1,
type: 1,
},
filter: {
tag1: 'avatar',

View File

@ -20,6 +20,7 @@ OakPage({
objectId: 1,
filename: 1,
extra1: 1,
type: 1,
},
filter: {
tag1: 'avatar',