@@ -49,12 +49,9 @@ export default {
49
49
name: " PlaygroundBlock" ,
50
50
components: { PgEditor, RulesSettings, SnsBar },
51
51
data () {
52
- const serializedString =
53
- (typeof window !== " undefined" && window .location .hash .slice (1 )) || " " ;
54
- const state = deserializeState (serializedString);
55
52
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 ),
58
55
messages: [],
59
56
};
60
57
},
@@ -75,12 +72,16 @@ export default {
75
72
},
76
73
watch: {
77
74
serializedString (serializedString ) {
78
- if (typeof window !== " undefined" ) {
75
+ if (
76
+ typeof window !== " undefined" &&
77
+ serializedString !== window .location .hash .slice (1 )
78
+ ) {
79
79
window .location .replace (` #${ serializedString} ` );
80
80
}
81
81
},
82
82
},
83
83
mounted () {
84
+ this .onUrlHashChange ();
84
85
if (typeof window !== " undefined" ) {
85
86
window .addEventListener (" hashchange" , this .onUrlHashChange );
86
87
}
@@ -104,7 +105,6 @@ export default {
104
105
const state = deserializeState (serializedString);
105
106
this .code = state .code || DEFAULT_CODE ;
106
107
this .rules = state .rules || Object .assign ({}, DEFAULT_RULES_CONFIG );
107
- this .script = state .script ;
108
108
}
109
109
},
110
110
},
0 commit comments