Initial qiwei secondary development handoff
This commit is contained in:
76
frontend/js/app.js
Normal file
76
frontend/js/app.js
Normal file
@@ -0,0 +1,76 @@
|
||||
// 等待DOM加载完成
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
try {
|
||||
// 导入Wails运行时API
|
||||
import('../wailsjs/runtime/runtime.js').then(({ LogInfo, LogDebug, LogError }) => {
|
||||
LogInfo('StarBot Pro frontend loaded successfully');
|
||||
|
||||
// 简化版本 - 只保留基本功能,移除可能导致问题的动画和复杂操作
|
||||
|
||||
// 侧边栏导航项点击事件 - 简化版
|
||||
const navItems = document.querySelectorAll('nav ul li');
|
||||
if (navItems.length > 0) {
|
||||
navItems.forEach(item => {
|
||||
item.addEventListener('click', function() {
|
||||
LogDebug('导航项点击:', this.textContent.trim());
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// 充值按钮点击事件 - 简化版
|
||||
const rechargeBtn = document.querySelector('#rechargeBtn');
|
||||
if (rechargeBtn) {
|
||||
rechargeBtn.addEventListener('click', function() {
|
||||
LogDebug('充值按钮点击');
|
||||
});
|
||||
}
|
||||
|
||||
// 添加账号按钮点击事件 - 简化版
|
||||
const addAccountBtn = document.querySelector('#addAccountBtn');
|
||||
if (addAccountBtn) {
|
||||
addAccountBtn.addEventListener('click', function() {
|
||||
LogDebug('添加账号按钮点击');
|
||||
});
|
||||
}
|
||||
|
||||
// 在页面上显示加载成功信息
|
||||
const statusEl = document.createElement('div');
|
||||
statusEl.style.position = 'fixed';
|
||||
statusEl.style.bottom = '20px';
|
||||
statusEl.style.right = '20px';
|
||||
statusEl.style.padding = '10px';
|
||||
statusEl.style.backgroundColor = '#2ecc71';
|
||||
statusEl.style.color = 'white';
|
||||
statusEl.style.borderRadius = '4px';
|
||||
statusEl.textContent = '前端加载成功';
|
||||
document.body.appendChild(statusEl);
|
||||
}).catch(error => {
|
||||
console.error('Failed to import Wails runtime:', error);
|
||||
// 在页面上显示加载成功信息作为备选
|
||||
const statusEl = document.createElement('div');
|
||||
statusEl.style.position = 'fixed';
|
||||
statusEl.style.bottom = '20px';
|
||||
statusEl.style.right = '20px';
|
||||
statusEl.style.padding = '10px';
|
||||
statusEl.style.backgroundColor = '#2ecc71';
|
||||
statusEl.style.color = 'white';
|
||||
statusEl.style.borderRadius = '4px';
|
||||
statusEl.textContent = '前端加载成功';
|
||||
document.body.appendChild(statusEl);
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
console.error('Frontend error:', error);
|
||||
// 在页面上显示错误信息
|
||||
const errorEl = document.createElement('div');
|
||||
errorEl.style.position = 'fixed';
|
||||
errorEl.style.bottom = '20px';
|
||||
errorEl.style.right = '20px';
|
||||
errorEl.style.padding = '10px';
|
||||
errorEl.style.backgroundColor = '#e74c3c';
|
||||
errorEl.style.color = 'white';
|
||||
errorEl.style.borderRadius = '4px';
|
||||
errorEl.textContent = '前端加载错误: ' + error.message;
|
||||
document.body.appendChild(errorEl);
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user