update at 2026-03-03 21:19:52
This commit is contained in:
@@ -20,8 +20,6 @@ body {
|
||||
|
||||
.xterm {
|
||||
.xterm-viewport {
|
||||
overscroll-behavior-y: contain !important;
|
||||
-webkit-overflow-scrolling: touch !important;
|
||||
will-change: transform, scroll-position;
|
||||
overflow-y: hidden;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#terminal {
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
height: 100%;
|
||||
position: relative;
|
||||
|
||||
@@ -8,7 +8,7 @@ import { disconnect } from './wetty/disconnect';
|
||||
import { overlay } from './wetty/disconnect/elements';
|
||||
import { verifyPrompt } from './wetty/disconnect/verify';
|
||||
import { FileDownloader } from './wetty/download';
|
||||
import { mobileKeyboard, initMobileViewport } from './wetty/mobile';
|
||||
import { mobileKeyboard } from './wetty/mobile';
|
||||
import { socket } from './wetty/socket';
|
||||
import { terminal, Term } from './wetty/term';
|
||||
|
||||
@@ -33,7 +33,6 @@ if (_.isUndefined(term)) {
|
||||
term.resizeTerm();
|
||||
term.focus();
|
||||
mobileKeyboard();
|
||||
initMobileViewport(term);
|
||||
const fileDownloader = new FileDownloader();
|
||||
|
||||
socket
|
||||
|
||||
@@ -9,38 +9,3 @@ export function mobileKeyboard(): void {
|
||||
screen.setAttribute('autocomplete', 'false');
|
||||
screen.setAttribute('autocapitalize', 'false');
|
||||
}
|
||||
|
||||
export function initMobileViewport(term: any): void {
|
||||
if (window.visualViewport) {
|
||||
const handleResize = () => {
|
||||
// 类似 xterminal,给软键盘和页面重排一点时间
|
||||
setTimeout(() => {
|
||||
let bottomInset = 0;
|
||||
if (window.visualViewport) {
|
||||
bottomInset = Math.max(
|
||||
0,
|
||||
window.innerHeight - (window.visualViewport.height + window.visualViewport.offsetTop)
|
||||
);
|
||||
}
|
||||
|
||||
const termWrapper = document.getElementById('terminal'); // 外层容器
|
||||
if (termWrapper) {
|
||||
if (bottomInset > 0) {
|
||||
termWrapper.style.paddingBottom = `${bottomInset}px`;
|
||||
} else {
|
||||
termWrapper.style.paddingBottom = '0px';
|
||||
}
|
||||
}
|
||||
|
||||
// 通知 xterm 重新按新的可用高度进行行列计算,类似于 xterminal 重新适配行
|
||||
if (term && term.fitAddon) {
|
||||
term.fitAddon.fit();
|
||||
term.scrollToBottom();
|
||||
}
|
||||
}, 100);
|
||||
};
|
||||
|
||||
window.visualViewport.addEventListener('resize', handleResize);
|
||||
window.visualViewport.addEventListener('scroll', handleResize);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,3 +17,12 @@ const DEV_KEY_PATH = "/Users/gavin/.acme.sh/shell.biboer.cn_ecc/shell.biboer.cn.
|
||||
参考../xterminal,增加:
|
||||
1. 软键盘弹出和折叠,行的位置计算参考xtermal。 -- 这点重要
|
||||
2. 滚动容器保持原生丝滑。现在xterm太卡。
|
||||
|
||||
|
||||
|
||||
---
|
||||
|
||||
|
||||
结论: 使用xterm.js,手机体验不好.
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user