backup: snapshot before optimization

This commit is contained in:
2026-06-04 16:25:43 +08:00
commit ff2700c067
47 changed files with 3332 additions and 0 deletions
+104
View File
@@ -0,0 +1,104 @@
var storage = require('../../utils/storage')
var themeMod = require('../../utils/theme')
Page({
data: {
theme: { primary: '#FF6B35', primaryLight: '#FF8C5A', primaryBg: '#FFF3ED', primaryRgb: '255,107,53' },
themeStyle: '',
themes: themeMod.THEMES,
currentThemeId: 'orange',
plans: [
{ id: 'beginner', name: '初级', desc: '7天计划 · 30秒起步', days: 7 },
{ id: 'intermediate', name: '中级', desc: '14天计划 · 60秒起步', days: 14 },
{ id: 'advanced', name: '高级', desc: '30天计划 · 90秒起步', days: 30 }
],
currentPlanId: 'beginner',
dailyReminder: true,
reminderTime: '08:00',
voiceGuide: true,
vibrate: true
},
onLoad: function () {
var s = storage.getSettings()
var theme = themeMod.getCurrentTheme()
themeMod.applyThemeToPage(this)
this.setData({
currentPlanId: s.planId,
dailyReminder: s.dailyReminder,
reminderTime: s.reminderTime,
voiceGuide: s.voiceGuide,
vibrate: s.vibrate,
currentThemeId: theme.id
})
},
onShow: function () {
try {
var tb = this.getTabBar()
if (tb) tb.setData({ selected: 2 })
} catch (e) {}
themeMod.applyThemeToPage(this)
},
onSelectTheme: function (e) {
var id = e.currentTarget.dataset.id
var theme = themeMod.setTheme(id)
this.setData({ currentThemeId: id })
try {
var tb = this.getTabBar()
if (tb) {
tb.setData({ themeStyle: themeMod.getThemeStyle(theme) })
}
} catch (e) {}
themeMod.applyThemeToPage(this)
},
onSelectPlan: function (e) {
var planId = e.currentTarget.dataset.id
var s = storage.getSettings()
s.planId = planId
storage.saveSettings(s)
this.setData({ currentPlanId: planId })
wx.showToast({ title: '计划已切换', icon: 'success', duration: 1200 })
},
onToggleReminder: function (e) {
var s = storage.getSettings()
s.dailyReminder = e.detail.value
storage.saveSettings(s)
this.setData({ dailyReminder: e.detail.value })
},
onReminderTimeChange: function (e) {
var s = storage.getSettings()
s.reminderTime = e.detail.value
storage.saveSettings(s)
this.setData({ reminderTime: e.detail.value })
},
onToggleVoice: function (e) {
var s = storage.getSettings()
s.voiceGuide = e.detail.value
storage.saveSettings(s)
this.setData({ voiceGuide: e.detail.value })
},
onToggleVibrate: function (e) {
var s = storage.getSettings()
s.vibrate = e.detail.value
storage.saveSettings(s)
this.setData({ vibrate: e.detail.value })
},
onCopyWechat: function () {
wx.setClipboardData({
data: '刘承',
success: function () {
wx.showToast({ title: '已复制', icon: 'success', duration: 1500 })
}
})
}
})
+4
View File
@@ -0,0 +1,4 @@
{
"usingComponents": {},
"navigationBarTitleText": "设置"
}
+115
View File
@@ -0,0 +1,115 @@
<view class="container" style="{{themeStyle}}">
<!-- 配色方案 -->
<view class="card">
<view class="section-header">
<text class="section-emoji">🎨</text>
<text class="section-title">配色方案</text>
</view>
<view class="theme-list">
<view
class="theme-item {{currentThemeId === item.id ? 'active' : ''}}"
wx:for="{{themes}}"
wx:key="id"
data-id="{{item.id}}"
bindtap="onSelectTheme"
>
<view class="theme-color-dot" style="background: {{item.primary}};"></view>
<text class="theme-name">{{item.name}}</text>
<text class="plan-check" wx:if="{{currentThemeId === item.id}}">✓</text>
</view>
</view>
</view>
<!-- 训练计划选择 -->
<view class="card">
<view class="section-header">
<text class="section-emoji">📋</text>
<text class="section-title">训练计划</text>
</view>
<view class="plan-list">
<view
class="plan-item {{currentPlanId === item.id ? 'active' : ''}}"
wx:for="{{plans}}"
wx:key="id"
data-id="{{item.id}}"
bindtap="onSelectPlan"
>
<view class="plan-radio">
<view class="radio-dot" wx:if="{{currentPlanId === item.id}}"></view>
</view>
<view class="plan-content">
<text class="plan-item-name">{{item.name}}</text>
<text class="plan-item-desc">{{item.desc}}</text>
</view>
<text class="plan-check" wx:if="{{currentPlanId === item.id}}">✓</text>
</view>
</view>
</view>
<!-- 提醒设置 -->
<view class="card">
<view class="section-header">
<text class="section-emoji">🔔</text>
<text class="section-title">提醒</text>
</view>
<view class="setting-row">
<view class="setting-left">
<text class="setting-icon">📅</text>
<text class="setting-label">每日提醒</text>
</view>
<switch checked="{{dailyReminder}}" bindchange="onToggleReminder" color="{{theme.primary}}"/>
</view>
<view class="setting-row" wx:if="{{dailyReminder}}">
<view class="setting-left">
<text class="setting-icon">🕐</text>
<text class="setting-label">提醒时间</text>
</view>
<picker mode="time" value="{{reminderTime}}" bindchange="onReminderTimeChange">
<text class="setting-value">{{reminderTime}}</text>
</picker>
</view>
</view>
<!-- 训练偏好 -->
<view class="card">
<view class="section-header">
<text class="section-emoji">⚙</text>
<text class="section-title">训练偏好</text>
</view>
<view class="setting-row">
<view class="setting-left">
<text class="setting-icon">🔊</text>
<text class="setting-label">语音引导</text>
</view>
<switch checked="{{voiceGuide}}" bindchange="onToggleVoice" color="{{theme.primary}}"/>
</view>
<view class="setting-row">
<view class="setting-left">
<text class="setting-icon">📳</text>
<text class="setting-label">振动反馈</text>
</view>
<switch checked="{{vibrate}}" bindchange="onToggleVibrate" color="{{theme.primary}}"/>
</view>
</view>
<!-- 关于 -->
<view class="card about-card">
<view class="section-header">
<text class="section-emoji"></text>
<text class="section-title">关于</text>
</view>
<view class="about-list">
<view class="about-row">
<text class="about-label">版本</text>
<text class="about-value">v1.0.0</text>
</view>
<view class="about-row" bindtap="onCopyWechat">
<text class="about-label">开发者</text>
<text class="about-value about-link">刘承</text>
</view>
</view>
<view class="about-footer">
<text class="about-copy">Made with ❤️ for better fitness</text>
</view>
</view>
</view>
+220
View File
@@ -0,0 +1,220 @@
.section-header {
display: flex;
align-items: center;
margin-bottom: 20rpx;
}
.section-emoji {
font-size: 28rpx;
margin-right: 10rpx;
line-height: 1;
}
.section-header .section-title {
margin-bottom: 0;
}
/* ---- theme picker ---- */
.theme-list {
margin-top: 0;
}
.theme-item {
display: flex;
align-items: center;
padding: 22rpx 0;
border-bottom: 1rpx solid var(--border);
transition: background 0.2s ease;
}
.theme-item:last-child {
border-bottom: none;
}
.theme-item.active {
background: var(--primary-bg);
margin: 0 -32rpx;
padding-left: 32rpx;
padding-right: 32rpx;
border-radius: 16rpx;
border-bottom: none;
}
.theme-item.active + .theme-item {
border-top: 1rpx solid transparent;
}
.theme-color-dot {
width: 44rpx;
height: 44rpx;
border-radius: 50%;
margin-right: 20rpx;
flex-shrink: 0;
box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.15);
transition: transform 0.2s ease;
}
.theme-item:active .theme-color-dot {
transform: scale(1.15);
}
.theme-name {
flex: 1;
font-size: 28rpx;
color: var(--text);
}
/* ---- plan list ---- */
.plan-list {
margin-top: 0;
}
.plan-item {
display: flex;
align-items: center;
padding: 24rpx 0;
border-bottom: 1rpx solid var(--border);
}
.plan-item:last-child {
border-bottom: none;
}
.plan-item.active {
background: var(--primary-bg);
margin: 0 -32rpx;
padding-left: 32rpx;
padding-right: 32rpx;
border-radius: 16rpx;
border-bottom: none;
}
.plan-radio {
width: 40rpx;
height: 40rpx;
border: 3rpx solid #DDD;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
margin-right: 20rpx;
flex-shrink: 0;
transition: border-color 0.2s;
}
.plan-item.active .plan-radio {
border-color: var(--primary);
}
.radio-dot {
width: 22rpx;
height: 22rpx;
background: var(--primary);
border-radius: 50%;
animation: popIn 0.3s ease;
}
.plan-content {
flex: 1;
display: flex;
flex-direction: column;
}
.plan-item-name {
font-size: 28rpx;
font-weight: 600;
color: var(--text);
}
.plan-item-desc {
font-size: 22rpx;
color: var(--text-secondary);
margin-top: 4rpx;
}
.plan-check {
color: var(--primary);
font-size: 32rpx;
font-weight: 700;
}
/* ---- setting rows ---- */
.setting-row {
display: flex;
justify-content: space-between;
align-items: center;
padding: 20rpx 0;
border-bottom: 1rpx solid var(--border);
}
.setting-row:last-child {
border-bottom: none;
}
.setting-left {
display: flex;
align-items: center;
}
.setting-icon {
font-size: 28rpx;
margin-right: 12rpx;
}
.setting-label {
font-size: 28rpx;
color: var(--text);
}
.setting-value {
font-size: 28rpx;
color: var(--primary);
}
/* ---- about ---- */
.about-card {
margin-top: 8rpx;
}
.about-list {
margin-top: 12rpx;
}
.about-row {
display: flex;
justify-content: space-between;
align-items: center;
padding: 18rpx 0;
border-bottom: 1rpx solid var(--border);
}
.about-row:last-child {
border-bottom: none;
}
.about-label {
font-size: 26rpx;
color: var(--text-secondary);
}
.about-value {
font-size: 26rpx;
color: var(--text);
}
.about-link {
color: var(--primary);
font-weight: 500;
}
.about-footer {
margin-top: 24rpx;
padding-top: 20rpx;
border-top: 1rpx solid var(--border);
text-align: center;
}
.about-copy {
font-size: 22rpx;
color: #CCCCCC;
}