PlatformIcon.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <template>
  2. <span v-if="PlatformIcons[name]" class="platform-icon">
  3. <a-tooltip placement="bottom">
  4. <template v-if="showTips" slot="title">
  5. <span class="f-12">{{ tipsPrefix }}{{ PlatformName[name] }}</span>
  6. </template>
  7. <a-icon class="icon" :class="[name]" :component="PlatformIcons[name]" />
  8. </a-tooltip>
  9. </span>
  10. </template>
  11. <script>
  12. import PropTypes from 'ant-design-vue/es/_util/vue-types'
  13. import { mpWeixin, h5, app } from '@/core/icons'
  14. // 客户端图标
  15. const PlatformIcons = {
  16. 'MP-WEIXIN': mpWeixin,
  17. 'H5': h5,
  18. 'APP': app
  19. }
  20. // 客户端名称
  21. const PlatformName = {
  22. 'MP-WEIXIN': '微信小程序',
  23. 'H5': 'H5网页',
  24. 'APP': '手机APP'
  25. }
  26. export default {
  27. name: 'PlatformIcon',
  28. props: {
  29. // 指定的客户端 (APP、H5、小程序等)
  30. name: PropTypes.string.def(''),
  31. // 是否显示文字提示
  32. showTips: PropTypes.bool.def(false),
  33. // 文字提示前缀
  34. tipsPrefix: PropTypes.string.def(''),
  35. },
  36. data () {
  37. return {
  38. PlatformIcons,
  39. PlatformName
  40. }
  41. },
  42. methods: {
  43. fetchNotice () {
  44. if (!this.visible) {
  45. this.loading = true
  46. setTimeout(() => {
  47. this.loading = false
  48. }, 2000)
  49. } else {
  50. this.loading = false
  51. }
  52. this.visible = !this.visible
  53. }
  54. }
  55. }
  56. </script>
  57. <style lang="less">
  58. // 客户端图标
  59. .platform-icon {
  60. font-size: 16px;
  61. .icon {
  62. margin-right: 5px;
  63. &:last-child {
  64. margin-right: 0;
  65. }
  66. }
  67. .MP-WEIXIN {
  68. color: #04be02;
  69. }
  70. .H5 {
  71. color: #e44c27;
  72. }
  73. }
  74. </style>