Compare commits

..

2 Commits

Author SHA1 Message Date
4d723758df bigger layout for FileDetail 2025-07-15 17:16:59 +08:00
cef8121008 fix page list for RepositoryList.vue 2025-07-15 16:53:31 +08:00
2 changed files with 71 additions and 13 deletions

View File

@ -1,6 +1,6 @@
<template> <template>
<b-e-flower-fall class="background" /> <b-e-flower-fall class="background" />
<root-layout v-if="ready" class="diselect" icp="粤ICP备2025368555号-1" domain="imyeyu.com" author="夜雨"> <root-layout v-if="ready" class="root-layout diselect" icp="粤ICP备2025368555号-1" domain="imyeyu.com" author="夜雨">
<router-view /> <router-view />
</root-layout> </root-layout>
<popup /> <popup />
@ -11,15 +11,32 @@
import { BEFlowerFall, Popup } from "timi-web"; import { BEFlowerFall, Popup } from "timi-web";
import { RootLayout, UserProfilePopup } from "timi-tdesign-pc"; import { RootLayout, UserProfilePopup } from "timi-tdesign-pc";
const ready = ref(false); const route = useRoute();
onMounted(async () => { const ready = ref(false);
ready.value = true; onMounted(async () => ready.value = true);
});
// ---------- 文件详情页更宽的布局 ----------
const inFileDetail = ref(false);
const largeWidth = computed(() => inFileDetail.value ? "1600px" : "1200px");
const width = computed(() => inFileDetail.value ? "1200px" : "900px");
watch(route, () => inFileDetail.value = route.name === "FileDetail");
</script> </script>
<style lang="less"> <style lang="less">
.background { .background {
background: url("@/assets/img/main.png") fixed right bottom; background: url("@/assets/img/main.png") fixed right bottom;
} }
@media screen and (max-width: 2560px) {
.root-layout {
width: v-bind(largeWidth) !important;
}
}
@media screen and (max-width: 1920px) {
.root-layout {
width: v-bind(width) !important;
}
}
</style> </style>

View File

@ -22,13 +22,16 @@
</t-list> </t-list>
<footer class="footer"> <footer class="footer">
<t-pagination <t-pagination
class="pagination" class="pages"
v-if="pageResult"
:total="pageResult.total" :total="pageResult.total"
:pageSize="16" :pageSize="16"
:showPageSize="false" :showPageSize="false"
:current="currentPage"
:onCurrentChange="onPageChangeEvent"
> >
<template #totalContent> <template #totalContent>
<div class="total" v-text="`共 ${pageResult.total} 个项目`"></div> <div style="flex: 1" v-text="`共 ${pageResult.total} 篇文章`"></div>
</template> </template>
</t-pagination> </t-pagination>
</footer> </footer>
@ -37,24 +40,62 @@
<script lang="ts" setup> <script lang="ts" setup>
import RepositoryAPI from "@/api/RepositoryAPI"; import RepositoryAPI from "@/api/RepositoryAPI";
import { Repository } from "@/types/Repository"; import { Repository } from "@/types/Repository";
import { Icon, Loading, Page, PageResult, Time } from "timi-web"; import { Icon, Loading, Page, PageResult, Time, Toolkit } from "timi-web";
const page = ref<Page>({ const router = useRouter();
const route = useRoute();
const isLoading = ref(false);
const currentPage = computed(() => page.index + 1);
const page = reactive<Page>({
index: 0, index: 0,
size: 12 size: 16
}); });
const pageResult = reactive<PageResult<Repository>>({ const pageResult = reactive<PageResult<Repository>>({
total: 0, total: 0,
list: [] list: []
}); });
const isLoading = ref(false); // 获取列表
onMounted(async () => { const fetchList = Toolkit.debounce(async () => {
isLoading.value = true; isLoading.value = true;
const result = await RepositoryAPI.page(page.value); const result = await RepositoryAPI.page(page);
pageResult.total = result.total; pageResult.total = result.total;
pageResult.list = result.list; pageResult.list = result.list;
isLoading.value = false; isLoading.value = false;
}); });
// 监听路由分页
watch(
() => route.query.p,
async (newP) => {
const pNum = Number(newP);
if (Number.isInteger(pNum) && 0 <= pNum) {
page.index = pNum;
await fetchList();
} else {
// 参数无效时重置为第一页
await router.push({
path: route.path,
query: {
...route.query,
p: 0
}
});
}
},
{ immediate: true }
);
function onPageChangeEvent(current: number) {
const newIndex = current - 1;
router.push({
path: route.path,
query: {
...route.query,
p: newIndex
}
});
}
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>