1
0
Fork 1
mirror of https://example.com synced 2024-11-22 12:46:39 +09:00

feat: automatically populate search parameters when opening search box on search results page

This commit is contained in:
naskya 2024-01-13 12:43:51 +09:00
parent 65d3190134
commit 22f5266241
Signed by: naskya
GPG key ID: 712D413B3A9FED5C

View file

@ -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 });