fix(mobile): 修复键盘布局和输入缩放并优化删除弹窗 #22
@@ -1123,3 +1123,16 @@ textarea:focus-visible {
|
|||||||
width: calc(100% - 32px);
|
width: calc(100% - 32px);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 移动表单保持可读字号,避免 Safari 聚焦后自动放大且不复原。 */
|
||||||
|
@media (pointer: coarse) {
|
||||||
|
body input:not([type="checkbox"]):not([type="radio"]),
|
||||||
|
body textarea,
|
||||||
|
body select {
|
||||||
|
font-size: max(16px, 1em);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
html {
|
||||||
|
-webkit-text-size-adjust: 100%;
|
||||||
|
text-size-adjust: 100%;
|
||||||
|
}
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ export function ConversationDeleteDialog({
|
|||||||
</span>
|
</span>
|
||||||
<h2 id={id}>删除这段对话?</h2>
|
<h2 id={id}>删除这段对话?</h2>
|
||||||
<p id={`${id}-description`}>
|
<p id={`${id}-description`}>
|
||||||
「{title}」的对话记录将被永久删除,无法恢复。
|
「{title}」将从你的对话列表中移除,你将无法继续查看。后台仍保留聊天记录。
|
||||||
</p>
|
</p>
|
||||||
{error && (
|
{error && (
|
||||||
<p className="dh-delete-error" role="alert">
|
<p className="dh-delete-error" role="alert">
|
||||||
@@ -185,7 +185,7 @@ export function ConversationDeleteDialog({
|
|||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
<div className="dh-delete-actions">
|
<div className="dh-delete-actions">
|
||||||
<button type="button" disabled={busy} onClick={onCancel}>
|
<button type="button" autoFocus disabled={busy} onClick={onCancel}>
|
||||||
取消
|
取消
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
|
|||||||
@@ -258,16 +258,44 @@ export function DigitalHome({
|
|||||||
}, [conversationId]);
|
}, [conversationId]);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!conversationId) return;
|
if (!conversationId) return;
|
||||||
const resize = () =>
|
const root = document.documentElement;
|
||||||
document.documentElement.style.setProperty(
|
const viewport = window.visualViewport;
|
||||||
"--dh-viewport",
|
const body = document.body;
|
||||||
`${window.visualViewport?.height ?? window.innerHeight}px`,
|
const scrollY = window.scrollY;
|
||||||
);
|
const previousOverflow = body.style.overflow;
|
||||||
|
let frame = 0;
|
||||||
|
// 聊天只滚动消息区;Safari 键盘可能同时改变可视高度和偏移,必须一起同步。
|
||||||
|
body.style.overflow = "hidden";
|
||||||
|
root.classList.add("dh-chat-active");
|
||||||
|
const resize = () => {
|
||||||
|
cancelAnimationFrame(frame);
|
||||||
|
frame = requestAnimationFrame(() => {
|
||||||
|
// 用户手动捏合时保留浏览器缩放,不把缩放后的高度再次施加给布局。
|
||||||
|
if (viewport && Math.abs(viewport.scale - 1) > 0.01) return;
|
||||||
|
root.style.setProperty(
|
||||||
|
"--dh-viewport",
|
||||||
|
`${viewport?.height ?? window.innerHeight}px`,
|
||||||
|
);
|
||||||
|
root.style.setProperty(
|
||||||
|
"--dh-viewport-top",
|
||||||
|
`${viewport?.offsetTop ?? 0}px`,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
};
|
||||||
resize();
|
resize();
|
||||||
window.visualViewport?.addEventListener("resize", resize);
|
viewport?.addEventListener("resize", resize);
|
||||||
|
viewport?.addEventListener("scroll", resize);
|
||||||
|
window.addEventListener("resize", resize);
|
||||||
return () => {
|
return () => {
|
||||||
window.visualViewport?.removeEventListener("resize", resize);
|
cancelAnimationFrame(frame);
|
||||||
document.documentElement.style.removeProperty("--dh-viewport");
|
viewport?.removeEventListener("resize", resize);
|
||||||
|
viewport?.removeEventListener("scroll", resize);
|
||||||
|
window.removeEventListener("resize", resize);
|
||||||
|
body.style.overflow = previousOverflow;
|
||||||
|
root.classList.remove("dh-chat-active");
|
||||||
|
root.style.removeProperty("--dh-viewport");
|
||||||
|
root.style.removeProperty("--dh-viewport-top");
|
||||||
|
window.scrollTo(0, scrollY);
|
||||||
};
|
};
|
||||||
}, [conversationId]);
|
}, [conversationId]);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -321,7 +349,7 @@ export function DigitalHome({
|
|||||||
previous?.focus();
|
previous?.focus();
|
||||||
};
|
};
|
||||||
}, [detail, showSettings]);
|
}, [detail, showSettings]);
|
||||||
/** 抽屉聚焦当前选项并限制滚动;取消、确认及切回桌面后恢复入口焦点。 */
|
/** 选择弹窗聚焦当前选项并限制滚动;取消、确认及切回桌面后恢复入口焦点。 */
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!selectionSheet) return;
|
if (!selectionSheet) return;
|
||||||
const previous = selectionTrigger.current;
|
const previous = selectionTrigger.current;
|
||||||
@@ -775,7 +803,7 @@ export function DigitalHome({
|
|||||||
input.style.height = `${Math.min(input.scrollHeight, 160)}px`;
|
input.style.height = `${Math.min(input.scrollHeight, 160)}px`;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
/** 抽屉仅编辑临时值;确认后回填设定,取消不改动已有选择。 */
|
/** 选择弹窗仅编辑临时值;确认后回填设定,取消不改动已有选择。 */
|
||||||
function openSelection(kind: "style" | "books") {
|
function openSelection(kind: "style" | "books") {
|
||||||
if (!settings) return;
|
if (!settings) return;
|
||||||
selectionTrigger.current = document.activeElement as HTMLElement;
|
selectionTrigger.current = document.activeElement as HTMLElement;
|
||||||
|
|||||||
+51
-21
@@ -636,9 +636,9 @@
|
|||||||
/* 横滑只移动会话卡片,删除在明确确认后才执行。 */
|
/* 横滑只移动会话卡片,删除在明确确认后才执行。 */
|
||||||
.dh-conversation-row {
|
.dh-conversation-row {
|
||||||
position: relative;
|
position: relative;
|
||||||
overflow: hidden;
|
overflow: visible;
|
||||||
border-radius: 14px;
|
border-radius: 14px;
|
||||||
background: #9a394b;
|
background: transparent;
|
||||||
}
|
}
|
||||||
.dh-conversation-list .dh-conversation-open {
|
.dh-conversation-list .dh-conversation-open {
|
||||||
position: relative;
|
position: relative;
|
||||||
@@ -659,9 +659,11 @@
|
|||||||
gap: 5px;
|
gap: 5px;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
width: 88px;
|
width: 76px;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
background: #9a394b;
|
background: #a3374c;
|
||||||
|
border-radius: 14px;
|
||||||
|
box-shadow: 0 4px 16px #0003;
|
||||||
visibility: hidden;
|
visibility: hidden;
|
||||||
}
|
}
|
||||||
.dh-conversation-row.is-revealed .dh-row-delete-swipe {
|
.dh-conversation-row.is-revealed .dh-row-delete-swipe {
|
||||||
@@ -699,7 +701,11 @@
|
|||||||
}
|
}
|
||||||
.dh-delete-dialog {
|
.dh-delete-dialog {
|
||||||
width: min(420px, calc(100% - 32px));
|
width: min(420px, calc(100% - 32px));
|
||||||
max-height: 90dvh;
|
max-height: calc(100dvh - 48px);
|
||||||
|
margin: auto;
|
||||||
|
overflow-y: auto;
|
||||||
|
overscroll-behavior: contain;
|
||||||
|
box-shadow: 0 24px 80px #0008;
|
||||||
padding: 26px;
|
padding: 26px;
|
||||||
color: var(--dh-text);
|
color: var(--dh-text);
|
||||||
background: var(--dh-panel);
|
background: var(--dh-panel);
|
||||||
@@ -882,12 +888,10 @@
|
|||||||
font-size: 10px;
|
font-size: 10px;
|
||||||
}
|
}
|
||||||
.dh-delete-dialog {
|
.dh-delete-dialog {
|
||||||
width: 100%;
|
width: min(380px, calc(100% - 40px));
|
||||||
max-width: 100%;
|
margin: auto;
|
||||||
margin: auto 0 0;
|
padding: 24px;
|
||||||
padding: 24px 22px calc(22px + env(safe-area-inset-bottom));
|
border-radius: 22px;
|
||||||
border-radius: 22px 22px 0 0;
|
|
||||||
border-bottom: 0;
|
|
||||||
}
|
}
|
||||||
.dh-app .dh-compose-tools .dh-mobile-linebreak {
|
.dh-app .dh-compose-tools .dh-mobile-linebreak {
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -1313,7 +1317,7 @@
|
|||||||
min-height: 76px;
|
min-height: 76px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* H5 选择项以底部抽屉编辑草稿,确认后才回填到对话设定。 */
|
/* H5 选择项在居中弹窗编辑草稿,确认后才回填到对话设定。 */
|
||||||
.dh-mobile-choices {
|
.dh-mobile-choices {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
@@ -1328,8 +1332,9 @@
|
|||||||
inset: 0;
|
inset: 0;
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: flex-end;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
padding: 20px;
|
||||||
overscroll-behavior: contain;
|
overscroll-behavior: contain;
|
||||||
}
|
}
|
||||||
.dh-selection-backdrop {
|
.dh-selection-backdrop {
|
||||||
@@ -1343,15 +1348,14 @@
|
|||||||
position: relative;
|
position: relative;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
width: 100%;
|
width: min(520px, 100%);
|
||||||
max-height: 86dvh;
|
max-height: 86dvh;
|
||||||
min-height: 0;
|
min-height: 0;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
background: var(--dh-panel);
|
background: var(--dh-panel);
|
||||||
border: 1px solid #ffffff1c;
|
border: 1px solid #ffffff1c;
|
||||||
border-bottom: 0;
|
border-radius: 22px;
|
||||||
border-radius: 24px 24px 0 0;
|
box-shadow: 0 24px 80px #0008;
|
||||||
box-shadow: 0 -16px 60px #0005;
|
|
||||||
animation: dh-sheet-enter 180ms ease-out;
|
animation: dh-sheet-enter 180ms ease-out;
|
||||||
}
|
}
|
||||||
.dh-sheet-handle {
|
.dh-sheet-handle {
|
||||||
@@ -1442,10 +1446,12 @@
|
|||||||
}
|
}
|
||||||
@keyframes dh-sheet-enter {
|
@keyframes dh-sheet-enter {
|
||||||
from {
|
from {
|
||||||
transform: translateY(100%);
|
opacity: 0;
|
||||||
|
transform: translateY(8px) scale(0.98);
|
||||||
}
|
}
|
||||||
to {
|
to {
|
||||||
transform: translateY(0);
|
opacity: 1;
|
||||||
|
transform: translateY(0) scale(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@media (width > 600px) {
|
@media (width > 600px) {
|
||||||
@@ -1833,7 +1839,7 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
resize: none;
|
resize: none;
|
||||||
min-height: 36px;
|
min-height: 36px;
|
||||||
max-height: 160px;
|
max-height: min(160px, calc(var(--dh-viewport, 100dvh) * 0.28));
|
||||||
border: 0;
|
border: 0;
|
||||||
background: none;
|
background: none;
|
||||||
padding: 7px 0;
|
padding: 7px 0;
|
||||||
@@ -2228,7 +2234,7 @@
|
|||||||
}
|
}
|
||||||
.dh-chat {
|
.dh-chat {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
inset: 0;
|
inset: var(--dh-viewport-top, 0px) 0 auto;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: var(--dh-viewport, 100dvh);
|
height: var(--dh-viewport, 100dvh);
|
||||||
z-index: 20;
|
z-index: 20;
|
||||||
@@ -2392,3 +2398,27 @@ body:has(.dh-app) .environment-badge {
|
|||||||
width: 16px;
|
width: 16px;
|
||||||
height: 16px;
|
height: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 聊天独立占据可视区域,防止焦点滚动带动整个文档。 */
|
||||||
|
html.dh-chat-active,
|
||||||
|
html.dh-chat-active body {
|
||||||
|
overflow: hidden;
|
||||||
|
overscroll-behavior: none;
|
||||||
|
}
|
||||||
|
.dh-composer-wrap {
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
@media (pointer: coarse) {
|
||||||
|
/* iOS 会自动放大不足 16px 的表单;覆盖各页面局部小字号,同时保留手动缩放。 */
|
||||||
|
.dh-app input:not([type="checkbox"]):not([type="radio"]),
|
||||||
|
.dh-app textarea,
|
||||||
|
.dh-app select {
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
.dh-conversation-list .dh-conversation-open {
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
.dh-conversation-list .dh-row-delete-desktop {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user