mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-15 09:48:14 +08:00
🎨 平滑锁定当前帖子
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
<span>{{ props.collection.collection_title }}</span>
|
<span>{{ props.collection.collection_title }}</span>
|
||||||
<span>合集ID:{{ props.collection.collection_id }}</span>
|
<span>合集ID:{{ props.collection.collection_id }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="tpoc-list">
|
<div class="tpoc-list" :id="`post-collect-overlay-${props.collection.collection_id}`">
|
||||||
<div
|
<div
|
||||||
class="tpoc-item"
|
class="tpoc-item"
|
||||||
v-for="(item, index) in posts"
|
v-for="(item, index) in posts"
|
||||||
@@ -47,7 +47,7 @@
|
|||||||
</TOverlay>
|
</TOverlay>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref, computed, onMounted } from "vue";
|
import { computed, onMounted, ref, watch } from "vue";
|
||||||
import { useRouter } from "vue-router";
|
import { useRouter } from "vue-router";
|
||||||
|
|
||||||
import Mys from "../../plugins/Mys/index.js";
|
import Mys from "../../plugins/Mys/index.js";
|
||||||
@@ -83,6 +83,25 @@ const posts = ref<TpoCollectionItem[]>([]);
|
|||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => visible.value,
|
||||||
|
async (value) => {
|
||||||
|
if (value) {
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 500));
|
||||||
|
const postList = document.getElementById(
|
||||||
|
`post-collect-overlay-${props.collection.collection_id}`,
|
||||||
|
);
|
||||||
|
if (postList === null) return;
|
||||||
|
if (props.collection.cur < 6) return;
|
||||||
|
const lastItem = <HTMLDivElement>postList.children[postList.children.length - 1];
|
||||||
|
postList.scrollTo({
|
||||||
|
top: lastItem.offsetTop - postList.clientHeight / 2 + lastItem.clientHeight / 2,
|
||||||
|
behavior: "smooth",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
const collectionPosts = await Mys.PostCollect(props.collection.collection_id);
|
const collectionPosts = await Mys.PostCollect(props.collection.collection_id);
|
||||||
const tempArr: TpoCollectionItem[] = [];
|
const tempArr: TpoCollectionItem[] = [];
|
||||||
|
|||||||
Reference in New Issue
Block a user