Compare commits

..

No commits in common. "068efe3d47e88372b2a5092dacddcc372fd0bd64" and "9dee5c9e96e25ec883e9e7858dd47f26f92207ae" have entirely different histories.

3 changed files with 12 additions and 37 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "easyshell", "name": "easyshell",
"version": "1.0.4", "version": "1.0.3",
"description": "跨平台远程Shell管理终端 - 支持 Windows/Mac/Linux/Android", "description": "跨平台远程Shell管理终端 - 支持 Windows/Mac/Linux/Android",
"author": "EasyShell Team", "author": "EasyShell Team",
"main": "main.js", "main": "main.js",

View File

@ -205,12 +205,10 @@ const getCategoryIcon = (category) => {
} }
}; };
function CommandSuggestions({ input, onSelect, onClose, visible, cursorPosition, containerHeight }) { function CommandSuggestions({ input, position, onSelect, onClose, visible, cursorPosition }) {
const [selectedIndex, setSelectedIndex] = useState(0); const [selectedIndex, setSelectedIndex] = useState(0);
const listRef = useRef(null); const listRef = useRef(null);
const selectedRef = useRef(null); const selectedRef = useRef(null);
const suggestionsRef = useRef(null);
const [showAbove, setShowAbove] = useState(false);
// 根据输入过滤命令 // 根据输入过滤命令
const suggestions = React.useMemo(() => { const suggestions = React.useMemo(() => {
@ -278,43 +276,21 @@ function CommandSuggestions({ input, onSelect, onClose, visible, cursorPosition,
if (!visible || suggestions.length === 0) return null; if (!visible || suggestions.length === 0) return null;
// 估算提示框高度(标题 + 每项约28px最多8项 // 计算提示框位置(在光标下方)
const estimatedHeight = 28 + Math.min(suggestions.length, 8) * 28; const positionStyle = cursorPosition ? {
top: cursorPosition.top + 20,
// 计算提示框位置,智能判断显示在光标上方还是下方 left: cursorPosition.left,
let positionStyle = {}; } : {
bottom: position?.bottom || 60,
if (cursorPosition) { left: position?.left || 16,
const spaceBelow = (containerHeight || 600) - cursorPosition.top - 20; };
const shouldShowAbove = spaceBelow < estimatedHeight && cursorPosition.top > estimatedHeight;
if (shouldShowAbove) {
// 显示在光标上方
positionStyle = {
bottom: (containerHeight || 600) - cursorPosition.top + 5,
left: Math.max(10, Math.min(cursorPosition.left, 200)),
};
} else {
// 显示在光标下方
positionStyle = {
top: cursorPosition.top + 20,
left: Math.max(10, Math.min(cursorPosition.left, 200)),
};
}
} else {
positionStyle = {
bottom: 60,
left: 16,
};
}
return ( return (
<AnimatePresence> <AnimatePresence>
<motion.div <motion.div
ref={suggestionsRef} initial={{ opacity: 0, y: -5, scale: 0.98 }}
initial={{ opacity: 0, y: cursorPosition && positionStyle.bottom ? 5 : -5, scale: 0.98 }}
animate={{ opacity: 1, y: 0, scale: 1 }} animate={{ opacity: 1, y: 0, scale: 1 }}
exit={{ opacity: 0, y: cursorPosition && positionStyle.bottom ? 5 : -5, scale: 0.98 }} exit={{ opacity: 0, y: -5, scale: 0.98 }}
transition={{ duration: 0.1 }} transition={{ duration: 0.1 }}
className="absolute z-50 bg-shell-surface/95 backdrop-blur-xl border border-shell-accent/30 className="absolute z-50 bg-shell-surface/95 backdrop-blur-xl border border-shell-accent/30
rounded-lg shadow-2xl overflow-hidden min-w-[240px] max-w-[360px]" rounded-lg shadow-2xl overflow-hidden min-w-[240px] max-w-[360px]"

View File

@ -630,7 +630,6 @@ function Terminal({ tabId, hostId, isActive, onConnectionChange, onShowCommandPa
input={currentInput} input={currentInput}
visible={showSuggestions && isActive && connectionId} visible={showSuggestions && isActive && connectionId}
cursorPosition={cursorPosition} cursorPosition={cursorPosition}
containerHeight={containerRef.current?.offsetHeight || 600}
onSelect={handleSuggestionSelect} onSelect={handleSuggestionSelect}
onClose={handleCloseSuggestions} onClose={handleCloseSuggestions}
/> />