From 64fd4d1a715a4af2b66d41e159479ccb808fa293 Mon Sep 17 00:00:00 2001 From: hxuanyu <2252193204@qq.com> Date: Thu, 26 Jun 2025 00:39:28 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=B7=AF=E7=94=B1=E5=8E=86?= =?UTF-8?q?=E5=8F=B2=E6=A8=A1=E5=BC=8F=E4=B8=BA=20hash=EF=BC=8C=E5=B9=B6?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E7=94=9F=E6=88=90=E7=9A=84=20URL=20=E4=BB=A5?= =?UTF-8?q?=E6=94=AF=E6=8C=81=20hash=20=E6=A8=A1=E5=BC=8F=E4=B8=8B?= =?UTF-8?q?=E7=9A=84=E5=8F=82=E6=95=B0=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/router/index.ts | 4 ++-- src/views/ConfigView.vue | 2 +- src/views/PreviewView.vue | 4 +++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/router/index.ts b/src/router/index.ts index 769cc89..06fa5c2 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -1,7 +1,7 @@ -import { createRouter, createWebHistory } from 'vue-router'; +import { createRouter, createWebHashHistory } from 'vue-router'; const router = createRouter({ - history: createWebHistory(), + history: createWebHashHistory(), routes: [ { path: '/', diff --git a/src/views/ConfigView.vue b/src/views/ConfigView.vue index 2399876..8cf46a3 100644 --- a/src/views/ConfigView.vue +++ b/src/views/ConfigView.vue @@ -79,7 +79,7 @@ const updateGeneratedUrl = () => { type: selectedWidget.value, config: currentWidgetConfig.value }); - generatedUrl.value = `${baseUrl}/preview?data=${configStr}`; + generatedUrl.value = `${baseUrl}/#/preview?data=${configStr}`; }; // 复制 URL 到剪贴板 diff --git a/src/views/PreviewView.vue b/src/views/PreviewView.vue index bb69a7b..8076c2a 100644 --- a/src/views/PreviewView.vue +++ b/src/views/PreviewView.vue @@ -33,7 +33,9 @@ const widgetComponent = computed(() => { }); onMounted(() => { - const queryParams = new URLSearchParams(window.location.search); + // 在 hash 模式下获取 URL 参数 + const searchParams = window.location.href.split('?')[1]; + const queryParams = new URLSearchParams(searchParams || ''); const data = queryParams.get('data'); if (data) {