Spaces:
Sleeping
Sleeping
Commit ·
03c1eec
1
Parent(s): 14ea612
fix(web): Discord Activity 舞台縮小至 1180×840(放大填滿、消除兩側空白)
Browse files原 1600×900 舞台比戰鬥內容(.battle 寬上限 1100)寬很多 → 內容縮在中間、兩側大量空白、
整體偏小。改用「剛好容納內容」的 1180×840(比例≈1.40,接近 Discord 活動面板)→ 縮放係數
最大化,遊戲整塊放大、填滿面板。尺寸仍為 CSS 變數,可再微調。
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- packages/web/src/App.tsx +2 -2
- packages/web/src/styles.css +5 -4
packages/web/src/App.tsx
CHANGED
|
@@ -284,8 +284,8 @@ export function App() {
|
|
| 284 |
if (platform !== "discord") return;
|
| 285 |
document.body.classList.add("discord-activity");
|
| 286 |
const css = getComputedStyle(document.documentElement);
|
| 287 |
-
const stageW = parseFloat(css.getPropertyValue("--stage-w")) ||
|
| 288 |
-
const stageH = parseFloat(css.getPropertyValue("--stage-h")) ||
|
| 289 |
const fit = (): void => {
|
| 290 |
const scale = Math.min(window.innerWidth / stageW, window.innerHeight / stageH);
|
| 291 |
document.documentElement.style.setProperty("--stage-scale", String(scale));
|
|
|
|
| 284 |
if (platform !== "discord") return;
|
| 285 |
document.body.classList.add("discord-activity");
|
| 286 |
const css = getComputedStyle(document.documentElement);
|
| 287 |
+
const stageW = parseFloat(css.getPropertyValue("--stage-w")) || 1180;
|
| 288 |
+
const stageH = parseFloat(css.getPropertyValue("--stage-h")) || 840;
|
| 289 |
const fit = (): void => {
|
| 290 |
const scale = Math.min(window.innerWidth / stageW, window.innerHeight / stageH);
|
| 291 |
document.documentElement.style.setProperty("--stage-scale", String(scale));
|
packages/web/src/styles.css
CHANGED
|
@@ -1033,11 +1033,12 @@ html, body, #root {
|
|
| 1033 |
版面在此尺寸下照桌面 RWD 排好、本就不溢出),再用 transform: scale 等比例縮放置中塞進 iframe。
|
| 1034 |
只在 platform=discord 時由 App.tsx 加上 body.discord-activity 啟用;網頁版完全不受影響。
|
| 1035 |
縮放係數 --stage-scale 由 App.tsx 依視窗大小即時算出(min(寬比, 高比),保持等比例)。
|
| 1036 |
-
舞台
|
| 1037 |
-
|
|
|
|
| 1038 |
:root {
|
| 1039 |
-
--stage-w:
|
| 1040 |
-
--stage-h:
|
| 1041 |
}
|
| 1042 |
body.discord-activity { overflow: hidden; }
|
| 1043 |
body.discord-activity #root {
|
|
|
|
| 1033 |
版面在此尺寸下照桌面 RWD 排好、本就不溢出),再用 transform: scale 等比例縮放置中塞進 iframe。
|
| 1034 |
只在 platform=discord 時由 App.tsx 加上 body.discord-activity 啟用;網頁版完全不受影響。
|
| 1035 |
縮放係數 --stage-scale 由 App.tsx 依視窗大小即時算出(min(寬比, 高比),保持等比例)。
|
| 1036 |
+
舞台尺寸取「剛好容納畫面內容」(戰鬥 .battle 寬上限 1100 + 邊距,高約容得下手牌/按鈕)→ 縮放係數最大化,
|
| 1037 |
+
遊戲整塊放大、填滿 Discord 面板、兩側不留大空白;其比例(≈1180/840≈1.40)也接近 Discord 活動面板。
|
| 1038 |
+
想更滿:--stage-w 調更小(逼近內容寬 ~1130)。底部被裁:--stage-h 調大。 */
|
| 1039 |
:root {
|
| 1040 |
+
--stage-w: 1180px;
|
| 1041 |
+
--stage-h: 840px;
|
| 1042 |
}
|
| 1043 |
body.discord-activity { overflow: hidden; }
|
| 1044 |
body.discord-activity #root {
|