Skip to content

Commit

Permalink
chore: fix site code
Browse files Browse the repository at this point in the history
  • Loading branch information
ota-meshi committed Sep 25, 2023
1 parent fbb0a9c commit d6cb312
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions docs/.vitepress/theme/components/playground-block.vue
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,9 @@ export default {
name: "PlaygroundBlock",
components: { PgEditor, RulesSettings, SnsBar },
data() {
const serializedString =
(typeof window !== "undefined" && window.location.hash.slice(1)) || "";
const state = deserializeState(serializedString);
return {
code: state.code || DEFAULT_CODE,
rules: state.rules || Object.assign({}, DEFAULT_RULES_CONFIG),
code: DEFAULT_CODE,
rules: Object.assign({}, DEFAULT_RULES_CONFIG),
messages: [],
};
},
Expand All @@ -115,12 +112,16 @@ export default {
},
watch: {
serializedString(serializedString) {
if (typeof window !== "undefined") {
if (
typeof window !== "undefined" &&
serializedString !== window.location.hash.slice(1)
) {
window.location.replace(`#${serializedString}`);
}
},
},
mounted() {
this.onUrlHashChange();
if (typeof window !== "undefined") {
window.addEventListener("hashchange", this.onUrlHashChange);
}
Expand All @@ -144,7 +145,6 @@ export default {
const state = deserializeState(serializedString);
this.code = state.code || DEFAULT_CODE;
this.rules = state.rules || Object.assign({}, DEFAULT_RULES_CONFIG);
this.script = state.script;
}
},
},
Expand Down

0 comments on commit d6cb312

Please sign in to comment.