File tree Expand file tree Collapse file tree 2 files changed +20
-4
lines changed
Expand file tree Collapse file tree 2 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -41,9 +41,7 @@ export const store = reactive({
4141 code : { } ,
4242 config : {
4343 template : '' ,
44- include_test : false ,
45- output_dir : './logs' ,
46- log_every_iters : 2
44+ include_test : false
4745 }
4846} )
4947
@@ -62,7 +60,7 @@ export function saveConfig(key, value) {
6260// render the code if there are fetched files for current selected template
6361export function genCode ( ) {
6462 const currentFiles = files [ store . config . template ]
65- store . code = { }
63+ store . code = { } // empty the `store.code` after changing templates
6664 if ( currentFiles && Object . keys ( currentFiles ) . length ) {
6765 for ( const file in currentFiles ) {
6866 if ( ! store . config . include_test && file === 'test_all.py' ) {
Original file line number Diff line number Diff line change @@ -19,6 +19,8 @@ import SplitPane from '../components/PaneSplit.vue'
1919import PaneRight from ' ../components/PaneRight.vue'
2020import PaneLeft from ' ../components/PaneLeft.vue'
2121import Footer from ' ../components/Footer.vue'
22+ import { onUnmounted } from ' vue'
23+ import { store } from ' ../store'
2224
2325export default {
2426 components: {
@@ -27,6 +29,22 @@ export default {
2729 PaneRight,
2830 PaneLeft,
2931 Footer
32+ },
33+ setup () {
34+ onUnmounted (() => {
35+ // delete each property of config
36+ // since `store.config` is being watched in store.js
37+ // and Vue watch function does not tracked
38+ // if we reassign `store.config` (i.e. store.config = {})
39+ for (const config in store .config ) {
40+ delete store .config [config]
41+ }
42+ // since we delete each property,
43+ // it is better to reassign the initial values
44+ // which are defined in store.js
45+ store .config .template = ' '
46+ store .config .include_test = false
47+ })
3048 }
3149}
3250 </script >
You can’t perform that action at this time.
0 commit comments