修改配色,修改功能

This commit is contained in:
2026-02-08 15:43:32 +08:00
parent 17e32d7cc1
commit fa1a8e083e
14 changed files with 441 additions and 119 deletions

View File

@@ -1,5 +1,5 @@
{
"navigationBarTitleText": "科学计算器",
"navigationBarBackgroundColor": "#1c1c1e",
"navigationBarTextStyle": "white"
"navigationBarBackgroundColor": "#EBF4F8",
"navigationBarTextStyle": "black"
}

View File

@@ -8,9 +8,27 @@ Page({
waitingForSecondOperand: false,
isScientific: false,
showHistory: false,
showHelp: false,
historyList: [] as Array<{expression: string, result: string}>
},
onShareAppMessage() {
return {
title: '便捷好用的科学计算器',
path: '/pages/calculator/calculator'
}
},
onShareTimeline() {
return {
title: '便捷好用的科学计算器'
}
},
toggleHelp() {
this.setData({ showHelp: !this.data.showHelp });
},
onLoad() {
// 从本地存储恢复历史记录
const saved = wx.getStorageSync('CALC_HISTORY');
@@ -34,6 +52,15 @@ Page({
});
},
switchMode(e: any) {
const mode = e.currentTarget.dataset.mode;
const isSci = (mode === 'scientific');
if (this.data.isScientific !== isSci) {
this.vibrate();
this.setData({ isScientific: isSci });
}
},
onDigit(e: any) {
this.vibrate();
const digit = e.currentTarget.dataset.digit;

View File

@@ -1,5 +1,42 @@
<!--pages/calculator/calculator.wxml-->
<view class="calculator-container">
<!-- 帮助说明面板 -->
<view class="history-panel {{showHelp ? 'show' : ''}}" catchtouchmove="preventTouchMove" style="z-index: 200;">
<view class="history-mask" bindtap="toggleHelp"></view>
<view class="history-content help-content">
<view class="history-header">
<text class="history-title">使用说明</text>
<text class="history-clear" bindtap="toggleHelp">关闭</text>
</view>
<scroll-view scroll-y class="history-list help-list">
<view class="help-section">
<view class="help-item">
<text class="help-icon">⚗️</text>
<view class="help-text">
<text class="help-h1">科学模式</text>
<text class="help-p">点击左上角“科学”按钮切换模式,支持三角函数(sin, cos, tan)、对数(log, ln)、指数(x²)、开方(√)等高级运算。</text>
</view>
</view>
<view class="help-item">
<text class="help-icon">🕐</text>
<view class="help-text">
<text class="help-h1">历史记录</text>
<text class="help-p">点击时钟图标查看过往计算记录,点击某条记录可将其结果填入当前计算。</text>
</view>
</view>
<view class="help-item">
<text class="help-icon">📋</text>
<view class="help-text">
<text class="help-h1">复制结果</text>
<text class="help-p">点击剪贴板图标可将当前显示结果复制到系统剪贴板。</text>
</view>
</view>
<button class="share-btn-large" open-type="share">分享给好友</button>
</view>
</scroll-view>
</view>
</view>
<!-- 历史记录面板 -->
<view class="history-panel {{showHistory ? 'show' : ''}}" catchtouchmove="preventTouchMove">
<view class="history-mask" bindtap="toggleHistory"></view>
@@ -28,8 +65,9 @@
<!-- 显示区域 -->
<view class="display-area">
<view class="display-top-bar">
<view class="mode-indicator" bindtap="toggleMode">
<text class="{{isScientific ? 'active' : ''}}">⚗️ 科学</text>
<view class="mode-indicator">
<text class="{{!isScientific ? 'active' : ''}}" bindtap="switchMode" data-mode="normal">常用</text>
<text class="{{isScientific ? 'active' : ''}}" bindtap="switchMode" data-mode="scientific">科学</text>
</view>
<view class="top-actions">
<view class="action-btn" bindtap="toggleHistory" hover-class="action-btn-hover" hover-stay-time="100">
@@ -38,6 +76,9 @@
<view class="action-btn" bindtap="copyResult" hover-class="action-btn-hover" hover-stay-time="100">
<text class="action-icon">📋</text>
</view>
<view class="action-btn" bindtap="toggleHelp" hover-class="action-btn-hover" hover-stay-time="100">
<text class="action-icon">❓</text>
</view>
</view>
</view>
<view class="history-text">{{history}}</view>

View File

@@ -38,42 +38,55 @@ page {
display: flex;
justify-content: space-between;
align-items: center;
z-index: 10;
}
.top-actions {
display: flex;
gap: 16rpx;
gap: 20rpx;
}
.action-btn {
width: 64rpx;
height: 64rpx;
width: 72rpx;
height: 72rpx;
display: flex;
align-items: center;
justify-content: center;
border-radius: 50%;
background: rgba(17, 97, 107, 0.1); /* Color 01 with opacity */
background: #ffffff;
box-shadow: 0 4rpx 12rpx rgba(17, 97, 107, 0.15); /* Teal shadow */
}
.action-icon {
font-size: 30rpx;
font-size: 36rpx;
color: #11616B; /* Color 01 */
}
/* 模式切换 */
.mode-indicator {
display: flex;
background: #ffffff;
padding: 6rpx;
border-radius: 16rpx; /* Reduced radius */
box-shadow: 0 4rpx 12rpx rgba(17, 97, 107, 0.1);
}
.mode-indicator text {
color: #7BBDB6; /* Color 02 text */
font-size: 24rpx;
padding: 10rpx 24rpx;
border-radius: 30rpx;
background: rgba(123, 189, 182, 0.2); /* Color 02 bg */
color: #7BBDB6; /* Color 02 */
font-size: 26rpx;
padding: 10rpx 30rpx;
border-radius: 12rpx; /* Reduced radius */
background: transparent;
border: none;
font-weight: 500;
transition: all 0.2s ease;
}
.mode-indicator text.active {
color: #11616B; /* Color 01 text */
background: rgba(17, 97, 107, 0.15); /* Color 01 bg */
color: #ffffff;
background: #11616B; /* Color 01 */
font-weight: 600;
box-shadow: 0 2rpx 8rpx rgba(17, 97, 107, 0.2);
}
/* 表达式行 */
@@ -260,7 +273,7 @@ page {
position: relative;
z-index: 101;
background: #EBF4F8; /* Color 03 */
border-radius: 0 0 36rpx 36rpx;
border-radius: 0 0 16rpx 16rpx; /* Reduced radius */
max-height: 70vh;
display: flex;
flex-direction: column;
@@ -306,25 +319,25 @@ page {
.history-item {
padding: 28rpx 40rpx;
border-bottom: 1rpx solid rgba(255,255,255,0.05);
border-bottom: 1rpx solid rgba(17, 97, 107, 0.08); /* Darker border for light bg */
display: flex;
flex-direction: column;
align-items: flex-end;
}
.history-item:active {
background: rgba(255,255,255,0.06);
background: rgba(17, 97, 107, 0.05); /* Dark interaction state */
}
.history-expr {
color: rgba(255,255,255,0.45);
color: rgba(17, 97, 107, 0.6); /* Color 01 faded - Visible on light bg */
font-size: 26rpx;
margin-bottom: 8rpx;
font-family: -apple-system, 'SF Pro Display', monospace;
}
.history-result {
color: #ffffff;
color: #11616B; /* Color 01 - Visible High Contrast */
font-size: 42rpx;
font-weight: 500;
font-family: -apple-system, 'SF Pro Display', 'Helvetica Neue', sans-serif;
@@ -344,6 +357,67 @@ page {
opacity: 0.5;
}
/* Help Panel Styles */
.help-list {
padding: 0; /* padding moved to inner section to avoid scroll-view width issues */
}
.help-section {
display: flex;
flex-direction: column;
gap: 40rpx;
padding: 30rpx 40rpx 60rpx; /* Apply padding here */
box-sizing: border-box;
}
.help-item {
display: flex;
gap: 24rpx;
align-items: flex-start;
}
.help-icon {
font-size: 44rpx;
width: 60rpx;
text-align: center;
padding-top: 4rpx;
}
.help-text {
flex: 1;
display: flex;
flex-direction: column;
}
.help-h1 {
font-size: 30rpx;
font-weight: bold;
color: #11616B; /* Color 01 */
margin-bottom: 12rpx;
}
.help-p {
font-size: 26rpx;
color: #2d3436;
line-height: 1.6;
opacity: 0.8;
}
.share-btn-large {
background-color: #11616B !important; /* Color 01 */
color: white !important;
border-radius: 16rpx !important; /* Unified radius */
font-size: 30rpx !important;
font-weight: 500 !important;
margin-top: 20rpx;
width: 100% !important;
box-shadow: 0 8rpx 20rpx rgba(17, 97, 107, 0.25);
display: flex;
align-items: center;
justify-content: center;
padding: 24rpx 0;
}
/* ========== 小屏适配 ========== */
@media (max-width: 360px) {
.btn {