refactor: 确立独立子工程架构 (backend, admin, mpuniapp) 并同步更新 AGENTS.md 规范
这个提交包含在:
@@ -0,0 +1,65 @@
|
||||
// 列表项数据类型
|
||||
export type ListItemData = {
|
||||
id: number,
|
||||
type: number,
|
||||
title: string,
|
||||
desc: string,
|
||||
author: string,
|
||||
timestamp: number,
|
||||
image: string,
|
||||
images: string[],
|
||||
gridImages: string[],
|
||||
rating: number,
|
||||
videoUrl: string,
|
||||
videoPoster: string,
|
||||
playCount: number,
|
||||
likeCount: number
|
||||
}
|
||||
|
||||
// 预生成4000条数据
|
||||
function generateData(): ListItemData[] {
|
||||
const result: ListItemData[] = []
|
||||
const baseTime = 1705000000000 // 固定基准时间戳
|
||||
|
||||
for (let i = 0; i < 4000; i++) {
|
||||
const type = (i % 3) + 1
|
||||
const idx = i + 1
|
||||
|
||||
// 生成3张图片URL - 使用不同颜色和文字标识
|
||||
const images: string[] = []
|
||||
images.push(`https://web-ext-storage.dcloud.net.cn/hello-uni-app-x/waterflow-perf/150x200/3498db/white/T${type}-${idx}-A.webp`)
|
||||
images.push(`https://web-ext-storage.dcloud.net.cn/hello-uni-app-x/waterflow-perf/150x200/e74c3c/white/T${type}-${idx}-B.webp`)
|
||||
images.push(`https://web-ext-storage.dcloud.net.cn/hello-uni-app-x/waterflow-perf/150x200/2ecc71/white/T${type}-${idx}-C.webp`)
|
||||
|
||||
// 生成9张九宫格图片 (虽然不用了,但为了类型兼容还是保留空数组或者生成一点防止报错,mock data里类型定义有这个字段)
|
||||
const gridImages: string[] = []
|
||||
|
||||
const item: ListItemData = {
|
||||
id: i,
|
||||
type: type,
|
||||
title: `#${idx} ${type == 1 ? '单图' : type == 2 ? '三图' : '视频'}`,
|
||||
desc: `第${idx}条数据内容摘要,测试长文本显示效果。这里多加一点文字让它看起来更长一些。`,
|
||||
author: `User-${idx}`,
|
||||
timestamp: baseTime - i * 3600000,
|
||||
image: `https://web-ext-storage.dcloud.net.cn/hello-uni-app-x/waterflow-perf/120x120/9b59b6/white/T${type}-${idx}.webp`,
|
||||
images: images,
|
||||
gridImages: gridImages,
|
||||
rating: Math.floor(Math.random() * 5) + 1,
|
||||
videoUrl: (i % 2 == 1) ? '/static/test-video/10second-demo.mp4' : 'https://web-ext-storage.dcloud.net.cn/uni-app-x/video/uts-5-16.mp4',
|
||||
videoPoster: `https://web-ext-storage.dcloud.net.cn/hello-uni-app-x/waterflow-perf/180x240/1abc9c/white/Video-${idx}.webp`,
|
||||
playCount: i * 100 + 500,
|
||||
likeCount: i * 10 + 50
|
||||
}
|
||||
result.push(item)
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
let _mockListData: ListItemData[] | null = null
|
||||
export function generateMockList() {
|
||||
if (_mockListData == null) {
|
||||
_mockListData = generateData()
|
||||
}
|
||||
return _mockListData!
|
||||
}
|
||||
@@ -0,0 +1,278 @@
|
||||
<template>
|
||||
<view class="page">
|
||||
<!-- #ifndef MP -->
|
||||
<fps />
|
||||
<!-- #endif -->
|
||||
<view class="header">
|
||||
<text class="header-info">{{ listData.length }}项 | 瀑布流动态列数 | 圆角边框阴影</text>
|
||||
</view>
|
||||
<waterflow class="waterflow-container" :max-cross-axis-extent="200" :main-axis-gap="4" :cross-axis-gap="4" @scrolltolower="onScrollToLower">
|
||||
<flow-item v-for="(item, index) in listData" :key="item.id" :type="item.type">
|
||||
|
||||
<!-- ========== Type 1: 单图配文 ========== -->
|
||||
<view v-if="item.type == 1" class="card card-type1">
|
||||
<view class="card-header">
|
||||
<text class="card-title" @click.stop="onTitleClick(item.id + 1)">#{{ item.id + 1 }}</text>
|
||||
<text class="tag-sm">单图</text>
|
||||
</view>
|
||||
<view class="card-image-area">
|
||||
<image class="card-image" :src="item.image" mode="aspectFill" @click.stop="onImageClick([item.image], 0)"></image>
|
||||
</view>
|
||||
<view class="card-content">
|
||||
<text class="content-title">{{ item.title }}</text>
|
||||
<text class="content-desc">{{ item.desc }}</text>
|
||||
<view class="meta-info">
|
||||
<text class="author-text">{{ item.author }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- ========== Type 2: 三图配文 ========== -->
|
||||
<view v-else-if="item.type == 2" class="card card-type2">
|
||||
<view class="card-header">
|
||||
<text class="card-title" @click.stop="onTitleClick(item.id + 1)">#{{ item.id + 1 }}</text>
|
||||
<text class="tag-sm">三图</text>
|
||||
</view>
|
||||
<view class="card-images-row">
|
||||
<image class="card-image-sm" :src="item.images[0]" mode="aspectFill" @click.stop="onImageClick(item.images, 0)"></image>
|
||||
<image class="card-image-sm" :src="item.images[1]" mode="aspectFill" @click.stop="onImageClick(item.images, 1)"></image>
|
||||
<image class="card-image-sm" :src="item.images[2]" mode="aspectFill" @click.stop="onImageClick(item.images, 2)"></image>
|
||||
</view>
|
||||
<view class="card-content">
|
||||
<text class="content-title">{{ item.title }}</text>
|
||||
<view class="meta-info">
|
||||
<text class="author-text">{{ item.author }}</text>
|
||||
<text class="view-count">1024阅读</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- ========== Type 3: 视频 ========== -->
|
||||
<view v-else-if="item.type == 3" class="card card-type5">
|
||||
<view class="card-header">
|
||||
<text class="card-title" @click.stop="onTitleClick(item.id + 1)">#{{ item.id + 1 }}</text>
|
||||
<text class="tag-sm">视频</text>
|
||||
</view>
|
||||
<view class="video-area">
|
||||
<video
|
||||
class="card-video"
|
||||
:src="item.videoUrl"
|
||||
:poster="item.videoPoster"
|
||||
:controls="true"
|
||||
object-fit="cover"
|
||||
></video>
|
||||
</view>
|
||||
<view class="card-content">
|
||||
<view class="meta-info">
|
||||
<text class="info-text">播放:{{ item.playCount }}</text>
|
||||
<text class="info-text">弹幕:99+</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</flow-item>
|
||||
<flow-item slot="load-more">
|
||||
<text style="line-height: 50px; text-align: center; font-size: 12px; color: #999999;">{{ hasMore ? '加载中...' : '没有更多' }}</text>
|
||||
</flow-item>
|
||||
</waterflow>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="uts">
|
||||
import { generateMockList, type ListItemData } from './mock-data.uts'
|
||||
|
||||
const fullData = generateMockList()
|
||||
const pageSize = 20
|
||||
function getPageData(pageIndex: number): ListItemData[] {
|
||||
const start = pageIndex * pageSize
|
||||
return fullData.slice(start, start + pageSize)
|
||||
}
|
||||
// 使用预生成的数据
|
||||
const listData = ref<ListItemData[]>([])
|
||||
const hasMore = ref(true)
|
||||
let cucurrentPage = 0
|
||||
onMounted(() => {
|
||||
listData.value = getPageData(cucurrentPage)
|
||||
})
|
||||
|
||||
function onScrollToLower() {
|
||||
// 模拟加载更多数据
|
||||
setTimeout(() => {
|
||||
cucurrentPage++
|
||||
const newData = getPageData(cucurrentPage)
|
||||
if (newData.length > 0) {
|
||||
listData.value = listData.value.concat(newData)
|
||||
} else {
|
||||
hasMore.value = false
|
||||
}
|
||||
}, 200)
|
||||
}
|
||||
|
||||
function onTitleClick(index: number) {
|
||||
uni.showToast({
|
||||
title: `序号: ${index}`,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
|
||||
function onImageClick(urls: string[], current: number) {
|
||||
uni.previewImage({
|
||||
urls: urls,
|
||||
current: current
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.page {
|
||||
flex: 1;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
.header {
|
||||
padding: 10px 15px;
|
||||
background-color: #333;
|
||||
}
|
||||
|
||||
.header-info {
|
||||
font-size: 10px;
|
||||
color: #aaa;
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.waterflow-container {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
/* ===== 卡片基础样式 ===== */
|
||||
.card {
|
||||
background-color: #fff;
|
||||
border-radius: 8px;
|
||||
padding: 10px;
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.card-header {
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 6px;
|
||||
padding-bottom: 4px;
|
||||
border-bottom-width: 0.5px;
|
||||
border-bottom-color: #eee;
|
||||
border-bottom-style: solid;
|
||||
}
|
||||
|
||||
.card-title {
|
||||
font-size: 12px;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.tag-sm {
|
||||
font-size: 8px;
|
||||
color: #fff;
|
||||
background-color: #3498db;
|
||||
padding: 2px 6px;
|
||||
border-radius: 3px;
|
||||
margin-left: 4px;
|
||||
}
|
||||
|
||||
.card-content {
|
||||
padding-top: 4px;
|
||||
}
|
||||
|
||||
.content-title {
|
||||
font-size: 12px;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
margin-bottom: 4px;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.content-desc {
|
||||
font-size: 10px;
|
||||
color: #666;
|
||||
margin-bottom: 4px;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.meta-info {
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.author-text {
|
||||
font-size: 8px;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.view-count {
|
||||
font-size: 8px;
|
||||
color: #aaa;
|
||||
margin-left: 6px;
|
||||
}
|
||||
|
||||
.info-text {
|
||||
font-size: 8px;
|
||||
color: #666;
|
||||
margin-right: 4px;
|
||||
}
|
||||
|
||||
.status-text {
|
||||
font-size: 8px;
|
||||
color: #2ecc71;
|
||||
margin-left: 6px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* ===== Type 1: 单图配文 ===== */
|
||||
|
||||
.card-image-area {
|
||||
margin: 6px 0;
|
||||
height: 100px;
|
||||
border-radius: 4px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.card-image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
/* ===== Type 2: 三图配文 ===== */
|
||||
|
||||
.card-images-row {
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
margin: 6px 0;
|
||||
height: 70px;
|
||||
}
|
||||
|
||||
.card-image-sm {
|
||||
flex: 1;
|
||||
height: 70px;
|
||||
border-radius: 3px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
|
||||
/* ===== Type 5: 视频 ===== */
|
||||
.video-area {
|
||||
margin: 6px 0;
|
||||
}
|
||||
|
||||
.video-area {
|
||||
margin: 6px 0;
|
||||
height: 240px;
|
||||
border-radius: 4px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.card-video {
|
||||
width: 100%;
|
||||
height: 240px;
|
||||
}
|
||||
</style>
|
||||
在新工单中引用
屏蔽一个用户