feat: automatically populate search parameters when opening search box on search results page
This commit is contained in:
parent
65d3190134
commit
22f5266241
1 changed files with 14 additions and 4 deletions
|
@ -115,10 +115,20 @@ const emit = defineEmits<{
|
|||
|
||||
const modal = shallowRef<InstanceType<typeof MkModal>>();
|
||||
|
||||
const searchWords = ref("");
|
||||
const searchUsers = ref("");
|
||||
const searchRange = ref("");
|
||||
const searchPostsWithFiles = ref(false);
|
||||
const searchParams = new URLSearchParams(window.location.search);
|
||||
|
||||
const searchWords = ref(searchParams.get("q") ?? "");
|
||||
const searchUsers = ref(
|
||||
searchParams.get("user") ?? searchParams.get("host") ?? "",
|
||||
);
|
||||
const searchRange = ref(
|
||||
searchParams.has("since") || searchParams.has("until")
|
||||
? `${searchParams.get("since") ?? ""}-${
|
||||
searchParams.get("until") ?? ""
|
||||
}`
|
||||
: "",
|
||||
);
|
||||
const searchPostsWithFiles = ref(searchParams.get("withFiles") === "true");
|
||||
|
||||
function done(canceled: boolean, result?: searchQuery) {
|
||||
emit("done", { canceled, result });
|
||||
|
|
Loading…
Reference in a new issue