郑诗鹏 2 months ago
commit 8346b44c3c

@ -0,0 +1,39 @@
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background-color: #f0f0f0;
}
.calculator {
background-color: white;
padding: 20px;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.display {
background-color: #222;
color: white;
text-align: right;
padding: 20px;
font-size: 2em;
border-radius: 5px;
margin-bottom: 10px;
}
.buttons {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 10px;
}
button {
padding: 20px;
font-size: 1.5em;
border: none;
border-radius: 5px;
cursor: pointer;
transition: background-color 0.3s;
}
button:hover {
background-color: #eee;
}

@ -0,0 +1,38 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>手机计算器</title>
<link rel="stylesheet" href="css/styles.css">
<script type="text/javascript">
</script>
</head>
<body>
<div class="calculator">
<div class="display" id="display">0</div>
<div class="buttons">
<button onclick="clearDisplay('C')">C</button>
<button onclick="chooseOperation('%')">%</button>
<button></button>
<button onclick="chooseOperation('/')">/</button>
<button onclick="appendNumber('7')">7</button>
<button onclick="appendNumber('8')">8</button>
<button onclick="appendNumber('9')">9</button>
<button onclick="chooseOperation('*')">×</button>
<button onclick="appendNumber('4')">4</button>
<button onclick="appendNumber('5')">5</button>
<button onclick="appendNumber('6')">6</button>
<button onclick="chooseOperation('-')">-</button>
<button onclick="appendNumber('1')">1</button>
<button onclick="appendNumber('2')">2</button>
<button onclick="appendNumber('3')">3</button>
<button onclick="chooseOperation('+')">+</button>
<button onclick="appendNumber('0')">0</button>
<button onclick="appendDecimal('.')">.</button>
<button onclick="calculateResult('=')">=</button>
</div>
</div>
<script src="js/script.js"></script>
</body>
</html>

@ -0,0 +1,71 @@
let display = document.getElementById('display');
let currentInput = '';
let previousInput = '';
let operation = null;
function appendNumber(number) {
currentInput += number;
display.textContent = currentInput;
}
function appendDecimal(dot) {
if (!currentInput.includes(dot)) {
currentInput += dot;
display.textContent = currentInput;
}
}
function chooseOperation(op) {
if (currentInput === '') return;
if (previousInput !== '') {
calculateResult();
}
operation = op;
previousInput = parseFloat(currentInput);
currentInput = '';
}
function clearDisplay(clear) {
if (clear === 'C') {
display.textContent = '0';
currentInput = '';
previousInput = '';
operation = null;
} else if (clear === 'AC') {
// Full reset (not implemented in basic example)
}
}
function calculateResult(equals) {
let result;
const prev = previousInput;
const curr = parseFloat(currentInput);
if (isNaN(prev) || isNaN(curr)) return;
switch (operation) {
case '+':
result = prev + curr;
break;
case '-':
result = prev - curr;
break;
case '*':
result = prev * curr;
break;
case '/':
result = prev / curr;
break;
case '%':
result = prev % curr;
break;
default:
return;
}
display.textContent = result;
previousInput = result;
currentInput = '';
operation = null;
}
// Bind equals button to calculate result
document.querySelector('button[onclick="calculateResult(\'=\')"]').addEventListener('click', calculateResult);

@ -0,0 +1,203 @@
{
"@platforms": ["android", "iPhone", "iPad"],
"id" : "",/**/
"name" : "t1",/**/
"version": {
"name": "1.0",/**/
"code": "100"
},
"description": "",/**/
"icons": {
"72": "icon.png"
},
"launch_path": "index.html",/*index.htmlhttp://https://*/
"developer": {
"name": "",/**/
"email": "",/**/
"url": ""/**/
},
"permissions": {
"Accelerometer": {
"description": "访问加速度感应器"
},
"Audio": {
"description": "访问麦克风"
},
"Messaging":{
"description": "短彩邮件插件"
},
"Cache": {
"description": "管理应用缓存"
},
"Camera": {
"description": "访问摄像头"
},
"Console": {
"description": "跟踪调试输出日志"
},
"Contacts": {
"description": "访问系统联系人信息"
},
"Device": {
"description": "访问设备信息"
},
"Downloader": {
"description": "文件下载管理"
},
"Events": {
"description": "应用扩展事件"
},
"File": {
"description": "访问本地文件系统"
},
"Gallery": {
"description": "访问系统相册"
},
"Geolocation": {
"description": "访问位置信息"
},
"Invocation": {
"description": "使用Native.js能力"
},
"Orientation": {
"description": "访问方向感应器"
},
"Proximity": {
"description": "访问距离感应器"
},
"Storage": {
"description": "管理应用本地数据"
},
"Uploader": {
"description": "管理文件上传任务"
},
"Runtime": {
"description": "访问运行期环境"
},
"XMLHttpRequest": {
"description": "跨域网络访问"
},
"Zip": {
"description": "文件压缩与解压缩"
},
"Barcode": {
"description": "管理二维码扫描插件"
},
"Maps": {
"description": "管理地图插件"
},
"Speech": {
"description": "管理语音识别插件"
},
"Webview":{
"description": "窗口管理"
},
"NativeUI":{
"description": "原生UI控件"
},
"Navigator":{
"description": "浏览器信息"
},
"NativeObj":{
"description": "原生对象"
}
},
"plus": {
"splashscreen": {
"autoclose": true,/*truefalseplus.navigator.closeSplashscreen()*/
"waiting": true/*truefalse*/
},
"popGesture": "close",/*Webview"none""hide"Webviewhttp://ask.dcloud.net.cn/article/102*/
"runmode": "normal",/*liberatenormalliberateAndroidFile API访_www*/
"signature": "Sk9JTiBVUyBtYWlsdG86aHIyMDEzQGRjbG91ZC5pbw==",/*使*/
"distribute": {
"apple": {
"appid": "",/*iOSappidio.dcloud.HelloH5*/
"mobileprovision": "",/*iOS*/
"password": "",/*iOS*/
"p12": "",/*iOS*/
"devices": "universal",/*iOSiphone/ipad/universal*/
"frameworks":[
]/*Native.jsObjective-c APIFrameWorkGameCenter"GameKit.framework"*/
},
"google": {
"packagename": "",/*Androidio.dcloud.HelloH5*/
"keystore": "",/*Android使*/
"password": "",/*Android使*/
"aliasname": "",/*Android使*/
"permissions": ["<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>","<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>","<uses-permission android:name=\"android.permission.READ_CONTACTS\"/>","<uses-permission android:name=\"android.permission.VIBRATE\"/>","<uses-permission android:name=\"android.permission.READ_LOGS\"/>","<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>","<uses-feature android:name=\"android.hardware.camera.autofocus\"/>","<uses-permission android:name=\"android.permission.WRITE_CONTACTS\"/>","<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>","<uses-permission android:name=\"android.permission.CAMERA\"/>","<uses-permission android:name=\"android.permission.RECORD_AUDIO\"/>","<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>","<uses-permission android:name=\"android.permission.MODIFY_AUDIO_SETTINGS\"/>","<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>","<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>","<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>","<uses-permission android:name=\"android.permission.CALL_PHONE\"/>","<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>","<uses-permission android:name=\"android.permission.ACCESS_COARSE_LOCATION\"/>","<uses-feature android:name=\"android.hardware.camera\"/>","<uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\"/>","<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"]
/*使Native.jsAPI使*/
},
"orientation": [
"portrait-primary"
],/*portrait-primaryportrait-secondarylandscape-primarylandscape-secondary*/
"icons": {
"ios": {
"prerendered": true, /*iOS6*/
"auto": "", /*512x512*/
"iphone": {
"normal": "", /*iPhone3/3GS57x57*/
"retina": "", /*iPhone4114x114*/
"retina7": "", /*iPhone4S/5/6120x120*/
"retina8": "", /*iPhone6 Plus180x180*/
"spotlight-normal": "", /*iPhone3/3GS Spotlight29x29*/
"spotlight-retina": "", /*iPhone4 Spotlight58x58*/
"spotlight-retina7": "", /*iPhone4S/5/6 Spotlight80x80*/
"settings-normal": "", /*iPhone429x29*/
"settings-retina": "", /*iPhone4S/5/658x58*/
"settings-retina8": "" /*iPhone6Plus87x87*/
},
"ipad": {
"normal": "", /*iPad72x72*/
"retina": "", /*iPad144x144*/
"normal7": "", /*iPad iOS776x76*/
"retina7": "", /*iPad iOS7152x152*/
"spotlight-normal": "", /*iPad Spotlight50x50*/
"spotlight-retina": "", /*iPadSpotlight100x100*/
"spotlight-normal7": "",/*iPad iOS7 Spotlight40x40*/
"spotlight-retina7": "",/*iPad iOS7Spotlight80x80*/
"settings-normal": "",/*iPad29x29*/
"settings-retina": "" /*iPad58x58*/
}
},
"android": {
"mdpi": "", /*48x48*/
"ldpi": "", /*48x48*/
"hdpi": "", /*72x72*/
"xhdpi": "",/*720P96x96*/
"xxhdpi": ""/*1080P 144x144*/
}
},
"splashscreen": {
"ios": {
"iphone": {
"default": "", /*iPhone3320x480*/
"retina35": "",/*3.5(iPhone4)640x960*/
"retina40": "",/*4.0 (iPhone5/iPhone5s)640x1136*/
"retina47": "",/*4.7 (iPhone6)750x1334*/
"retina55": "",/*5.5 (iPhone6 Plus)1242x2208*/
"retina55l": ""/*5.5 (iPhone6 Plus)2208x1242*/
},
"ipad": {
"portrait": "", /*iPad768x1004*/
"portrait-retina": "",/*iPad1536x2008*/
"landscape": "", /*iPad1024x748*/
"landscape-retina": "", /*iPad2048x1496*/
"portrait7": "", /*iPad iOS7768x1024*/
"portrait-retina7": "",/*iPad iOS71536x2048*/
"landscape7": "", /*iPad iOS71024x768*/
"landscape-retina7": ""/*iPad iOS72048x1536*/
}
},
"android": {
"mdpi": "", /*240x282*/
"ldpi": "", /*320x442*/
"hdpi": "", /*480x762*/
"xhdpi": "", /*720P720x1242*/
"xxhdpi": ""/*1080P1080x1882*/
}
}
}
}
}
Loading…
Cancel
Save