Prompt as Code | GPT Image 2 / 2.5 提示词与案例库,530+ 个案例、20+ 套工业级模板与可复用 Skills,新增 2.5 同提示词对比专区,附完整提示词与生成记录,持续更新。
JavaScript agentsai-image-generationchatgptdsh-plugingpt-image-2image-promptsprompt-as-codeprompt-engineeringskillsworkflow-automation
Fix mobile modal scroll locking
freestyleflydcfd3900b5ac
diff --git a/src/main.jsx b/src/main.jsxindex 867b5d3..bd9f73c 100644--- a/src/main.jsx+++ b/src/main.jsx@@ -519,6 +519,8 @@ const GENERATED_TESTS_STORAGE_KEY = 'gpt-image-2-generated-tests:v1';const MAX_SAVED_GENERATIONS = 12;const HERO_CASE_COUNT = 5;const HOT_STRIP_CASE_COUNT = 8;+let bodyScrollLockCount = 0;+let bodyScrollLockState = null;function pagePathWithHash() {return `${window.location.pathname}${window.location.search}${window.location.hash}`;@@ -563,6 +565,45 @@ function useGaPageViews() {}, []);}+function useBodyScrollLock(active) {+ useEffect(() => {+ if (!active) return undefined;++ if (bodyScrollLockCount === 0) {+ const scrollY = window.scrollY || document.documentElement.scrollTop || 0;+ bodyScrollLockState = {+ scrollY,+ bodyOverflow: document.body.style.overflow,+ bodyPosition: document.body.style.position,+ bodyTop: document.body.style.top,+ bodyWidth: document.body.style.width,+ htmlOverflow: document.documentElement.style.overflow+ };+ document.documentElement.style.overflow = 'hidden';+ document.body.style.overflow = 'hidden';+ document.body.style.position = 'fixed';+ document.body.style.top = `-${scrollY}px`;+ document.body.style.width = '100%';+ }++ bodyScrollLockCount += 1;++ return () => {+ bodyScrollLockCount = Math.max(0, bodyScrollLockCount - 1);+ if (bodyScrollLockCount > 0 || !bodyScrollLockState) return;++ const { scrollY, bodyOverflow, bodyPosition, bodyTop, bodyWidth, htmlOverflow } = bodyScrollLockState;+ document.documentElement.style.overflow = htmlOverflow;+ document.body.style.overflow = bodyOverflow;+ document.body.style.position = bodyPosition;+ document.body.style.top = bodyTop;+ document.body.style.width = bodyWidth;+ bodyScrollLockState = null;+ window.scrollTo(0, scrollY);+ };+ }, [active]);+}+function formatNumber(value) {return new Intl.NumberFormat('en-US').format(Number(value || 0));}@@ -1093,6 +1134,7 @@ function AuthModal({ open, language, onClose }) {const t = copy[language];const [status, setStatus] = useState('idle');const [message, setMessage] = useState('');+ useBodyScrollLock(open);useEffect(() => {if (!open) return;@@ -1307,6 +1349,7 @@ function AccountPanel({const [status, setStatus] = useState('idle');const [message, setMessage] = useState('');const favoritesRef = useRef(null);+ useBodyScrollLock(open);useEffect(() => {if (!open) return;@@ -1690,6 +1733,7 @@ function AdminPanel({ open, language, session, casesById, onClose, onOpenCase })const [message, setMessage] = useState('');const [adjustment, setAdjustment] = useState(null);const [adjustStatus, setAdjustStatus] = useState('idle');+ useBodyScrollLock(open);async function loadAdminData(nextRange = range, nextStart = customStart, nextEnd = customEnd) {if (!session?.access_token) {@@ -2090,6 +2134,7 @@ function BillingPanel({const [status, setStatus] = useState('idle');const [message, setMessage] = useState('');const [busyProduct, setBusyProduct] = useState('');+ useBodyScrollLock(open);async function loadBilling() {setStatus('loading');@@ -2584,20 +2629,17 @@ function PreviewDialog({image: '',message: ''});+ useBodyScrollLock(Boolean(preview));useEffect(() => {if (!preview) return undefined;- const previousOverflow = document.body.style.overflow;- document.body.style.overflow = 'hidden';-function handleKeyDown(event) {if (event.key === 'Escape') onClose();}window.addEventListener('keydown', handleKeyDown);return () => {- document.body.style.overflow = previousOverflow;window.removeEventListener('keydown', handleKeyDown);};}, [preview, onClose]);diff --git a/src/styles.css b/src/styles.cssindex 7a2de5e..753dab5 100644--- a/src/styles.css+++ b/src/styles.css@@ -1395,9 +1395,11 @@ button {z-index: 60;display: grid;place-items: center;+ overscroll-behavior: contain;padding: 24px;background: rgba(3, 6, 13, 0.78);backdrop-filter: blur(16px);+ touch-action: none;}.previewDialog {@@ -1413,6 +1415,8 @@ button {radial-gradient(circle at 10% 0%, rgba(66, 230, 255, 0.12), transparent 34%),linear-gradient(145deg, rgba(11, 17, 33, 0.98), rgba(7, 11, 22, 0.96));box-shadow: 0 34px 120px rgba(0, 0, 0, 0.56);+ overscroll-behavior: contain;+ touch-action: auto;}.previewClose {@@ -1516,6 +1520,8 @@ button {}.previewContent {+ -webkit-overflow-scrolling: touch;+ overscroll-behavior: contain;overflow: auto;padding: 30px;}@@ -1812,6 +1818,8 @@ button {position: relative;width: min(100%, 460px);max-height: min(860px, 92vh);+ -webkit-overflow-scrolling: touch;+ overscroll-behavior: contain;overflow: auto;border: 1px solid rgba(255, 255, 255, 0.16);border-radius: 8px;@@ -1819,6 +1827,7 @@ button {radial-gradient(circle at 18% 0%, rgba(66, 230, 255, 0.15), transparent 38%),linear-gradient(145deg, rgba(12, 18, 36, 0.98), rgba(6, 10, 21, 0.96));box-shadow: 0 34px 120px rgba(0, 0, 0, 0.56);+ touch-action: auto;}.authDialog {@@ -1936,7 +1945,12 @@ button {.accountDialog {width: min(920px, 100%);+ max-height: min(860px, 92vh);+ -webkit-overflow-scrolling: touch;+ overscroll-behavior: contain;+ overflow: auto;padding: 24px;+ touch-action: auto;}.accountHeader {