Skip to content

Commit

Permalink
fix(plugins/materials): fix new app with no page should not set url p…
Browse files Browse the repository at this point in the history
…age id to undefined
  • Loading branch information
rhlin committed Jan 22, 2025
1 parent dd8ae42 commit 448cc75
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions packages/plugins/materials/src/composable/useResource.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,21 @@ const appSchemaState = reactive({
materialsDeps: { scripts: [], styles: new Set() }
})

function goPage(pageId) {
const url = new URL(window.location)

url.searchParams.set('pageid', pageId)
window.history.pushState({}, '', url)
usePage().postLocationHistoryChanged({ pageId })
}

const initPage = (pageInfo) => {
try {
if (pageInfo.meta) {
const { occupier } = pageInfo.meta

useLayout().layoutState.pageStatus = getCanvasStatus(occupier)
goPage(pageInfo.meta?.id)
} else {
useLayout().layoutState.pageStatus = {
state: 'empty',
Expand All @@ -54,12 +63,6 @@ const initPage = (pageInfo) => {
pageInfo.id = pageInfo.meta?.id
} catch (error) {
console.log(error) // eslint-disable-line
} finally {
const url = new URL(window.location)

url.searchParams.set('pageid', pageInfo.id)
window.history.pushState({}, '', url)
usePage().postLocationHistoryChanged({ pageId: pageInfo.id })
}

const { id, meta, ...pageSchema } = pageInfo
Expand Down

0 comments on commit 448cc75

Please sign in to comment.