resolver-egretimp-plus 0.1.27 → 0.1.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "resolver-egretimp-plus",
3
- "version": "0.1.27",
3
+ "version": "0.1.28",
4
4
  "description": "交付体验渲染",
5
5
  "main": "./dist/web/index.js",
6
6
  "module": "./dist/web/index.js",
package/src/renderer.jsx CHANGED
@@ -40,6 +40,7 @@ export default {
40
40
  emit('update:modelValue', val)
41
41
  }
42
42
  })
43
+ const messageInstance = inject('_messageInstance')
43
44
  const getNativeComps = inject('_getNativeComps')
44
45
  const loadModuleCache = inject('_loadModuleCache')
45
46
  const _isH5 = inject('_isH5')
@@ -63,7 +64,7 @@ export default {
63
64
  return null
64
65
  }
65
66
  const disabled = calcDisable(config, modelRef.value)
66
- const component = getComponentForConfig({config, disabled, getNativeComps, isH5: _isH5?.value, loadModuleCache})
67
+ const component = getComponentForConfig({messageInstance: messageInstance?.value, config, disabled, getNativeComps, isH5: _isH5?.value, loadModuleCache})
67
68
  if (component) {
68
69
  const layoutPolyfill = generateLayoutPolyfill(config, disabled, _isH5?.value) // // 生成布局框(col)的辅助函数
69
70
  return layoutPolyfill(
@@ -4,6 +4,9 @@ import * as Router from 'vue-router'
4
4
  import { buildInRequest } from './request'
5
5
  import { FIND_FILEA_NND_CONENT_BY_ID } from '../api/builtIn'
6
6
  import { resultToast } from './respone'
7
+ let messageInstance = null
8
+
9
+ const fileCache = new Map()
7
10
 
8
11
  const options = {
9
12
  moduleCache: {
@@ -11,15 +14,23 @@ const options = {
11
14
  'vue-router': Router,
12
15
  },
13
16
  async getFile(url) {
14
- return buildInRequest(FIND_FILEA_NND_CONENT_BY_ID, {fileId: url?.originVal?.() || url}).then(ret => {
15
- if (resultToast(ret.data)) {
16
- return ret.data.result?.content
17
- } else {
17
+ const fileId = url?.originVal?.() || url
18
+ if (!fileId) {
19
+ messageInstance?.error('custom component fileId empty!')
20
+ return
21
+ }
22
+ if (!fileCache.has(fileId)) {
23
+ fileCache.set(fileId, buildInRequest(FIND_FILEA_NND_CONENT_BY_ID, {fileId}).then(ret => {
24
+ if (resultToast(ret.data, messageInstance)) {
25
+ return ret.data.result?.content
26
+ } else {
27
+ return ''
28
+ }
29
+ }).catch(() => {
18
30
  return ''
19
- }
20
- }).catch(() => {
21
- return ''
22
- })
31
+ }))
32
+ }
33
+ return fileCache.get(fileId)
23
34
  },
24
35
 
25
36
  addStyle(textContent) {
@@ -52,7 +63,8 @@ const options = {
52
63
  }
53
64
  }
54
65
 
55
- export default function(url, moduleCache) {
66
+ export default function(url, moduleCache, _messageInstance) {
67
+ messageInstance = _messageInstance
56
68
  options.moduleCache['resolver-egretimp-plus'] = window['resolver-egretimp-plus']
57
69
  options.moduleCache['resolver-egretimp-plus/h5'] = window['resolver-egretimp-plus']
58
70
  options.moduleCache['resolver-egretimp-plus/web'] = window['resolver-egretimp-plus']
@@ -409,9 +409,9 @@ export function isPlainColumn(config, disabled) {
409
409
  return false
410
410
  }
411
411
 
412
- export function getComponentForConfig({config, disabled, getNativeComps, loadModuleCache}) {
412
+ export function getComponentForConfig({messageInstance, config, disabled, getNativeComps, loadModuleCache}) {
413
413
  if (config.isCustom) {
414
- return () => loadModule(generateVuePath(config.fileId), loadModuleCache)
414
+ return () => loadModule(generateVuePath(config.fileId), loadModuleCache, messageInstance)
415
415
  }
416
416
  // 表格中中的列,是否需要转换为普通形式
417
417
  if (isPlainColumn(config, disabled)) {