diff --git a/src/index.js b/src/index.js index 63ede9e..15d562d 100644 --- a/src/index.js +++ b/src/index.js @@ -1505,18 +1505,22 @@ import { registerExportInfo, downloadExportData } from './core/exportInfo.js'; const SaturationDisplay = (() => { let saturationTableElement = null; + const isNarrowViewport = () => window.innerWidth <= 480; + // 构建表格内容 const createTable = (list) => { const d = DM(); + const isNarrow = isNarrowViewport(); + const cellPadding = isNarrow ? '4px 5px' : '4px 8px'; const table = document.createElement("table"); - table.style.cssText = `border-collapse:collapse;margin:10px 0;background:${d ? '#333' : '#f9f9f9'};color:${d ? 'white' : '#333'};font-size:13px;width:100%;`; + table.style.cssText = `border-collapse:collapse;margin:10px 0;background:${d ? '#333' : '#f9f9f9'};color:${d ? 'white' : '#333'};font-size:${isNarrow ? 12 : 13}px;width:100%;table-layout:fixed;`; const thead = document.createElement("thead"); const headerRow = document.createElement("tr"); ["物品", "质量", "饱和度"].forEach(text => { const th = document.createElement("th"); th.textContent = text; - th.style.cssText = `border:1px solid ${d ? '#666' : '#ccc'};padding:4px 8px;`; + th.style.cssText = `border:1px solid ${d ? '#666' : '#ccc'};padding:${cellPadding};overflow-wrap:anywhere;word-break:break-word;`; headerRow.appendChild(th); }); thead.appendChild(headerRow); @@ -1529,7 +1533,7 @@ import { registerExportInfo, downloadExportData } from './core/exportInfo.js'; [name, item.quality ?? "-", String(item.saturation)].forEach(text => { const td = document.createElement("td"); td.textContent = text; - td.style.cssText = `border:1px solid ${d ? '#666' : '#ccc'};padding:4px 8px;text-align:center;`; + td.style.cssText = `border:1px solid ${d ? '#666' : '#ccc'};padding:${cellPadding};text-align:center;overflow-wrap:anywhere;word-break:break-word;`; row.appendChild(td); }); tbody.appendChild(row); @@ -1547,6 +1551,11 @@ import { registerExportInfo, downloadExportData } from './core/exportInfo.js'; } const d = DM(); + const isNarrow = isNarrowViewport(); + const containerPadding = isNarrow ? 8 : 12; + const containerMaxHeight = isNarrow ? 'calc(100vh - 70px)' : '400px'; + const titleFont = isNarrow ? 13 : 14; + const subFont = isNarrow ? 12 : 13; const list = data.ResourcesRetailInfo; const weatherMultiplier = data.sellingSpeedMultiplier.sellingSpeedMultiplier; const weatherData = data.sellingSpeedMultiplier || {}; @@ -1567,19 +1576,21 @@ import { registerExportInfo, downloadExportData } from './core/exportInfo.js'; // 1. 创建容器 saturationTableElement = document.createElement("div"); saturationTableElement.style.cssText = ` - position:fixed; left:10px; top:50px; z-index:9998; - background:${d ? '#2c2c2c' : '#fff'}; color:${d ? '#fff' : '#333'}; padding:12px; - border-radius:8px; max-height:400px; overflow:auto; - max-width: calc(100vw - 20px); + position:fixed; left:10px; right:10px; top:50px; z-index:9998; box-sizing:border-box; + background:${d ? '#2c2c2c' : '#fff'}; color:${d ? '#fff' : '#333'}; padding:${containerPadding}px; + border-radius:8px; max-height:${containerMaxHeight}; overflow:auto; + width:auto; max-width: calc(100vw - 20px); box-shadow:0 4px 15px rgba(0,0,0,0.5); font-family:Arial, sans-serif; `; // 2. 创建头部信息 const headerInfo = document.createElement("div"); + headerInfo.style.paddingRight = '26px'; + headerInfo.style.overflowWrap = 'anywhere'; headerInfo.innerHTML = ` -