save work

This commit is contained in:
Red Adaya 2024-05-08 22:42:01 +08:00
parent 4758b7351d
commit bcf6e91f48
3 changed files with 27 additions and 13 deletions

View File

@ -63,9 +63,7 @@ class ChatContent extends React.Component<{ chatWindowRef }, {}> {
componentDidUpdate() { componentDidUpdate() {
this.chatListKeyCount = 0; this.chatListKeyCount = 0;
if (this.containerRef?.current && this.osInstance) { if (this.containerRef?.current && this.osInstance) {
const { viewport, scrollOffsetElement } = this.osInstance.elements(); const { viewport } = this.osInstance.elements();
const { scrollTop } = scrollOffsetElement;
console.log("this.props.chatWindowRef.current.scrollTop", scrollTop);
viewport.scrollTo({ viewport.scrollTo({
behavior: "auto", behavior: "auto",
top: this.props.chatWindowRef.current.scrollHeight, top: this.props.chatWindowRef.current.scrollHeight,

View File

@ -86,9 +86,9 @@ class CmdInput extends React.Component<{}, {}> {
e.stopPropagation(); e.stopPropagation();
const inputModel = GlobalModel.inputModel; const inputModel = GlobalModel.inputModel;
if (inputModel.getActiveAuxView() === appconst.InputAuxView_AIChat) { if (inputModel.getActiveAuxView() === appconst.InputAuxView_AIChat) {
inputModel.closeAuxView(); // inputModel.closeAuxView();
} else { } else {
inputModel.openAIAssistantChat(); // inputModel.openAIAssistantChat();
} }
} }
@ -191,10 +191,10 @@ class CmdInput extends React.Component<{}, {}> {
<div className="cmd-input-grow-spacer"></div> <div className="cmd-input-grow-spacer"></div>
<HistoryInfo /> <HistoryInfo />
</When> </When>
<When condition={openView === appconst.InputAuxView_AIChat}> {/* <When condition={openView === appconst.InputAuxView_AIChat}>
<div className="cmd-input-grow-spacer"></div> <div className="cmd-input-grow-spacer"></div>
<AIChat /> <AIChat />
</When> </When> */}
<When condition={openView === appconst.InputAuxView_Info}> <When condition={openView === appconst.InputAuxView_Info}>
<InfoMsg key="infomsg" /> <InfoMsg key="infomsg" />
</When> </When>

View File

@ -578,10 +578,10 @@ class InputModel {
let rtn = -1; let rtn = -1;
// Why is codeSelectBlockRefArray being reset here? This causes a bug where multiple code blocks are highlighted // Why is codeSelectBlockRefArray being reset here? This causes a bug where multiple code blocks are highlighted
// because multiple code blocks have the same index. // because multiple code blocks have the same index.
if (uuid != this.codeSelectUuid) { // if (uuid != this.codeSelectUuid) {
// this.codeSelectUuid = uuid; // this.codeSelectUuid = uuid;
// this.codeSelectBlockRefArray = []; // this.codeSelectBlockRefArray = [];
} // }
rtn = this.codeSelectBlockRefArray.length; rtn = this.codeSelectBlockRefArray.length;
this.codeSelectBlockRefArray.push(blockRef); this.codeSelectBlockRefArray.push(blockRef);
return rtn; return rtn;
@ -597,13 +597,29 @@ class InputModel {
this.codeSelectSelectedIndex.set(blockIndex); this.codeSelectSelectedIndex.set(blockIndex);
const currentRef = this.codeSelectBlockRefArray[blockIndex].current; const currentRef = this.codeSelectBlockRefArray[blockIndex].current;
if (currentRef != null && this.aiChatWindowRef?.current != null) { if (currentRef != null && this.aiChatWindowRef?.current != null) {
const chatWindowTop = this.aiChatWindowRef.current.scrollTop; // const chatWindowTop = this.aiChatWindowRef.current.scrollTop;
const { viewport, scrollOffsetElement } = this.chatOsInstance.elements();
const chatWindowTop = scrollOffsetElement.scrollTop;
console.log("chatWindowTop", chatWindowTop);
const chatWindowBottom = chatWindowTop + this.aiChatWindowRef.current.clientHeight - 100; const chatWindowBottom = chatWindowTop + this.aiChatWindowRef.current.clientHeight - 100;
console.log("chatWindowTop", chatWindowTop);
console.log("this.aiChatWindowRef.current.clientHeight", this.aiChatWindowRef.current.clientHeight);
const elemTop = currentRef.offsetTop; const elemTop = currentRef.offsetTop;
let elemBottom = elemTop - currentRef.offsetHeight; let elemBottom = elemTop - currentRef.offsetHeight;
const elementIsInView = elemBottom < chatWindowBottom && elemTop > chatWindowTop; const elementIsInView = elemBottom < chatWindowBottom && elemTop > chatWindowTop;
if (!elementIsInView) { if (!elementIsInView) {
this.aiChatWindowRef.current.scrollTop = elemBottom - this.aiChatWindowRef.current.clientHeight / 3; console.log("elemBottom", elemBottom);
console.log(
"this.aiChatWindowRef.current.clientHeight",
this.aiChatWindowRef.current.clientHeight,
this.aiChatWindowRef.current.clientHeight / 2
);
// this.aiChatWindowRef.current.scrollTop = elemBottom - this.aiChatWindowRef.current.clientHeight / 3;
viewport.scrollTo({
behavior: "auto",
top: elemTop - 20,
});
} }
} }
} }