更新路由历史模式为 hash,并调整生成的 URL 以支持 hash 模式下的参数解析

This commit is contained in:
hxuanyu 2025-06-26 00:39:28 +08:00
parent 03a19beafa
commit 64fd4d1a71
3 changed files with 6 additions and 4 deletions

View File

@ -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: '/',

View File

@ -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

View File

@ -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) {