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.

81 lines
2.4 KiB

4 months ago
  1. import { defineMixin } from '../../libs/vue'
  2. import defProps from '../../libs/config/props.js'
  3. import test from '../../libs/function/test';
  4. export const props = defineMixin({
  5. props: {
  6. // 头像图片路径(不能为相对路径)
  7. src: {
  8. type: String,
  9. default: () => defProps.avatar.src
  10. },
  11. // 头像形状,circle-圆形,square-方形
  12. shape: {
  13. type: String,
  14. default: () => defProps.avatar.shape
  15. },
  16. // 头像尺寸
  17. size: {
  18. type: [String, Number],
  19. default: () => defProps.avatar.size
  20. },
  21. // 裁剪模式
  22. mode: {
  23. type: String,
  24. default: () => defProps.avatar.mode
  25. },
  26. // 显示的文字
  27. text: {
  28. type: String,
  29. default: () => defProps.avatar.text
  30. },
  31. // 背景色
  32. bgColor: {
  33. type: String,
  34. default: () => defProps.avatar.bgColor
  35. },
  36. // 文字颜色
  37. color: {
  38. type: String,
  39. default: () => defProps.avatar.color
  40. },
  41. // 文字大小
  42. fontSize: {
  43. type: [String, Number],
  44. default: () => defProps.avatar.fontSize
  45. },
  46. // 显示的图标
  47. icon: {
  48. type: String,
  49. default: () => defProps.avatar.icon
  50. },
  51. // 显示小程序头像,只对百度,微信,QQ小程序有效
  52. mpAvatar: {
  53. type: Boolean,
  54. default: () => defProps.avatar.mpAvatar
  55. },
  56. // 是否使用随机背景色
  57. randomBgColor: {
  58. type: Boolean,
  59. default: () => defProps.avatar.randomBgColor
  60. },
  61. // 加载失败的默认头像(组件有内置默认图片)
  62. defaultUrl: {
  63. type: String,
  64. default: () => defProps.avatar.defaultUrl
  65. },
  66. // 如果配置了randomBgColor为true,且配置了此值,则从默认的背景色数组中取出对应索引的颜色值,取值0-19之间
  67. colorIndex: {
  68. type: [String, Number],
  69. // 校验参数规则,索引在0-19之间
  70. validator(n) {
  71. return test.range(n, [0, 19]) || n === ''
  72. },
  73. default: () => defProps.avatar.colorIndex
  74. },
  75. // 组件标识符
  76. name: {
  77. type: String,
  78. default: () => defProps.avatar.name
  79. }
  80. }
  81. })