Skip to content
导航栏

显示视频

xgen 视频的显示存在 bug: https://github.com/YaoApp/yao/issues/371

修正处理

js
// /xgen-v1.0/packages/xgen/knife/yao/getFileSrc.ts

import getToken from './getToken';

const Index = (name: string) => {
  //这里加个判断,因为在上传视频其间这个name是一个对象,而不是字符串
  if (typeof name !== 'string') {
    return;
  }
  if (name.startsWith('http')) return name;

  return `${name}&token=${getToken()}`;
};

export default Index;

模型配置

模型字段配置类型为 json

json
{
  "label": "video",
  "type": "json",
  "nullable": true,
  "name": "video"
}

列表配置

配置字段的 edit 属性 "filetype": "video"

json
{
  "video": {
    "view": {
      "props": {},
      "type": "Image",
      "compute": "Download"
    },
    "edit": {
      "type": "Upload",
      "compute": "Upload",
      "props": {
        "maxCount": 100,
        "filetype": "video",
        "$api": {
          "process": "fs.system.Upload"
        }
      }
    },
    "bind": "video"
  }
}

表单配置

表单的字段一定要配置 view 属性,并加上"compute": "Download",才能正确的获取视频的下载地址

json
{
  "video": {
    "view": {
      "props": {},
      "type": "Image",
      "compute": "Download"
    },
    "edit": {
      "props": {
        "maxCount": 100,
        "filetype": "video",
        "$api": {
          "process": "fs.system.Upload"
        }
      },
      "type": "Upload",
      "compute": "Upload"
    },
    "bind": "video"
  }
}