From b89cef5b7caa1963441d99d33f93c851933cf757 Mon Sep 17 00:00:00 2001 From: yuetsh <517252939@qq.com> Date: Thu, 19 Dec 2024 23:03:52 +0800 Subject: [PATCH] fix --- src/composables/code.ts | 12 +++++------- src/desktop/Query.vue | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/composables/code.ts b/src/composables/code.ts index 4e32d7a..d622e30 100644 --- a/src/composables/code.ts +++ b/src/composables/code.ts @@ -1,6 +1,6 @@ import { useStorage } from "@vueuse/core" import copyTextToClipboard from "copy-text-to-clipboard" -import queryString from "query-string" +import qs from "query-string" import { reactive, ref, watch } from "vue" import { getCodeByQuery, submit } from "../api" import { sources } from "../templates" @@ -63,7 +63,7 @@ export async function init() { size.value = cache.fontsize.value status.value = Status.NotStarted - const parsed = queryString.parse(location.search) + const parsed = qs.parse(location.search) const base64 = parsed.share as string if (base64) { try { @@ -91,10 +91,8 @@ export function reset() { cache.code[code.language].value = sources[code.language] output.value = "" status.value = Status.NotStarted - const u = new URL(window.location.href) - u.hash = "" - u.search = "" - window.location.href = u.href + const url = qs.exclude(location.href, ["query"]) + window.location.href = url } export async function run() { @@ -120,6 +118,6 @@ export function share() { } const base64 = utoa(JSON.stringify(data)) copyTextToClipboard( - queryString.stringifyUrl({ url: location.href, query: { share: base64 } }), + qs.stringifyUrl({ url: location.href, query: { share: base64 } }), ) } diff --git a/src/desktop/Query.vue b/src/desktop/Query.vue index 87a91c8..efb6230 100644 --- a/src/desktop/Query.vue +++ b/src/desktop/Query.vue @@ -1,26 +1,23 @@