CraftsArticle.vue 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <script setup>
  2. import { ref, reactive } from "vue";
  3. import axios from "axios";
  4. import { useMainStore } from "@/stores/store";
  5. // import { useI18n } from "vue-i18n";
  6. // const { t } = useI18n();
  7. const store = useMainStore();
  8. let loading = ref(false);
  9. let data = reactive({
  10. list: [],
  11. });
  12. // 國際專欄
  13. (async () => {
  14. loading.value = true;
  15. try {
  16. const response = await axios.get(
  17. `${store.apiUrl}/api/get_article?group_sort=國際專欄`
  18. );
  19. data.list = response.data.articles;
  20. loading.value = false;
  21. console.log("國際專欄", data.list);
  22. } catch (error) {
  23. console.error(error);
  24. }
  25. })();
  26. </script>
  27. <template>
  28. <div v-if="loading" class="d-flex justify-center my-10">
  29. <v-progress-circular
  30. color="grey-lighten-4"
  31. indeterminate
  32. ></v-progress-circular>
  33. </div>
  34. <v-row v-else class="list">
  35. <v-col cols="12" sm="6" v-for="(item, index) in data.list" :key="index">
  36. <a :href="item.url" target="_blank">
  37. <!-- <img :src="`${store.imgUrl}/${item.cover_img}`" alt="臺灣工藝學習平台" /> -->
  38. <div class="overflow-hidden">
  39. <v-img
  40. class="mx-auto cover-img"
  41. :lazy-src="`${store.imgUrl}/${item.cover_img}`"
  42. cover
  43. :src="`${store.imgUrl}/${item.cover_img}`"
  44. alt="臺灣工藝學習平台"
  45. >
  46. <template v-slot:placeholder>
  47. <div class="d-flex align-center justify-center fill-height">
  48. <v-progress-circular
  49. color="grey-lighten-4"
  50. indeterminate
  51. ></v-progress-circular>
  52. </div>
  53. </template>
  54. </v-img>
  55. </div>
  56. </a>
  57. <section>
  58. <p>{{ item.depiction }}</p>
  59. <h3 v-html="item.title"></h3>
  60. </section>
  61. </v-col>
  62. </v-row>
  63. </template>
  64. <style lang="scss" scoped>
  65. .cover-img {
  66. transition: all 0.5s;
  67. &:hover {
  68. transform: translate(0, -0.625em);
  69. }
  70. }
  71. .list {
  72. p {
  73. margin-bottom: 0.625em;
  74. }
  75. h3,
  76. p {
  77. font-weight: 500;
  78. text-align: center;
  79. line-height: 1.875em;
  80. }
  81. }
  82. </style>