Compare commits
No commits in common. "068efe3d47e88372b2a5092dacddcc372fd0bd64" and "9dee5c9e96e25ec883e9e7858dd47f26f92207ae" have entirely different histories.
068efe3d47
...
9dee5c9e96
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "easyshell",
|
||||
"version": "1.0.4",
|
||||
"version": "1.0.3",
|
||||
"description": "跨平台远程Shell管理终端 - 支持 Windows/Mac/Linux/Android",
|
||||
"author": "EasyShell Team",
|
||||
"main": "main.js",
|
||||
|
||||
@ -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 listRef = useRef(null);
|
||||
const selectedRef = useRef(null);
|
||||
const suggestionsRef = useRef(null);
|
||||
const [showAbove, setShowAbove] = useState(false);
|
||||
|
||||
// 根据输入过滤命令
|
||||
const suggestions = React.useMemo(() => {
|
||||
@ -278,43 +276,21 @@ function CommandSuggestions({ input, onSelect, onClose, visible, cursorPosition,
|
||||
|
||||
if (!visible || suggestions.length === 0) return null;
|
||||
|
||||
// 估算提示框高度(标题 + 每项约28px,最多8项)
|
||||
const estimatedHeight = 28 + Math.min(suggestions.length, 8) * 28;
|
||||
|
||||
// 计算提示框位置,智能判断显示在光标上方还是下方
|
||||
let positionStyle = {};
|
||||
|
||||
if (cursorPosition) {
|
||||
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 = {
|
||||
// 计算提示框位置(在光标下方)
|
||||
const positionStyle = cursorPosition ? {
|
||||
top: cursorPosition.top + 20,
|
||||
left: Math.max(10, Math.min(cursorPosition.left, 200)),
|
||||
left: cursorPosition.left,
|
||||
} : {
|
||||
bottom: position?.bottom || 60,
|
||||
left: position?.left || 16,
|
||||
};
|
||||
}
|
||||
} else {
|
||||
positionStyle = {
|
||||
bottom: 60,
|
||||
left: 16,
|
||||
};
|
||||
}
|
||||
|
||||
return (
|
||||
<AnimatePresence>
|
||||
<motion.div
|
||||
ref={suggestionsRef}
|
||||
initial={{ opacity: 0, y: cursorPosition && positionStyle.bottom ? 5 : -5, scale: 0.98 }}
|
||||
initial={{ opacity: 0, y: -5, scale: 0.98 }}
|
||||
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 }}
|
||||
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]"
|
||||
|
||||
@ -630,7 +630,6 @@ function Terminal({ tabId, hostId, isActive, onConnectionChange, onShowCommandPa
|
||||
input={currentInput}
|
||||
visible={showSuggestions && isActive && connectionId}
|
||||
cursorPosition={cursorPosition}
|
||||
containerHeight={containerRef.current?.offsetHeight || 600}
|
||||
onSelect={handleSuggestionSelect}
|
||||
onClose={handleCloseSuggestions}
|
||||
/>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user