统一样式
This commit is contained in:
67
01_文档/原型设计/navigation.js
Normal file
67
01_文档/原型设计/navigation.js
Normal file
@@ -0,0 +1,67 @@
|
||||
/* 打飞机对战小程序 - 页面导航功能 */
|
||||
|
||||
// 页面路径映射
|
||||
const routes = {
|
||||
'entry': '01_入口页面.html',
|
||||
'preparation': '04_准备页面.html',
|
||||
'battle': '05_对战页面.html',
|
||||
'roomWaiting': '02_房间等待[房主].html',
|
||||
'joinRoom': '03_加入房间列表.html'
|
||||
};
|
||||
|
||||
// 简单的触觉反馈
|
||||
function vibrate() {
|
||||
if ('vibrate' in navigator) {
|
||||
navigator.vibrate(10);
|
||||
}
|
||||
}
|
||||
|
||||
// 主要导航函数
|
||||
function navigateTo(routeKey) {
|
||||
vibrate();
|
||||
|
||||
const pagePath = routes[routeKey];
|
||||
if (!pagePath) {
|
||||
console.error('未找到路由:', routeKey);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('导航到:', pagePath);
|
||||
window.location.href = pagePath;
|
||||
}
|
||||
|
||||
// 游戏模式选择处理
|
||||
function handleGameModeSelection(mode) {
|
||||
vibrate();
|
||||
|
||||
switch(mode) {
|
||||
case 'quickStart':
|
||||
case 'onlineMatch':
|
||||
console.log(`${mode} - 进入准备页面`);
|
||||
navigateTo('preparation');
|
||||
break;
|
||||
case 'createRoom':
|
||||
console.log('createRoom - 进入房间等待页面');
|
||||
navigateTo('roomWaiting');
|
||||
break;
|
||||
case 'joinGame':
|
||||
console.log('joinGame - 进入房间列表页面');
|
||||
navigateTo('joinRoom');
|
||||
break;
|
||||
default:
|
||||
console.warn('未知的游戏模式:', mode);
|
||||
}
|
||||
}
|
||||
|
||||
// 从准备页面完成后跳转到对战页面
|
||||
function completePlacementAndNavigate() {
|
||||
vibrate();
|
||||
console.log('准备完成,进入对战页面');
|
||||
navigateTo('battle');
|
||||
}
|
||||
|
||||
// 全局导出,确保函数可用
|
||||
window.navigateTo = navigateTo;
|
||||
window.handleGameModeSelection = handleGameModeSelection;
|
||||
window.completePlacementAndNavigate = completePlacementAndNavigate;
|
||||
window.vibrate = vibrate;
|
||||
Reference in New Issue
Block a user