Skip to content

Commit ddd3328

Browse files
Sami KolariSami Kolari
Sami Kolari
authored and
Sami Kolari
committed
preload fonts, fix click event bug
1 parent 6299ab5 commit ddd3328

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

src/components/Navbar.vue

+4-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export default {
116116
},
117117
onClick(ev) {
118118
// close link dropdown if clicked outside
119-
if (this.linkDropdownOpen && !this.$refs.dropdown.contains(ev.target)) this.linkDropdownOpen = false
119+
if (this.linkDropdownOpen && this.$refs.dropdown && !this.$refs.dropdown.contains(ev.target)) this.linkDropdownOpen = false
120120
}
121121
},
122122
mounted() {
@@ -126,6 +126,9 @@ export default {
126126
observer.observe(this.$refs.nav)
127127
document.addEventListener('click', this.onClick)
128128
},
129+
beforeUnmount() {
130+
document.removeEventListener('click', this.onClick)
131+
},
129132
watch: {
130133
linkDropdownOpen() {
131134
if (this.linkDropdownOpen) this.langDropdownOpen = false

src/components/ResourceBox.vue

+7-3
Original file line numberDiff line numberDiff line change
@@ -259,13 +259,17 @@ export default {
259259
const key = this.stars.find(({ name }) => href.toLowerCase().includes(name.toLowerCase()))
260260
if (key) return key.stars
261261
return null
262+
},
263+
onClick({ target }) {
264+
if (this.$refs.tagInput && !this.$refs.tagInput.contains(target)) this.tagsDropdownShown = false
262265
}
263266
},
264267
mounted() {
265268
this.stars = stars()
266-
document.addEventListener('click', ({ target }) => {
267-
if (!this.$refs.tagInput.contains(target)) this.tagsDropdownShown = false
268-
})
269+
document.addEventListener('click', this.onClick)
270+
},
271+
beforeUnmount() {
272+
document.removeEventListener('click', this.onClick)
269273
}
270274
}
271275
</script>

vue.config.js

+11
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,16 @@ module.exports = {
2929
}
3030
return args
3131
})
32+
config
33+
.plugin('preload')
34+
.tap(args => {
35+
args[0].include = 'allAssets'
36+
args[0].as = (entry) => {
37+
if (/\.css$/.test(entry)) return 'style'
38+
if (/\.woff$/.test(entry)) return 'font'
39+
return 'script'
40+
}
41+
return args
42+
})
3243
}
3344
}

0 commit comments

Comments
 (0)