aboutsummaryrefslogtreecommitdiff
path: root/src/App.vue
diff options
context:
space:
mode:
Diffstat (limited to 'src/App.vue')
-rw-r--r--src/App.vue24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/App.vue b/src/App.vue
index ecf2948..3bbb5cd 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -106,6 +106,7 @@ import {arraySum, randWeightedChoice, timeout} from './util';
// Constants
const SERVER_WAIT_MSG = 'Loading data';
const PROCESSING_WAIT_MSG = 'Processing';
+import initialTrees from './initialTrees.json'; // Cached server data used to reduce load time
// Type representing auto-mode actions
type AutoAction = 'move across' | 'move down' | 'move up' | Action;
// Function used in auto-mode to reduce action cycles
@@ -941,14 +942,19 @@ export default defineComponent({
// Get possible target node from URL
let nodeName = (new URL(window.location.href)).searchParams.get('node');
// Query server
- let urlParams = new URLSearchParams({type: 'node', tree: this.uiOpts.tree});
- if (nodeName != null){
- urlParams.append('name', nodeName);
- urlParams.append('toroot', '1');
- }
- let responseObj: {[x: string]: TolNode} = await this.loadFromServer(urlParams);
- if (responseObj == null){
- return;
+ let responseObj: {[x: string]: TolNode};
+ if (nodeName == null && initialTrees != null){ // Use pre-stored initial-tree data
+ responseObj = initialTrees[this.uiOpts.tree as keyof typeof initialTrees];
+ } else {
+ let urlParams = new URLSearchParams({type: 'node', tree: this.uiOpts.tree});
+ if (nodeName != null){
+ urlParams.append('name', nodeName);
+ urlParams.append('toroot', '1');
+ }
+ responseObj = await this.loadFromServer(urlParams);
+ if (responseObj == null){
+ return;
+ }
}
// Get root node name
let rootName = null;
@@ -1103,7 +1109,7 @@ export default defineComponent({
}
},
},
- created(){
+ mounted(){
window.addEventListener('resize', this.onResize);
window.addEventListener('keydown', this.onKeyUp);
this.initTreeFromServer();