mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-08-11 22:00:59 +00: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,
|
text: r.text,
|
||||||
type: r.type,
|
type: r.type,
|
||||||
subText: r.subText,
|
subText: r.subText,
|
||||||
extra: r.extra
|
extra: r.extra,
|
||||||
|
postId: r.postId
|
||||||
}))
|
}))
|
||||||
return results.value
|
return results.value
|
||||||
}
|
}
|
||||||
@@ -76,7 +77,9 @@ export default {
|
|||||||
} else if (opt.type === 'user') {
|
} else if (opt.type === 'user') {
|
||||||
router.push(`/users/${opt.id}`)
|
router.push(`/users/${opt.id}`)
|
||||||
} else if (opt.type === 'comment') {
|
} else if (opt.type === 'comment') {
|
||||||
// code here
|
if (opt.postId) {
|
||||||
|
router.push(`/posts/${opt.postId}#comment-${opt.id}`)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
selected.value = null
|
selected.value = null
|
||||||
keyword.value = ''
|
keyword.value = ''
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ public class SearchController {
|
|||||||
dto.setText(r.text());
|
dto.setText(r.text());
|
||||||
dto.setSubText(r.subText());
|
dto.setSubText(r.subText());
|
||||||
dto.setExtra(r.extra());
|
dto.setExtra(r.extra());
|
||||||
|
dto.setPostId(r.postId());
|
||||||
return dto;
|
return dto;
|
||||||
})
|
})
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
@@ -96,5 +97,6 @@ public class SearchController {
|
|||||||
private String text;
|
private String text;
|
||||||
private String subText;
|
private String subText;
|
||||||
private String extra;
|
private String extra;
|
||||||
|
private Long postId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ public class SearchService {
|
|||||||
u.getId(),
|
u.getId(),
|
||||||
u.getUsername(),
|
u.getUsername(),
|
||||||
u.getIntroduction(),
|
u.getIntroduction(),
|
||||||
|
null,
|
||||||
null
|
null
|
||||||
));
|
));
|
||||||
|
|
||||||
@@ -64,7 +65,8 @@ public class SearchService {
|
|||||||
p.getId(),
|
p.getId(),
|
||||||
p.getTitle(),
|
p.getTitle(),
|
||||||
p.getCategory().getName(),
|
p.getCategory().getName(),
|
||||||
extractSnippet(p.getContent(), keyword, false)
|
extractSnippet(p.getContent(), keyword, false),
|
||||||
|
null
|
||||||
)),
|
)),
|
||||||
searchPostsByTitle(keyword).stream()
|
searchPostsByTitle(keyword).stream()
|
||||||
.map(p -> new SearchResult(
|
.map(p -> new SearchResult(
|
||||||
@@ -72,7 +74,8 @@ public class SearchService {
|
|||||||
p.getId(),
|
p.getId(),
|
||||||
p.getTitle(),
|
p.getTitle(),
|
||||||
p.getCategory().getName(),
|
p.getCategory().getName(),
|
||||||
extractSnippet(p.getContent(), keyword, true)
|
extractSnippet(p.getContent(), keyword, true),
|
||||||
|
null
|
||||||
))
|
))
|
||||||
)
|
)
|
||||||
.collect(java.util.stream.Collectors.toMap(
|
.collect(java.util.stream.Collectors.toMap(
|
||||||
@@ -91,7 +94,8 @@ public class SearchService {
|
|||||||
c.getId(),
|
c.getId(),
|
||||||
extractSnippet(c.getContent(), keyword, false),
|
extractSnippet(c.getContent(), keyword, false),
|
||||||
c.getAuthor().getUsername(),
|
c.getAuthor().getUsername(),
|
||||||
c.getPost().getTitle()
|
c.getPost().getTitle(),
|
||||||
|
c.getPost().getId()
|
||||||
));
|
));
|
||||||
|
|
||||||
return Stream.concat(Stream.concat(users, mergedPosts.stream()), comments)
|
return Stream.concat(Stream.concat(users, mergedPosts.stream()), comments)
|
||||||
@@ -114,5 +118,5 @@ public class SearchService {
|
|||||||
return content.substring(start, end);
|
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