From 78d2ec221506b0aeb380b7c6d22b7ce7f5c66e8a Mon Sep 17 00:00:00 2001
From: AliceLanniste <1399789151@qq.com>
Date: Wed, 24 Jul 2024 01:12:16 +0800
Subject: [PATCH] =?UTF-8?q?feat(component):=20=E7=B4=A0=E6=9D=90=E7=80=91?=
=?UTF-8?q?=E5=B8=83=E6=B5=81=E5=B8=83=E5=B1=80=20(#471)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* fix(component): 素材瀑布流布局样式
* fix(component): 新增空瀑布流组件
* feat(component): 瀑布流增加样式
* feat(component): 修改返回数据
* feat(component): 新增瀑布流组件
* feat(component): 修改素材列表页面
* feat(component): getPageData接口修改
* feat(component): 修改瀑布流样式
* feat(component): 修改渲染层
* feat(component): 删除冗余代码
* feat(component): 重构逻辑
* feat(component): 移除注释
* feat(component): 加入loading组件
* feat(component): 加入Message组件
* feat(component): 增加瀑布流组件props
* feat(component): 完成关键词瀑布流查询
* feat(component): 删除冗余
* feat(component): 修改瀑布流布局
---
src/components/common/masonry.vue | 207 ++++++++++++++++++++++++++++++
src/components/importTmpl.vue | 54 ++++----
src/hooks/pageList.js | 22 +++-
3 files changed, 249 insertions(+), 34 deletions(-)
create mode 100644 src/components/common/masonry.vue
diff --git a/src/components/common/masonry.vue b/src/components/common/masonry.vue
new file mode 100644
index 00000000..2999697b
--- /dev/null
+++ b/src/components/common/masonry.vue
@@ -0,0 +1,207 @@
+
+
+
+
+
+
+
diff --git a/src/components/importTmpl.vue b/src/components/importTmpl.vue
index 7e5d8156..ada872ba 100644
--- a/src/components/importTmpl.vue
+++ b/src/components/importTmpl.vue
@@ -10,7 +10,7 @@
-
@@ -60,27 +57,22 @@
import useSelect from '@/hooks/select';
import usePageList from '@/hooks/pageList';
import { Spin, Modal } from 'view-ui-plus';
-
+import masonry from './common/masonry.vue';
import { useI18n } from 'vue-i18n';
import { useRouter, useRoute } from 'vue-router';
const router = useRouter();
const route = useRoute();
const { t } = useI18n();
const { canvasEditor } = useSelect();
-
+const column = ref(2);
const {
- startPage,
+ getTypeList,
+ getPageData,
typeValue,
typeText,
typeList,
pageLoading,
- pageData,
searchKeyWord,
- isDownBottm,
- startGetList,
- nextPage,
- showScroll,
- scrollHeight,
getInfo,
} = usePageList({
typeUrl: 'templ-types',
@@ -91,7 +83,11 @@ const {
scrollElement: '#myTemplBox',
fields: ['name'],
});
+const masonryRef = ref(null);
+const keywordSearch = () => {
+ masonryRef.value.getkeyWordSearch();
+};
// 替换提示
const beforeClearTip = (info) => {
Modal.confirm({
@@ -104,7 +100,7 @@ const beforeClearTip = (info) => {
};
onMounted(() => {
- startPage();
+ getTypeList();
getTemplInfo();
});
diff --git a/src/hooks/pageList.js b/src/hooks/pageList.js
index 94ae8286..da7357ad 100644
--- a/src/hooks/pageList.js
+++ b/src/hooks/pageList.js
@@ -133,11 +133,11 @@ export default function usePageList({
pageLoading.value = false;
};
- const getPageData = async () => {
+ const getPageData = async (page, pageSize) => {
pageLoading.value = true;
try {
const params = getPageParams(
- page.value,
+ page,
typeValue.value,
searchKeyWord.value,
searchTypeKey,
@@ -146,12 +146,19 @@ export default function usePageList({
fields
);
const res = await pageApi(listUrl, params);
+ pageLoading.value = false;
const list = res.data.data.map((item) => {
+ let small = item.attributes.img.data.attributes.formats.small;
+ let thumbnail = item.attributes.img.data.attributes.formats.thumbnail;
+ const height = small ? small.height : thumbnail.height;
+ const width = small ? small.width : thumbnail.width;
return {
id: item.id,
name: item.attributes.name,
desc: item.attributes.desc,
json: item.attributes?.json,
+ height: height,
+ width: width,
src: getMaterialInfoUrl(item.attributes.img),
previewSrc: getMaterialPreviewUrl(item.attributes.img),
};
@@ -159,17 +166,20 @@ export default function usePageList({
Object.keys(res.data.meta.pagination).forEach((key) => {
pagination[key] = res.data.meta.pagination[key];
});
- pageData.value = [...pageData.value, ...list];
+ if (list.length) {
+ return list;
+ } else {
+ return [];
+ }
} catch (error) {
console.log(error);
}
- pageLoading.value = false;
};
const startGetList = () => {
pageData.value = [];
page.value = 1;
- getPageData();
+ getPageData(1, 10);
};
const nextPage = () => {
@@ -203,6 +213,8 @@ export default function usePageList({
isDownBottm,
startGetList,
nextPage,
+ getTypeList,
+ getPageData,
scrollHeight,
showScroll,
getInfo,