@steedos-widgets/amis-lib 6.3.11-beta.7 → 6.3.11-beta.9

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/dist/index.esm.js CHANGED
@@ -388,18 +388,24 @@ const Router = {
388
388
  /*
389
389
  * @Author: baozhoutao@steedos.com
390
390
  * @Date: 2022-07-20 16:29:22
391
- * @LastEditors: liaodaxue
392
- * @LastEditTime: 2024-01-25 14:44:17
391
+ * @LastEditors: baozhoutao@steedos.com
392
+ * @LastEditTime: 2024-10-14 13:33:27
393
393
  * @Description:
394
394
  */
395
395
 
396
- function getImageFieldUrl(url) {
397
- if (window.Meteor && window.Meteor.isCordova != true) {
398
- // '//'的位置
399
- const doubleSlashIndex = url.indexOf('//');
400
- const urlIndex = url.indexOf('/', doubleSlashIndex + 2);
401
- const rootUrl = url.substring(urlIndex);
402
- return rootUrl;
396
+ function getImageFieldUrl(url, readonly) {
397
+ if (window.Meteor) {
398
+ if(window.Meteor.isCordova != true){
399
+ // '//'的位置
400
+ const doubleSlashIndex = url.indexOf('//');
401
+ const urlIndex = url.indexOf('/', doubleSlashIndex + 2);
402
+ const rootUrl = url.substring(urlIndex);
403
+ return rootUrl;
404
+ }else {
405
+ if(readonly || url.startsWith('http')){
406
+ return `${url}?token=${window.btoa(JSON.stringify({ authToken : Builder.settings.context.authToken }))}`
407
+ }
408
+ }
403
409
  }
404
410
  return url;
405
411
  }
@@ -906,12 +912,12 @@ function getScriptForRemoveUrlPrefixForImgFields(fields){
906
912
  if(imgFieldValue instanceof Array){
907
913
  formData[item] = imgFieldValue.map((value)=>{
908
914
  let itemValue = value && value.split('/');
909
- return itemValue[itemValue.length - 1];
915
+ return itemValue[itemValue.length - 1].split('?')[0];
910
916
  });
911
917
  }
912
918
  }else{
913
919
  let imgValue = imgFieldValue.split('/');
914
- formData[item] = imgValue[imgValue.length - 1];
920
+ formData[item] = imgValue[imgValue.length - 1].split('?')[0];
915
921
  }
916
922
  }
917
923
  })
@@ -1191,7 +1197,7 @@ async function getPage({type, pageId = '', appId, objectName = '', recordId = ''
1191
1197
  * @Author: baozhoutao@steedos.com
1192
1198
  * @Date: 2022-10-28 14:15:09
1193
1199
  * @LastEditors: baozhoutao@steedos.com
1194
- * @LastEditTime: 2024-08-19 16:26:58
1200
+ * @LastEditTime: 2024-10-14 14:01:15
1195
1201
  * @Description:
1196
1202
  */
1197
1203
 
@@ -1289,13 +1295,13 @@ const getAmisFileReadonlySchema = async (steedosField,ctx = {})=>{
1289
1295
  if(type === 'file'){
1290
1296
  return window.Meteor?.isCordova ? {
1291
1297
  "type": "control",
1292
- "body": {
1298
+ "body": steedosField.multiple ? {
1293
1299
  "type": "each",
1294
1300
  "name": "_display." + steedosField.name,
1295
1301
  "items": {
1296
1302
  "type": "tpl",
1297
1303
  "tpl": "${name}",
1298
- "className": "antd-Button--link inline-block",
1304
+ "className": "antd-Button--link inline-block mr-2",
1299
1305
  "onEvent": {
1300
1306
  "click": {
1301
1307
  "actions": [
@@ -1310,6 +1316,24 @@ const getAmisFileReadonlySchema = async (steedosField,ctx = {})=>{
1310
1316
  }
1311
1317
  }
1312
1318
  }
1319
+ } : {
1320
+ "type": "tpl",
1321
+ "tpl": "${_display." + steedosField.name + ".name}",
1322
+ "className": "antd-Button--link inline-block",
1323
+ "onEvent": {
1324
+ "click": {
1325
+ "actions": [
1326
+ {
1327
+ "script": `
1328
+ const data = event.data._display.${steedosField.name};
1329
+ Steedos.cordovaDownload(encodeURI(data.url), data.name);
1330
+ `,
1331
+ "actionType": "custom"
1332
+ }
1333
+ ],
1334
+ "weight": 0
1335
+ }
1336
+ }
1313
1337
  }
1314
1338
  } : {
1315
1339
  // type: amisFieldType,
@@ -3475,7 +3499,7 @@ function getReadonlyFormAdaptor(object, fields, options){
3475
3499
  var gridAndObjectFieldsName = ${JSON.stringify(gridAndObjectFieldsName)};
3476
3500
  try{
3477
3501
  ${scriptStr}
3478
- ${getScriptForAddUrlPrefixForImgFields(fields)}
3502
+ ${getScriptForAddUrlPrefixForImgFields(fields, true)}
3479
3503
  ${getScriptForRewriteValueForFileFields(fields)}
3480
3504
  }catch(e){
3481
3505
  console.error(e)
@@ -3539,7 +3563,7 @@ async function getReadonlyFormInitApi(object, recordId, fields, options){
3539
3563
  /*
3540
3564
  img/avatar字段值添加URL前缀使其在amis中正常显示图片。
3541
3565
  */
3542
- function getScriptForAddUrlPrefixForImgFields(fields){
3566
+ function getScriptForAddUrlPrefixForImgFields(fields, readonly){
3543
3567
  let imgFieldsKeys = [];
3544
3568
  let imgFields = {};
3545
3569
  fields.forEach((item)=>{
@@ -3567,12 +3591,12 @@ function getScriptForAddUrlPrefixForImgFields(fields){
3567
3591
  if(fieldProps.multiple){
3568
3592
  if(imgFieldDisplayValue instanceof Array){
3569
3593
  data[item] = imgFieldDisplayValue.map((i)=>{
3570
- const url = window.getImageFieldUrl(i.url);
3594
+ const url = window.getImageFieldUrl(i.url, ${readonly});
3571
3595
  return url;
3572
3596
  });
3573
3597
  }
3574
3598
  }else{
3575
- const url = imgFieldDisplayValue && window.getImageFieldUrl(imgFieldDisplayValue.url);
3599
+ const url = imgFieldDisplayValue && window.getImageFieldUrl(imgFieldDisplayValue.url, ${readonly});
3576
3600
  data[item] = url;
3577
3601
  }
3578
3602
  }
@@ -3668,7 +3692,7 @@ async function getEditFormInitApi(object, recordId, fields, options){
3668
3692
  const fieldKeys = uiSchema && _.keys(uiSchema.fields);
3669
3693
 
3670
3694
  if(data){
3671
- ${getScriptForAddUrlPrefixForImgFields(fields)}
3695
+ ${getScriptForAddUrlPrefixForImgFields(fields, false)}
3672
3696
  ${getScriptForRewriteValueForFileFields(fields)}
3673
3697
 
3674
3698
  _.each(dataKeys, function(key){