Skip to content

Commit

Permalink
Fix Crash And Refine Tips
Browse files Browse the repository at this point in the history
- Fix crash described in #164
- Upgrade unique-random-array to v2.0
- Refine tips to ts
  • Loading branch information
elite-sheep committed Jul 23, 2020
1 parent ed94afa commit 83830ba
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 24 deletions.
6 changes: 6 additions & 0 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ app.on('window-all-closed', () => {
})

app.on('activate', (e, hasVisibleWindows) => {
// If the application is not ready, then
// just return and wait when the app is ready.
if (!app.isReady()) {
return
}

if (mainWindow == null) {
mainWindow = createMainWindow()
if (platform === 'darwin') {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"pify": "^2.3.0",
"sanitize-html": "^1.13.0",
"sumchecker": "^2.0.1",
"unique-random-array": "^1.0.0",
"unique-random-array": "^2.0.0",
"vuex": "^2.1.1"
}
}
30 changes: 16 additions & 14 deletions src/components/tip.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,28 @@
</div>
</template>

<script>
import random from 'unique-random-array'
import tips from 'utils/tips'
<script lang="ts">
import tips from "utils/tips";
import uniqueRandomArray from "unique-random-array";
import Vue from "vue";

const randomTip = random(tips)
const randomTips = uniqueRandomArray(tips);

export default {
data() {
export default Vue.extend({
data: function() {
return {
tip: randomTip()
}
tip: randomTips(),
interval: 0
};
},
mounted() {
this.interval = setInterval(() => {
this.tip = randomTip()
}, 20000)
this.interval = window.setInterval(() => {
this.tip = randomTips();
}, 20000);
},
beforeDestroy() {
clearInterval(this.interval)
this.interval = null
clearInterval(this.interval);
}
}
});

</script>
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"compilerOptions": {
"outDir": "./dist/",
"allowJs": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"strict": true,
"noImplicitReturns": true,
Expand Down
18 changes: 9 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7727,17 +7727,17 @@ uniqs@^2.0.0:
resolved "https://registry.yarnpkg.com/uniqs/-/uniqs-2.0.0.tgz#ffede4b36b25290696e6e165d4a59edb998e6b02"
integrity sha1-/+3ks2slKQaW5uFl1KWe25mOawI=

unique-random-array@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/unique-random-array/-/unique-random-array-1.0.1.tgz#f29bda2a62be8860a703c4739c8f4fdb4d722cc7"
integrity sha512-z9J/SV8CUIhIRROcHe9YUoAT6XthUJt0oUyLGgobiXJprDP9O9dsErNevvSaAv5BkhwFEVPn6nIEOKeNE6Ck1Q==
unique-random-array@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/unique-random-array/-/unique-random-array-2.0.0.tgz#9e639b1a9dc141e97350a6fc6f17da4b0717b1ad"
integrity sha512-xR87O95fZ7hljw84J8r1YDXrvffPLWN513BNOP4Bv0KcgG5dyEUrHwsvP7mVAOKg4Y80uqRbpUk0GKr8il70qg==
dependencies:
unique-random "^1.0.0"
unique-random "^2.1.0"

unique-random@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/unique-random/-/unique-random-1.0.0.tgz#ce3e224c8242cd33a0e77b0d7180d77e6b62d0c4"
integrity sha1-zj4iTIJCzTOg53sNcYDXfmti0MQ=
unique-random@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/unique-random/-/unique-random-2.1.0.tgz#7a8413da5176d028567168b57125ac5c0cec5c25"
integrity sha512-iQ1ZgWac3b8YxGThecQFRQiqgk6xFERRwHZIWeVVsqlbmgCRl0PY13R4mUkodNgctmg5b5odG1nyW/IbOxQTqg==

unique-string@^2.0.0:
version "2.0.0"
Expand Down

0 comments on commit 83830ba

Please sign in to comment.