feat: 新增控笔练习,增加首页公告

This commit is contained in:
R524809
2026-05-29 10:21:39 +08:00
parent 2f0c4ab591
commit a6e8f4df02
28 changed files with 1045 additions and 672 deletions
+21
View File
@@ -1,6 +1,7 @@
import { CATEGORY_LIST_WITH_ALL } from '../../core/data/categories';
import { AGE_BANDS } from '../../core/data/difficulty';
import { CategoryId } from '../../core/models/category';
import { APP_VERSION, APP_VERSION_NOTE } from '../../config/config';
export type HomeDisplayItem = {
id: string;
@@ -59,6 +60,26 @@ const HOME_AGE_BANDS: HomeDisplayDataset['ageBands'] = AGE_BANDS.map(
}),
);
/** 首页跑马灯公告条(不随云端配置变化) */
export type HomeNotice = {
id: string;
text: string;
/** 可选跳转路径,为空则点击不跳转 */
path?: string;
};
export const HOME_NOTICES: HomeNotice[] = [
{
id: 'welcome',
text: '欢迎来到 涂鸦丫,趣味练习纸任你选',
},
{
id: `update-${APP_VERSION}`,
text: `${APP_VERSION} 上线:${APP_VERSION_NOTE}`,
path: '/chinesePages/penControlSheet/penControlSheet',
},
];
/** 首页固定:每日打卡练习(不随云端配置变化) */
export const HOME_DAILY_CHECKIN_ITEMS: HomeDisplayItem[] = [
{
+86
View File
@@ -48,6 +48,92 @@
margin-top: 48rpx;
}
.home-notice-bar {
display: flex;
align-items: center;
margin: 24rpx @page-padding-x 0;
padding: 0 24rpx;
height: 64rpx;
border-radius: 999rpx;
background: fade(#ff8f1f, 10%);
overflow: hidden;
box-sizing: border-box;
}
.home-notice-bar__label {
display: flex;
align-items: center;
flex-shrink: 0;
margin-right: 16rpx;
padding-right: 16rpx;
border-right: 2rpx solid fade(#b06b1a, 30%);
height: 36rpx;
}
.home-notice-bar__icon {
font-size: 26rpx;
line-height: 1;
}
.home-notice-bar__label-text {
margin-left: 8rpx;
font-size: 22rpx;
font-weight: 700;
color: #b06b1a;
line-height: 1;
}
.home-notice-bar__viewport {
flex: 1;
min-width: 0;
overflow: hidden;
height: 100%;
display: flex;
align-items: center;
}
.home-notice-bar__track {
display: inline-flex;
flex-wrap: nowrap;
white-space: nowrap;
animation: home-notice-scroll 12s linear infinite;
will-change: transform;
}
.home-notice-bar__group {
display: inline-flex;
flex-shrink: 0;
}
.home-notice-bar__item {
display: inline-flex;
align-items: center;
flex-shrink: 0;
}
.home-notice-bar__text {
font-size: 24rpx;
color: #7a4c12;
line-height: 1;
}
.home-notice-bar__sep {
margin: 0 24rpx;
font-size: 24rpx;
color: fade(#b06b1a, 50%);
line-height: 1;
}
@keyframes home-notice-scroll {
0% {
transform: translate3d(0, 0, 0);
}
100% {
transform: translate3d(-50%, 0, 0);
}
}
.home-hero-placeholder {
margin: @section-gap @page-padding-x 0;
height: 450rpx;
+8
View File
@@ -6,6 +6,7 @@ import {
} from '../../utils/index';
import {
HOME_DAILY_CHECKIN_ITEMS,
HOME_NOTICES,
createEmptyHomeDataset,
type HomeDisplayItem,
type HomeDisplaySection,
@@ -190,6 +191,7 @@ Page({
hotRecommends: SKELETON_HOT,
dailyCheckinItems: HOME_DAILY_CHECKIN_ITEMS.map(toItemView),
sections: [] as HomeDisplaySectionView[],
notices: HOME_NOTICES,
loading: true,
},
@@ -295,6 +297,12 @@ Page({
navigateByPath(path, title);
},
onTapNotice(e: WechatMiniprogram.TouchEvent) {
const path = e.currentTarget.dataset.path as string | undefined;
if (!path) return;
navigateByPath(path);
},
onTapCard(e: WechatMiniprogram.CustomEvent) {
const detail = (e.detail || {}) as { title?: string; path?: string };
const path =
+37
View File
@@ -22,6 +22,43 @@
bind:change="onTabChange" />
</view>
<view wx:if="{{notices.length > 0}}" class="home-notice-bar">
<view class="home-notice-bar__label">
<text class="home-notice-bar__icon">📣</text>
<text class="home-notice-bar__label-text">公告</text>
</view>
<view class="home-notice-bar__viewport">
<view class="home-notice-bar__track">
<view class="home-notice-bar__group">
<view
wx:for="{{notices}}"
wx:key="id"
class="home-notice-bar__item"
data-path="{{item.path}}"
bindtap="onTapNotice">
<text class="home-notice-bar__text"
>{{item.text}}</text
>
<text class="home-notice-bar__sep">·</text>
</view>
</view>
<view class="home-notice-bar__group" aria-hidden="true">
<view
wx:for="{{notices}}"
wx:key="id"
class="home-notice-bar__item"
data-path="{{item.path}}"
bindtap="onTapNotice">
<text class="home-notice-bar__text"
>{{item.text}}</text
>
<text class="home-notice-bar__sep">·</text>
</view>
</view>
</view>
</view>
</view>
<swiper
class="home-hero-swiper"
previous-margin="80rpx"
+2 -1
View File
@@ -1,4 +1,5 @@
import { disablePageShareMenu } from '../../base/pageMixin';
import { APP_VERSION } from '../../config/config';
import { getDownloadLogCount } from '../../utils/downloadLogs';
import { getFavoriteCount } from '../../utils/favorites';
import {
@@ -16,7 +17,7 @@ Page({
isDevEnv: false,
printCount: 0,
favoriteCount: 0,
version: '3.0.0',
version: APP_VERSION,
showProfileEditor: false,
draftNickName: '',
draftAvatarUrl: '/assets/imgs/doodle-head.png',