From 39bf18035f7f8d3781c419f1291270ece3b79acb Mon Sep 17 00:00:00 2001 From: Xc Date: Wed, 18 May 2022 20:25:17 +0800 Subject: [PATCH] file-lst --- src/typings/polyfill.d.ts | 2 +- src/utils/extraFile.ts | 4 ++-- tsconfig.json | 4 ++-- .../{file-selector => file-list}/index.json | 0 .../{file-selector => file-list}/index.less | 0 .../{file-selector => file-list}/index.ts | 21 +++++++--------- .../{file-selector => file-list}/index.wxml | 0 .../extraFile/{upsert => display}/index.json | 0 .../extraFile/{upsert => display}/index.less | 0 .../components/extraFile/display/index.ts | 17 +++++++++++++ .../extraFile/{upsert => display}/index.wxml | 0 wechatMp/components/extraFile/upsert/index.ts | 24 ------------------- 12 files changed, 31 insertions(+), 41 deletions(-) rename wechatMp/components/Func/{file-selector => file-list}/index.json (100%) rename wechatMp/components/Func/{file-selector => file-list}/index.less (100%) rename wechatMp/components/Func/{file-selector => file-list}/index.ts (86%) rename wechatMp/components/Func/{file-selector => file-list}/index.wxml (100%) rename wechatMp/components/extraFile/{upsert => display}/index.json (100%) rename wechatMp/components/extraFile/{upsert => display}/index.less (100%) create mode 100644 wechatMp/components/extraFile/display/index.ts rename wechatMp/components/extraFile/{upsert => display}/index.wxml (100%) delete mode 100644 wechatMp/components/extraFile/upsert/index.ts diff --git a/src/typings/polyfill.d.ts b/src/typings/polyfill.d.ts index cc56389c7..403d78af3 100644 --- a/src/typings/polyfill.d.ts +++ b/src/typings/polyfill.d.ts @@ -7,6 +7,6 @@ import { initialize } from '../features'; declare global { const OakPage: MakeOakPage, typeof aspectDict, ReturnType>; const OakComponent: MakeOakComponent, typeof aspectDict, ReturnType>; - const generateNewId: () => Promise; + const generateNewId: (options?: { timestamp?: boolean }) => Promise; } export {} \ No newline at end of file diff --git a/src/utils/extraFile.ts b/src/utils/extraFile.ts index 4d2020358..0ba01f9eb 100644 --- a/src/utils/extraFile.ts +++ b/src/utils/extraFile.ts @@ -2,8 +2,8 @@ import { OpSchema as ExtraFile } from 'oak-app-domain/ExtraFile/Schema'; export function composeFileUrl(extraFile: Pick) { const { type, bucket, filename, origin, extra1 } = extraFile; - if (origin === 'unknown') { - // 未知第三方源 + if (extra1) { + // 有extra1就用extra1 return extra1!; } return ''; diff --git a/tsconfig.json b/tsconfig.json index 36ebcc2f7..991a93201 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -77,7 +77,7 @@ "node_modules", "**/*.spec.ts", "test", - "scripts", - "wechatMp" + "scripts",/* + "wechatMp" */ ] } \ No newline at end of file diff --git a/wechatMp/components/Func/file-selector/index.json b/wechatMp/components/Func/file-list/index.json similarity index 100% rename from wechatMp/components/Func/file-selector/index.json rename to wechatMp/components/Func/file-list/index.json diff --git a/wechatMp/components/Func/file-selector/index.less b/wechatMp/components/Func/file-list/index.less similarity index 100% rename from wechatMp/components/Func/file-selector/index.less rename to wechatMp/components/Func/file-list/index.less diff --git a/wechatMp/components/Func/file-selector/index.ts b/wechatMp/components/Func/file-list/index.ts similarity index 86% rename from wechatMp/components/Func/file-selector/index.ts rename to wechatMp/components/Func/file-list/index.ts index 9a3694741..d69bb6cb6 100644 --- a/wechatMp/components/Func/file-selector/index.ts +++ b/wechatMp/components/Func/file-list/index.ts @@ -36,15 +36,14 @@ Component({ sourceType, }); if (errMsg !== 'chooseMedia:ok') { - this.setData({ - oakError: { - level: 'warning', - msg: errMsg, - }, + this.triggerEvent('error', { + level: 'warning', + msg: errMsg, }); } else { - const { globalData: { features } } = getApp(); + this.triggerEvent('add', tempFiles); + /* const { globalData: { features } } = getApp(); const { oakFullpath } = this.data; for (const file of tempFiles) { await features.runningNode.addNode({ @@ -52,16 +51,14 @@ Component({ fileCarrier: new WechatMpFileCarrier(file), updateData: oakUpdateData, }); - } + } */ } } catch (err: any) { if (err.errMsg !== 'chooseMedia:fail cancel') { - this.setData({ - oakError: { - level: 'error', - msg: err.errMsg, - }, + this.triggerEvent('error', { + level: 'error', + msg: err.errMsg, }); } } diff --git a/wechatMp/components/Func/file-selector/index.wxml b/wechatMp/components/Func/file-list/index.wxml similarity index 100% rename from wechatMp/components/Func/file-selector/index.wxml rename to wechatMp/components/Func/file-list/index.wxml diff --git a/wechatMp/components/extraFile/upsert/index.json b/wechatMp/components/extraFile/display/index.json similarity index 100% rename from wechatMp/components/extraFile/upsert/index.json rename to wechatMp/components/extraFile/display/index.json diff --git a/wechatMp/components/extraFile/upsert/index.less b/wechatMp/components/extraFile/display/index.less similarity index 100% rename from wechatMp/components/extraFile/upsert/index.less rename to wechatMp/components/extraFile/display/index.less diff --git a/wechatMp/components/extraFile/display/index.ts b/wechatMp/components/extraFile/display/index.ts new file mode 100644 index 000000000..6de752d33 --- /dev/null +++ b/wechatMp/components/extraFile/display/index.ts @@ -0,0 +1,17 @@ +import assert from 'assert'; +import { EntityDict } from 'oak-app-domain'; +import { WechatMpFileCarrier } from 'oak-frontend-base'; +import { composeFileUrl } from '../../../../src/utils/extraFile'; +OakComponent({ + entity: 'extraFile', + formData: async (_rows, _features) => { + return { + src: composeFileUrl(_rows[0]!), + } + } +}, { + methods: { + }, + lifetimes: { + } +}); \ No newline at end of file diff --git a/wechatMp/components/extraFile/upsert/index.wxml b/wechatMp/components/extraFile/display/index.wxml similarity index 100% rename from wechatMp/components/extraFile/upsert/index.wxml rename to wechatMp/components/extraFile/display/index.wxml diff --git a/wechatMp/components/extraFile/upsert/index.ts b/wechatMp/components/extraFile/upsert/index.ts deleted file mode 100644 index 4cf668ed2..000000000 --- a/wechatMp/components/extraFile/upsert/index.ts +++ /dev/null @@ -1,24 +0,0 @@ -import assert from 'assert'; -import { EntityDict } from 'oak-app-domain'; -import { WechatMpFileCarrier } from 'oak-frontend-base'; -import { composeFileUrl } from '../../../../src/utils/extraFile'; -OakComponent({ - entity: 'extraFile', - formData: async (_rows, _features, _fileCarrier) => { - if (_fileCarrier) { - const file = (>_fileCarrier).getFile(); - return { - src: file.tempFilePath || file.thumbTempFilePath, - }; - } - else { - assert(_rows); - return { - src: composeFileUrl(_rows[0]!), - } - } - } -}, { - methods: { - } -}); \ No newline at end of file