Compare commits

..

No commits in common. "0eecc8ce90b81c0ecb13ad2ceefe216e87744333" and "2adcdaf91ff5ab642aff1caff7edc31296968f91" have entirely different histories.

15 changed files with 1604 additions and 84 deletions

1
.gitignore vendored
View File

@ -16,4 +16,3 @@ local.properties
/StandAPP/.idea /StandAPP/.idea
/StandAPP/app/release /StandAPP/app/release
/.idea/ /.idea/
".idea/"

3
.idea/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AndroidProjectSystem">
<option name="providerId" value="com.android.tools.idea.GradleProjectSystem" />
</component>
</project>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="deploymentTargetSelector">
<selectionStates>
<SelectionState runConfigName="StandAPP.app">
<option name="selectionMode" value="DROPDOWN" />
</SelectionState>
</selectionStates>
</component>
</project>

13
.idea/deviceManager.xml Normal file
View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DeviceTable">
<option name="columnSorters">
<list>
<ColumnSorterState>
<option name="column" value="Name" />
<option name="order" value="ASCENDING" />
</ColumnSorterState>
</list>
</option>
</component>
</project>

18
.idea/gradle.xml Normal file
View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="testRunner" value="CHOOSE_PER_TEST" />
<option name="externalProjectPath" value="$PROJECT_DIR$/StandAPP" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$/StandAPP" />
<option value="$PROJECT_DIR$/StandAPP/app" />
</set>
</option>
</GradleProjectSettings>
</option>
</component>
</project>

7
.idea/misc.xml Normal file
View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="temurin-17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

8
.idea/modules.xml Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/StandAPP-Project.iml" filepath="$PROJECT_DIR$/.idea/StandAPP-Project.iml" />
</modules>
</component>
</project>

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunConfigurationProducerService">
<option name="ignoredProducers">
<set>
<option value="com.intellij.execution.junit.AbstractAllInDirectoryConfigurationProducer" />
<option value="com.intellij.execution.junit.AllInPackageConfigurationProducer" />
<option value="com.intellij.execution.junit.PatternConfigurationProducer" />
<option value="com.intellij.execution.junit.TestInClassConfigurationProducer" />
<option value="com.intellij.execution.junit.UniqueIdConfigurationProducer" />
<option value="com.intellij.execution.junit.testDiscovery.JUnitTestDiscoveryConfigurationProducer" />
<option value="org.jetbrains.kotlin.idea.junit.KotlinJUnitRunConfigurationProducer" />
<option value="org.jetbrains.kotlin.idea.junit.KotlinPatternConfigurationProducer" />
</set>
</option>
</component>
</project>

6
.idea/vcs.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

View File

@ -11,8 +11,8 @@ android {
applicationId = "com.stand.standapp" applicationId = "com.stand.standapp"
minSdk = 24 minSdk = 24
targetSdk = 34 targetSdk = 34
versionCode = 2 versionCode = 1
versionName = "1.0.1" versionName = "1.0.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
} }

View File

@ -43,19 +43,6 @@
.log-item { margin-bottom: 4px; border-bottom: 1px solid #334155; padding-bottom: 2px; } .log-item { margin-bottom: 4px; border-bottom: 1px solid #334155; padding-bottom: 2px; }
.log-time { color: #94a3b8; margin-right: 5px; } .log-time { color: #94a3b8; margin-right: 5px; }
.log-msg { word-break: break-all; } .log-msg { word-break: break-all; }
/* Custom Modal Styles */
.modal-overlay {
display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
background: rgba(0,0,0,0.5); z-index: 1000; align-items: center; justify-content: center;
}
.modal-content {
background: white; padding: 20px; border-radius: 12px; width: 85%; max-width: 400px;
box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}
.modal-header { font-weight: bold; font-size: 18px; margin-bottom: 15px; color: #004A8F; border-bottom: 1px solid #eee; padding-bottom: 10px; }
.modal-body { font-size: 14px; line-height: 1.8; color: #444; word-break: break-all; }
.modal-footer { margin-top: 20px; text-align: right; }
</style> </style>
</head> </head>
<body> <body>
@ -79,8 +66,7 @@
<p style="font-size: 12px; color: #666;">(适用于蓝牙/USB 小票机,传输原始 JSON)</p> <p style="font-size: 12px; color: #666;">(适用于蓝牙/USB 小票机,传输原始 JSON)</p>
<button class="btn btn-orange" onclick="callUpdate()">3. 检查系统更新</button> <button class="btn btn-orange" onclick="callUpdate()">3. 检查系统更新</button>
<button class="btn" style="background: #64748b;" onclick="callAbout()">4. 关于应用</button> <button class="btn btn-red" onclick="callExit()">4. 退出应用</button>
<button class="btn btn-red" onclick="callExit()">5. 退出应用</button>
<!-- WebSocket 控制区 --> <!-- WebSocket 控制区 -->
<div class="ws-card"> <div class="ws-card">
@ -191,19 +177,6 @@
Telewave SDK Connectivity v1.0 Telewave SDK Connectivity v1.0
</div> </div>
<!-- 自定义“关于”弹窗 -->
<div id="aboutModal" class="modal-overlay" onclick="closeAbout()">
<div class="modal-content" onclick="event.stopPropagation()">
<div class="modal-header">关于应用信息</div>
<div id="aboutBody" class="modal-body">
正在获取信息...
</div>
<div class="modal-footer">
<button class="btn" style="padding: 10px 20px; background: #64748b; margin: 0;" onclick="closeAbout()">确认</button>
</div>
</div>
</div>
<script> <script>
// 初始化界面 // 初始化界面
document.getElementById('current-time').innerText = new Date().toLocaleString(); document.getElementById('current-time').innerText = new Date().toLocaleString();
@ -266,32 +239,6 @@
} }
} }
function callAbout() {
if (window.android && window.android.getAboutInfo) {
const infoStr = window.android.getAboutInfo();
try {
const info = JSON.parse(infoStr);
const html = `
<strong>应用名称:</strong> ${info.appName}<br>
<strong>版本号:</strong> <span style="color: #3b82f6;">${info.versionName}</span><br>
<strong>设备型号:</strong> ${info.model}<br>
<strong>系统版本:</strong> Android ${info.osVersion}
`;
document.getElementById('aboutBody').innerHTML = html;
document.getElementById('aboutModal').style.display = 'flex';
} catch (e) {
document.getElementById('aboutBody').innerText = "获取信息解析失败: " + infoStr;
document.getElementById('aboutModal').style.display = 'flex';
}
} else {
alert("关于接口未就绪");
}
}
function closeAbout() {
document.getElementById('aboutModal').style.display = 'none';
}
// 安卓回调函数:退出确认时执行 // 安卓回调函数:退出确认时执行
function addExitText() { function addExitText() {
const tag = document.getElementById('inject-status'); const tag = document.getElementById('inject-status');
@ -311,7 +258,6 @@
let clientId = "WEB_" + Math.random().toString(36).substr(2, 9); let clientId = "WEB_" + Math.random().toString(36).substr(2, 9);
let heartbeatTimer = null; let heartbeatTimer = null;
let reconnectTimer = null; let reconnectTimer = null;
let isManualClose = false; // 新增:手动断开标记
const logList = document.getElementById('log-list'); const logList = document.getElementById('log-list');
document.getElementById('ws-client-id').innerText = clientId; document.getElementById('ws-client-id').innerText = clientId;
@ -355,7 +301,6 @@
const finalUrl = rawUrl.replace("{clientId}", clientId); const finalUrl = rawUrl.replace("{clientId}", clientId);
addLog("正在尝试连接: " + finalUrl, false); addLog("正在尝试连接: " + finalUrl, false);
isManualClose = false; // 启动连接时重置标记
try { try {
ws = new WebSocket(finalUrl); ws = new WebSocket(finalUrl);
@ -379,12 +324,8 @@
updateWSStatus(false); updateWSStatus(false);
addLog("连接关闭", false); addLog("连接关闭", false);
stopHeartbeat(); stopHeartbeat();
// 5秒后自动重连
// 只有非手动断开(如网络异常)时才自动重连
if (!isManualClose) {
addLog("异常断开5秒后自动重连...", false);
reconnectTimer = setTimeout(connectWS, 5000); reconnectTimer = setTimeout(connectWS, 5000);
}
}; };
ws.onerror = (err) => { ws.onerror = (err) => {
@ -398,7 +339,6 @@
function toggleWS() { function toggleWS() {
if (ws && ws.readyState === WebSocket.OPEN) { if (ws && ws.readyState === WebSocket.OPEN) {
isManualClose = true; // 标记为手动断开
clearTimeout(reconnectTimer); clearTimeout(reconnectTimer);
reconnectTimer = null; reconnectTimer = null;
ws.close(); ws.close();

View File

@ -103,24 +103,6 @@ class AndroidInterface(private val activity: MainActivity) {
} }
} }
/**
* JS 调用获取关于信息
*/
@JavascriptInterface
fun getAboutInfo(): String {
return try {
val packageInfo = activity.packageManager.getPackageInfo(activity.packageName, 0)
val json = org.json.JSONObject()
json.put("appName", activity.getString(R.string.app_name))
json.put("versionName", packageInfo.versionName)
json.put("model", android.os.Build.MODEL)
json.put("osVersion", android.os.Build.VERSION.RELEASE)
json.toString()
} catch (e: Exception) {
"{ \"appName\": \"StandApp\", \"versionName\": \"1.0.0\" }"
}
}
/** /**
* JS 调用保存消息记录 * JS 调用保存消息记录
*/ */