Skip to content

Commit 83830ba

Browse files
authored
Fix Crash And Refine Tips
- Fix crash described in #164 - Upgrade unique-random-array to v2.0 - Refine tips to ts
1 parent ed94afa commit 83830ba

File tree

5 files changed

+33
-24
lines changed

5 files changed

+33
-24
lines changed

app/index.js

+6
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ app.on('window-all-closed', () => {
106106
})
107107

108108
app.on('activate', (e, hasVisibleWindows) => {
109+
// If the application is not ready, then
110+
// just return and wait when the app is ready.
111+
if (!app.isReady()) {
112+
return
113+
}
114+
109115
if (mainWindow == null) {
110116
mainWindow = createMainWindow()
111117
if (platform === 'darwin') {

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
"pify": "^2.3.0",
8888
"sanitize-html": "^1.13.0",
8989
"sumchecker": "^2.0.1",
90-
"unique-random-array": "^1.0.0",
90+
"unique-random-array": "^2.0.0",
9191
"vuex": "^2.1.1"
9292
}
9393
}

src/components/tip.vue

+16-14
Original file line numberDiff line numberDiff line change
@@ -32,26 +32,28 @@
3232
</div>
3333
</template>
3434

35-
<script>
36-
import random from 'unique-random-array'
37-
import tips from 'utils/tips'
35+
<script lang="ts">
36+
import tips from "utils/tips";
37+
import uniqueRandomArray from "unique-random-array";
38+
import Vue from "vue";
3839
39-
const randomTip = random(tips)
40+
const randomTips = uniqueRandomArray(tips);
4041
41-
export default {
42-
data() {
42+
export default Vue.extend({
43+
data: function() {
4344
return {
44-
tip: randomTip()
45-
}
45+
tip: randomTips(),
46+
interval: 0
47+
};
4648
},
4749
mounted() {
48-
this.interval = setInterval(() => {
49-
this.tip = randomTip()
50-
}, 20000)
50+
this.interval = window.setInterval(() => {
51+
this.tip = randomTips();
52+
}, 20000);
5153
},
5254
beforeDestroy() {
53-
clearInterval(this.interval)
54-
this.interval = null
55+
clearInterval(this.interval);
5556
}
56-
}
57+
});
58+
5759
</script>

tsconfig.json

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"compilerOptions": {
33
"outDir": "./dist/",
44
"allowJs": true,
5+
"allowSyntheticDefaultImports": true,
56
"sourceMap": true,
67
"strict": true,
78
"noImplicitReturns": true,

yarn.lock

+9-9
Original file line numberDiff line numberDiff line change
@@ -7727,17 +7727,17 @@ uniqs@^2.0.0:
77277727
resolved "https://registry.yarnpkg.com/uniqs/-/uniqs-2.0.0.tgz#ffede4b36b25290696e6e165d4a59edb998e6b02"
77287728
integrity sha1-/+3ks2slKQaW5uFl1KWe25mOawI=
77297729

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

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

77427742
unique-string@^2.0.0:
77437743
version "2.0.0"

0 commit comments

Comments
 (0)