mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-02-23 22:50:51 +08:00
Merge pull request #121 from nagisa77/codex/modify-search-result-navigation-for-comments
Update comment search link
This commit is contained in:
@@ -48,7 +48,8 @@ export default {
|
||||
text: r.text,
|
||||
type: r.type,
|
||||
subText: r.subText,
|
||||
extra: r.extra
|
||||
extra: r.extra,
|
||||
postId: r.postId
|
||||
}))
|
||||
return results.value
|
||||
}
|
||||
@@ -76,7 +77,9 @@ export default {
|
||||
} else if (opt.type === 'user') {
|
||||
router.push(`/users/${opt.id}`)
|
||||
} else if (opt.type === 'comment') {
|
||||
// code here
|
||||
if (opt.postId) {
|
||||
router.push(`/posts/${opt.postId}#comment-${opt.id}`)
|
||||
}
|
||||
}
|
||||
selected.value = null
|
||||
keyword.value = ''
|
||||
|
||||
@@ -58,6 +58,7 @@ public class SearchController {
|
||||
dto.setText(r.text());
|
||||
dto.setSubText(r.subText());
|
||||
dto.setExtra(r.extra());
|
||||
dto.setPostId(r.postId());
|
||||
return dto;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
@@ -96,5 +97,6 @@ public class SearchController {
|
||||
private String text;
|
||||
private String subText;
|
||||
private String extra;
|
||||
private Long postId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ public class SearchService {
|
||||
u.getId(),
|
||||
u.getUsername(),
|
||||
u.getIntroduction(),
|
||||
null,
|
||||
null
|
||||
));
|
||||
|
||||
@@ -64,7 +65,8 @@ public class SearchService {
|
||||
p.getId(),
|
||||
p.getTitle(),
|
||||
p.getCategory().getName(),
|
||||
extractSnippet(p.getContent(), keyword, false)
|
||||
extractSnippet(p.getContent(), keyword, false),
|
||||
null
|
||||
)),
|
||||
searchPostsByTitle(keyword).stream()
|
||||
.map(p -> new SearchResult(
|
||||
@@ -72,7 +74,8 @@ public class SearchService {
|
||||
p.getId(),
|
||||
p.getTitle(),
|
||||
p.getCategory().getName(),
|
||||
extractSnippet(p.getContent(), keyword, true)
|
||||
extractSnippet(p.getContent(), keyword, true),
|
||||
null
|
||||
))
|
||||
)
|
||||
.collect(java.util.stream.Collectors.toMap(
|
||||
@@ -91,7 +94,8 @@ public class SearchService {
|
||||
c.getId(),
|
||||
extractSnippet(c.getContent(), keyword, false),
|
||||
c.getAuthor().getUsername(),
|
||||
c.getPost().getTitle()
|
||||
c.getPost().getTitle(),
|
||||
c.getPost().getId()
|
||||
));
|
||||
|
||||
return Stream.concat(Stream.concat(users, mergedPosts.stream()), comments)
|
||||
@@ -114,5 +118,5 @@ public class SearchService {
|
||||
return content.substring(start, end);
|
||||
}
|
||||
|
||||
public record SearchResult(String type, Long id, String text, String subText, String extra) {}
|
||||
public record SearchResult(String type, Long id, String text, String subText, String extra, Long postId) {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user