index.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <template>
  2. <a-card>
  3. <div class="templates">
  4. <template v-for="(template,key) in templates">
  5. <div class="item-box" :key="key" @click="show(template)">
  6. <a-popover v-if="template.preview">
  7. <template #content>
  8. <img style="cursor: pointer" :src="template.preview" @click="show(template)"/>
  9. </template>
  10. <img class="preview" :src="template.preview"/>
  11. </a-popover>
  12. <div v-else class="preview">暂无预览图</div>
  13. <div class="name pd">{{ template.name }}</div>
  14. <div class="desc pd">{{ template.desc }}</div>
  15. <div class="author pd" @click.stop="">
  16. <a :href="template.link" target="_blank">{{ template.author }}</a>
  17. </div>
  18. </div>
  19. </template>
  20. </div>
  21. <template-preview ref="preview"/>
  22. </a-card>
  23. </template>
  24. <script>
  25. import templates from './files'
  26. import templatePreview from './preview'
  27. import printData from "../design/print-data";
  28. export default {
  29. name: "templates",
  30. components: {templatePreview},
  31. data() {
  32. return {
  33. templates
  34. }
  35. },
  36. mounted() {
  37. },
  38. methods: {
  39. show(template) {
  40. this.$refs.preview.show(template)
  41. }
  42. }
  43. }
  44. </script>
  45. <style scoped lang="less">
  46. .templates {
  47. display: flex;
  48. flex-wrap: wrap;
  49. align-content: center;
  50. justify-content: center;
  51. }
  52. .item-box {
  53. display: flex;
  54. flex-direction: column;
  55. box-shadow: 0 0 10px #ccc;
  56. border-radius: 10px;
  57. margin: 0 10px 10px 0;
  58. img {
  59. object-fit: cover;
  60. }
  61. .preview {
  62. height: 200px;
  63. width: 200px;
  64. border-top-left-radius: 10px;
  65. border-top-right-radius: 10px;
  66. }
  67. .pd {
  68. padding: 4px 6px;
  69. }
  70. .name {
  71. text-align: center;
  72. font-size: 16px;
  73. font-weight: bold;
  74. }
  75. .desc {
  76. font-size: 12px;
  77. color: #999;
  78. }
  79. .author {
  80. text-align: right;
  81. }
  82. }
  83. .item-box:hover {
  84. box-shadow: 0 0 10px #999;
  85. cursor: pointer;
  86. }
  87. </style>