You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

130 lines
4.2 KiB

5 months ago
  1. import { defineMixin } from '../../libs/vue'
  2. import defProps from '../../libs/config/props.js'
  3. export const props = defineMixin({
  4. props: {
  5. // 接受的文件类型, 可选值为all media image file video
  6. accept: {
  7. type: String,
  8. default: () => defProps.upload.accept
  9. },
  10. extension: {
  11. type: Array,
  12. default: () => defProps.upload.extension
  13. },
  14. // 图片或视频拾取模式,当accept为image类型时设置capture可选额外camera可以直接调起摄像头
  15. capture: {
  16. type: [String, Array],
  17. default: () => defProps.upload.capture
  18. },
  19. // 当accept为video时生效,是否压缩视频,默认为true
  20. compressed: {
  21. type: Boolean,
  22. default: () => defProps.upload.compressed
  23. },
  24. // 当accept为video时生效,可选值为back或front
  25. camera: {
  26. type: String,
  27. default: () => defProps.upload.camera
  28. },
  29. // 当accept为video时生效,拍摄视频最长拍摄时间,单位秒
  30. maxDuration: {
  31. type: Number,
  32. default: () => defProps.upload.maxDuration
  33. },
  34. // 上传区域的图标,只能内置图标
  35. uploadIcon: {
  36. type: String,
  37. default: () => defProps.upload.uploadIcon
  38. },
  39. // 上传区域的图标的颜色,默认
  40. uploadIconColor: {
  41. type: String,
  42. default: () => defProps.upload.uploadIconColor
  43. },
  44. // 是否开启文件读取前事件
  45. useBeforeRead: {
  46. type: Boolean,
  47. default: () => defProps.upload.useBeforeRead
  48. },
  49. // 读取后的处理函数
  50. afterRead: {
  51. type: Function,
  52. default: null
  53. },
  54. // 读取前的处理函数
  55. beforeRead: {
  56. type: Function,
  57. default: null
  58. },
  59. // 是否显示组件自带的图片预览功能
  60. previewFullImage: {
  61. type: Boolean,
  62. default: () => defProps.upload.previewFullImage
  63. },
  64. // 最大上传数量
  65. maxCount: {
  66. type: [String, Number],
  67. default: () => defProps.upload.maxCount
  68. },
  69. // 是否启用
  70. disabled: {
  71. type: Boolean,
  72. default: () => defProps.upload.disabled
  73. },
  74. // 预览上传的图片时的裁剪模式,和image组件mode属性一致
  75. imageMode: {
  76. type: String,
  77. default: () => defProps.upload.imageMode
  78. },
  79. // 标识符,可以在回调函数的第二项参数中获取
  80. name: {
  81. type: String,
  82. default: () => defProps.upload.name
  83. },
  84. // 所选的图片的尺寸, 可选值为original compressed
  85. sizeType: {
  86. type: Array,
  87. default: () => defProps.upload.sizeType
  88. },
  89. // 是否开启图片多选,部分安卓机型不支持
  90. multiple: {
  91. type: Boolean,
  92. default: () => defProps.upload.multiple
  93. },
  94. // 是否展示删除按钮
  95. deletable: {
  96. type: Boolean,
  97. default: () => defProps.upload.deletable
  98. },
  99. // 文件大小限制,单位为byte
  100. maxSize: {
  101. type: [String, Number],
  102. default: () => defProps.upload.maxSize
  103. },
  104. // 显示已上传的文件列表
  105. fileList: {
  106. type: Array,
  107. default: () => defProps.upload.fileList
  108. },
  109. // 上传区域的提示文字
  110. uploadText: {
  111. type: String,
  112. default: () => defProps.upload.uploadText
  113. },
  114. // 内部预览图片区域和选择图片按钮的区域宽度
  115. width: {
  116. type: [String, Number],
  117. default: () => defProps.upload.width
  118. },
  119. // 内部预览图片区域和选择图片按钮的区域高度
  120. height: {
  121. type: [String, Number],
  122. default: () => defProps.upload.height
  123. },
  124. // 是否在上传完成后展示预览图
  125. previewImage: {
  126. type: Boolean,
  127. default: () => defProps.upload.previewImage
  128. }
  129. }
  130. })