Skip to content

Commit

Permalink
fix event-bus
Browse files Browse the repository at this point in the history
  • Loading branch information
Miorey committed Jan 17, 2024
1 parent 21ecefd commit 6be6074
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 23 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wow-launcher",
"version": "0.2.0",
"version": "1.0.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
Expand Down
2 changes: 1 addition & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
</template>

<script>
import PageLoader from "./components/PageLoader";
import MainContent from './components/MainContent';
import FooterAction from "./components/FooterAction";
import PageLoader from "./components/PageLoader";
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { patchManager } = require(`./patchManager`);
// eslint-disable-next-line @typescript-eslint/no-var-requires
Expand Down
28 changes: 10 additions & 18 deletions src/components/PageLoader.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<v-overlay :value="countOverlay !== 0 || !loaded.storage || !loaded.ftp_cli || !loaded.patches">
<v-card v-if="!loaded.storage || !loaded.ftp_cli || !loaded.patches">
<v-overlay :value="isLoaded">
<v-card v-if="isLoaded">
<v-card-title>
{{ `page_loading` }}
</v-card-title>
Expand All @@ -25,26 +25,18 @@

<script>
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { EventBus } = require(`../event-bus`);
const { loaded } = require(`../event-bus`);
export default {
name: `PageLoader`,
data: () => ({
countOverlay: 0,
loaded: {
patches: false,
storage: false,
ftp_cli: false
}
loaded: loaded
}),
async mounted() {
EventBus.$on(`event_loader_start`, () => {
this.countOverlay++;
});
EventBus.$on(`event_loader_stop`, (val) => {
if(val) { this.loaded[val] = true; }
else this.countOverlay--;
});
}
computed: {
isLoaded: function () {
return !this.loaded.storage || !this.loaded.ftp_cli || !this.loaded.patches;
}
},
};
</script>
Expand Down
18 changes: 17 additions & 1 deletion src/event-bus.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,18 @@
import Vue from 'vue';
export const EventBus = new Vue();
export const EventBus = new Vue();

export const loaded = {
patches: false,
storage: false,
ftp_cli: false
};

console.log(`EVENT-BUS.js`);

EventBus.$on(`event_loader_start`, () => {
console.log(`EVENT_LOADER_START`);
});
EventBus.$on(`event_loader_stop`, (val) => {
if(val) { loaded[val] = true; }
console.log(`event_loader_stop`, val, loaded);
});
4 changes: 2 additions & 2 deletions src/patchManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ class PatchManager {
cwd: `storage`,
name: `selectedPatch${this.language}`
});
console.info(`store.path:`, store.path);
const resolveVal = (!store.get(`updated`))? [] : store.get(`patches`);
EventBus.$emit(`event_loader_stop`, `storage`);
const resolveVal = (!store.get(`updated`)) ? [] : store.get(`patches`);
console.log(`resolveVal`, resolveVal);
return resolveVal;
}
Expand Down

0 comments on commit 6be6074

Please sign in to comment.