Skip to content

Commit 19501c6

Browse files
committed
chore: fix demo
1 parent dcabb84 commit 19501c6

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

Diff for: docs/.vitepress/theme/components/playground-block.vue

+7-7
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,9 @@ export default {
4949
name: "PlaygroundBlock",
5050
components: { PgEditor, RulesSettings, SnsBar },
5151
data() {
52-
const serializedString =
53-
(typeof window !== "undefined" && window.location.hash.slice(1)) || "";
54-
const state = deserializeState(serializedString);
5552
return {
56-
code: state.code || DEFAULT_CODE,
57-
rules: state.rules || Object.assign({}, DEFAULT_RULES_CONFIG),
53+
code: DEFAULT_CODE,
54+
rules: Object.assign({}, DEFAULT_RULES_CONFIG),
5855
messages: [],
5956
};
6057
},
@@ -75,12 +72,16 @@ export default {
7572
},
7673
watch: {
7774
serializedString(serializedString) {
78-
if (typeof window !== "undefined") {
75+
if (
76+
typeof window !== "undefined" &&
77+
serializedString !== window.location.hash.slice(1)
78+
) {
7979
window.location.replace(`#${serializedString}`);
8080
}
8181
},
8282
},
8383
mounted() {
84+
this.onUrlHashChange();
8485
if (typeof window !== "undefined") {
8586
window.addEventListener("hashchange", this.onUrlHashChange);
8687
}
@@ -104,7 +105,6 @@ export default {
104105
const state = deserializeState(serializedString);
105106
this.code = state.code || DEFAULT_CODE;
106107
this.rules = state.rules || Object.assign({}, DEFAULT_RULES_CONFIG);
107-
this.script = state.script;
108108
}
109109
},
110110
},

0 commit comments

Comments
 (0)