chore(backend,frontend): 移除设备位置管理全链路功能与相关代码

- 删除后端所有机器位置相关的API接口、缓存逻辑与后台同步任务
- 移除前端的机器位置导航入口、地图页面与管理代码
- 将原机器地图页面重构为车票查询页面
- 调整Lua程序的默认版本号
- 删除无用的.gitignore文件
- 优化前端页面的代码格式与导航结构
This commit is contained in:
2026-07-11 16:05:20 +08:00
parent 4fe3a24eaf
commit 1d9f08d5c6
14 changed files with 112 additions and 448 deletions
+1 -92
View File
@@ -24,7 +24,6 @@ createApp({
dashboard: '仪表盘',
management: '线路与票价管理',
faremap: '票价地图',
machinemap: '机器位置',
tickets: '车票记录',
vouchers: '凭证管理',
iccards: 'IC 卡管理',
@@ -79,14 +78,12 @@ createApp({
let logDataLoaded = false;
let assetsLoaded = false;
let fareMapLoaded = false;
let machineLocationsLoaded = false;
const loadingState = reactive({
core: false,
tickets: false,
orders: false,
logs: false,
iccards: false,
machinemap: false
iccards: false
});
const lastSyncAt = ref(0);
@@ -1119,82 +1116,6 @@ createApp({
}
};
const machineLocations = ref({});
const selectedMachineId = ref('');
const getMapX = (x) => {
if (typeof x !== 'number') return 50;
// Assuming typical MC coords are between -10000 and +10000.
// We can auto-scale based on actual data bounds instead.
let min = 0, max = 0;
const vals = Object.values(machineLocations.value).map(l => l.x).filter(v => typeof v === 'number');
if (vals.length > 0) {
min = Math.min(...vals) - 50;
max = Math.max(...vals) + 50;
} else {
return 50;
}
if (max === min) return 50;
return ((x - min) / (max - min)) * 90 + 5; // 5% to 95% margin
};
const getMapY = (z) => {
if (typeof z !== 'number') return 50;
let min = 0, max = 0;
const vals = Object.values(machineLocations.value).map(l => l.z).filter(v => typeof v === 'number');
if (vals.length > 0) {
min = Math.min(...vals) - 50;
max = Math.max(...vals) + 50;
} else {
return 50;
}
if (max === min) return 50;
return ((z - min) / (max - min)) * 90 + 5;
};
const fetchMachineLocations = async () => {
loadingState.machinemap = true;
try {
const res = await requestJson('/api/machine-locations');
if (res && res.data) {
machineLocations.value = res.data;
}
machineLocationsLoaded = true;
} catch (e) {
console.error(e);
} finally {
loadingState.machinemap = false;
}
};
const showEditMachineModal = ref(false);
const editMachineForm = reactive({ device_id: '', station_code: '', x: 0, y: 0, z: 0, type: 'TicketMachine' });
const openEditMachineModal = (id) => {
const loc = machineLocations.value[id];
if (!loc) return;
editMachineForm.device_id = id;
editMachineForm.station_code = loc.station_code || loc.station || '';
editMachineForm.x = loc.x || 0;
editMachineForm.y = loc.y || 0;
editMachineForm.z = loc.z || 0;
editMachineForm.type = loc.type || 'TicketMachine';
showEditMachineModal.value = true;
};
const saveMachineLocation = async () => {
try {
const payload = { ...editMachineForm };
await requestJson(`/api/machine-location/${encodeURIComponent(payload.device_id)}`, {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload)
}, { expectOk: true });
showEditMachineModal.value = false;
await fetchMachineLocations();
} catch (e) {
alert('保存失败: ' + e.message);
}
};
const ensureViewData = async (view = currentView.value, { force = false } = {}) => {
await fetchCoreData({ force });
if (view === 'tickets' && (force || !ticketDataLoaded)) await fetchTicketData();
@@ -1208,7 +1129,6 @@ createApp({
}
if (view === 'faremap' && (force || !fareMapLoaded)) await loadFareMap({ force });
if (view === 'assets' && (!assetsLoaded || force)) await fetchAssetsManifest();
if (view === 'machinemap') await fetchMachineLocations();
};
const fetchData = async () => {
@@ -1644,8 +1564,6 @@ createApp({
syncSelectedIcCard().catch(console.error);
});
let machineMapTimer = null;
watch(currentView, (v) => {
sidebarOpen.value = false;
if (v === 'iccards') {
@@ -1653,14 +1571,6 @@ createApp({
} else {
stopIcCardSync();
}
if (v === 'machinemap') {
if (!machineMapTimer) machineMapTimer = setInterval(fetchMachineLocations, 60000);
} else {
if (machineMapTimer) {
clearInterval(machineMapTimer);
machineMapTimer = null;
}
}
ensureViewData(v).catch(console.error);
const sp = new URLSearchParams(location.search);
if (v === 'dashboard') sp.delete('view');
@@ -1810,7 +1720,6 @@ createApp({
};
return {
machineLocations, selectedMachineId, getMapX, getMapY, showEditMachineModal, editMachineForm, openEditMachineModal, saveMachineLocation,
currentView, viewTitle, sidebarOpen,
loadingState, isViewBusy, lastSyncText, currentViewSummary,
stations, lines, fares, stats, config, recentLogs, ticketList, ticketStats, orderStats,