mirror of
https://github.com/haiwen/seahub.git
synced 2025-07-19 09:37:51 +00:00
fix: semantic-search-enter (#5704)
* fix: semantic-search-enter * fix: semantic-search-enter * fix: code
This commit is contained in:
parent
5d1229cec2
commit
86f535db2d
@ -167,15 +167,23 @@ class Search extends Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
onChangeHandler = (event) => {
|
onChangeHandler = (event) => {
|
||||||
|
const { searchMode } = this.state;
|
||||||
const newValue = event.target.value;
|
const newValue = event.target.value;
|
||||||
this.setState({ value: newValue }, () => {
|
this.setState({ value: newValue }, () => {
|
||||||
if (this.inputValue === newValue.trim()) return;
|
if (this.inputValue === newValue.trim()) return;
|
||||||
this.inputValue = newValue.trim();
|
this.inputValue = newValue.trim();
|
||||||
this.onSearch();
|
this.onSearch(searchMode === SEARCH_MODE.NORMAL);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
onSearch = () => {
|
onKeydownHandler = (event) => {
|
||||||
|
if (isHotkey('enter', event)) {
|
||||||
|
if (this.state.searchMode === SEARCH_MODE.NORMAL) return;
|
||||||
|
this.onSearch(true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
onSearch = (isGetSearchResult) => {
|
||||||
const { value } = this.state;
|
const { value } = this.state;
|
||||||
const { repoID } = this.props;
|
const { repoID } = this.props;
|
||||||
const _this = this;
|
const _this = this;
|
||||||
@ -190,6 +198,7 @@ class Search extends Component {
|
|||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!isGetSearchResult) return;
|
||||||
|
|
||||||
const queryData = {
|
const queryData = {
|
||||||
q: value,
|
q: value,
|
||||||
@ -488,18 +497,18 @@ class Search extends Component {
|
|||||||
|
|
||||||
if (searchMode === SEARCH_MODE.SIMILARITY) {
|
if (searchMode === SEARCH_MODE.SIMILARITY) {
|
||||||
if (currentIndexState === INDEX_STATE.FINISHED) {
|
if (currentIndexState === INDEX_STATE.FINISHED) {
|
||||||
this.onSearch();
|
this.onSearch(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
seafileAPI.queryLibraryIndexState(repoID).then(res => {
|
seafileAPI.queryLibraryIndexState(repoID).then(res => {
|
||||||
const { state: indexState, task_id: taskId } = res.data;
|
const { state: indexState, task_id: taskId } = res.data;
|
||||||
this.setState({ indexState }, () => {
|
this.setState({ indexState }, () => {
|
||||||
if (indexState === INDEX_STATE.FINISHED) {
|
if (indexState === INDEX_STATE.FINISHED) {
|
||||||
this.onSearch();
|
this.onSearch(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (indexState === INDEX_STATE.RUNNING) {
|
if (indexState === INDEX_STATE.RUNNING) {
|
||||||
this.queryIndexTaskStatus(taskId, this.onSearch);
|
this.queryIndexTaskStatus(taskId, () => this.onSearch(true));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -569,6 +578,7 @@ class Search extends Component {
|
|||||||
autoComplete="off"
|
autoComplete="off"
|
||||||
ref={this.inputRef}
|
ref={this.inputRef}
|
||||||
readOnly={isCloseShow && enableSeafileAI && SEARCH_MODE.SIMILARITY === searchMode && indexState !== INDEX_STATE.FINISHED}
|
readOnly={isCloseShow && enableSeafileAI && SEARCH_MODE.SIMILARITY === searchMode && indexState !== INDEX_STATE.FINISHED}
|
||||||
|
onKeyDown={this.onKeydownHandler}
|
||||||
/>
|
/>
|
||||||
{(this.state.isCloseShow && username) &&
|
{(this.state.isCloseShow && username) &&
|
||||||
<a href={searchPageUrl} className="search-icon-right input-icon-addon fas fa-external-link-alt search-icon-arrow"></a>
|
<a href={searchPageUrl} className="search-icon-right input-icon-addon fas fa-external-link-alt search-icon-arrow"></a>
|
||||||
|
Loading…
Reference in New Issue
Block a user