diff --git a/shandan-browser/src/main/java/com/keyware/shandan/browser/service/FileSearchService.java b/shandan-browser/src/main/java/com/keyware/shandan/browser/service/FileSearchService.java index 26dc691..0122f90 100644 --- a/shandan-browser/src/main/java/com/keyware/shandan/browser/service/FileSearchService.java +++ b/shandan-browser/src/main/java/com/keyware/shandan/browser/service/FileSearchService.java @@ -21,6 +21,7 @@ import org.elasticsearch.client.RequestOptions; import org.elasticsearch.client.Requests; import org.elasticsearch.client.RestHighLevelClient; import org.elasticsearch.index.query.BoolQueryBuilder; +import org.elasticsearch.index.query.MatchPhraseQueryBuilder; import org.elasticsearch.index.query.QueryBuilder; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.search.SearchHits; @@ -138,11 +139,16 @@ public class FileSearchService { return PageVo.ofSearchHits(response.getHits(), param); } - private List getChildrenByDirId(String dirId) { - DirectoryVo dir = directoryService.getById(dirId); - return StreamUtil.as(directoryService.childrenLists(dir, ReviewStatus.SUBMITTED)).map(DirectoryVo::getId).toList(); - } - + /** + * 图片检索 + * + * @param dirId + * @param searchText + * @param pageNo + * @param pageSize + * @return + * @throws IOException + */ public PageVo searchImage(String dirId, String searchText, int pageNo, int pageSize) throws IOException { SearchRequest request = Requests.searchRequest("shandan"); SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); @@ -159,8 +165,9 @@ public class FileSearchService { } if (StringUtils.hasText(searchText)) { BoolQueryBuilder boolQuery = QueryBuilders.boolQuery(); - boolQuery.should(QueryBuilders.matchPhraseQuery("fileName", searchText)); - queryBuilder.must(boolQuery); + MatchPhraseQueryBuilder matchPhraseQuery = QueryBuilders.matchPhraseQuery("fileName", searchText); + boolQuery.should(); + queryBuilder.must(matchPhraseQuery); } searchSourceBuilder.query(queryBuilder); @@ -184,4 +191,10 @@ public class FileSearchService { }).collect(Collectors.toList())); return PageVo.ofSearchHits(response.getHits(), page); } + + private List getChildrenByDirId(String dirId) { + DirectoryVo dir = directoryService.getById(dirId); + return StreamUtil.as(directoryService.childrenLists(dir, ReviewStatus.SUBMITTED)).map(DirectoryVo::getId).toList(); + } + } diff --git a/shandan-browser/src/main/resources/static/js/browser.js b/shandan-browser/src/main/resources/static/js/browser.js index f2834d8..9187431 100644 --- a/shandan-browser/src/main/resources/static/js/browser.js +++ b/shandan-browser/src/main/resources/static/js/browser.js @@ -499,19 +499,25 @@ layui.use(['layer', 'listPage', 'globalTree', 'gtable', 'form', 'element', 'drop * 流式加载图片 */ function queryImages(dirId, searchText) { + const {protocol, host, port} = window.location; let pageNo = 1, pageSize = 20; - $('#layer-photos').html('') + $('#pic-container').html('') layui.flow.load({ elem: '#pic-container', isAuto: true, mb: 100, + scrollElem: $('#pic-container').parent(), done: function (page, next) { //执行下一页的回调 pageNo = page; Util.get(`/search/image/page/${dirId}`, {pageNo, pageSize, searchText}).then(({flag, data, msg}) => { if (flag) { console.info(data); const {records, pageTotal} = data, picItems = []; + const domain = protocol + "//" + host, pubDomain = 'http://24.47.112.32:6688'; for (const pic of records) { + if (pic.src.startsWith(pubDomain) && host !== '24.47.112.32') { + pic.src = pic.src.replace(pubDomain, domain) + } const htm = `
  • ${pic.title} diff --git a/shandan-browser/src/main/resources/view/browser.html b/shandan-browser/src/main/resources/view/browser.html index 78fbdd7..194f6a0 100644 --- a/shandan-browser/src/main/resources/view/browser.html +++ b/shandan-browser/src/main/resources/view/browser.html @@ -257,7 +257,9 @@ -
      +
      +
        +
        @@ -273,7 +275,7 @@ const sizeInit = () => { $(".layui-card-body").height(window.innerHeight - 20); $("#tree-toobar-div").height($(".layui-card-body").height() - 25 - 45); - $(".picture-container").height($(".layui-card-body").height() - 140); + $(".pic-box").height($(".layui-card-body").height() - 140); } window.onresize = sizeInit; sizeInit();