Skip to content

Commit

Permalink
fix(ui): improved performance
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume Chau committed Jun 15, 2018
1 parent cfed833 commit c378658
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ import { size } from '../filters'
import DonutModule from './DonutModule.vue'
export default {
clientState: true,
mixins: [
Dashboard
],
Expand Down
6 changes: 6 additions & 0 deletions packages/@vue/cli-ui/src/components/ConnectionStatus.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
</ApolloQuery>
</template>

<script>
export default {
clientState: true
}
</script>

<style lang="stylus" scoped>
@import "~@/style/imports"
Expand Down
2 changes: 2 additions & 0 deletions packages/@vue/cli-ui/src/components/StatusBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ import DARK_MODE_SET from '../graphql/darkModeSet.gql'
let lastRoute
export default {
clientState: true,
data () {
return {
showLogs: false,
Expand Down
27 changes: 12 additions & 15 deletions packages/@vue/cli-ui/src/components/TerminalView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ const darkTheme = {
}
export default {
clientState: true,
props: {
cols: {
type: Number,
Expand Down Expand Up @@ -136,21 +138,12 @@ export default {
content: 'setContent',
theme: {
handler (value) {
if (this.$_terminal) {
this.$_terminal._setTheme(this.theme)
}
},
immediate: true
}
},
mounted () {
this.initTerminal()
if (this.autoSize) {
this.$nextTick(this.fit)
darkMode (value, oldValue) {
if (typeof oldValue === 'undefined') {
this.initTerminal()
} else if (this.$_terminal) {
this.$_terminal._setTheme(this.theme)
}
}
},
Expand All @@ -171,6 +164,10 @@ export default {
term.on('blur', () => this.$emit('blur'))
term.on('focus', () => this.$emit('focus'))
if (this.autoSize) {
this.$nextTick(this.fit)
}
},
setContent (value, ln = true) {
Expand Down
23 changes: 19 additions & 4 deletions packages/@vue/cli-ui/src/mixins/ClientState.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,24 @@ import DARK_MODE from '../graphql/darkMode.gql'

// @vue/component
export default {
apollo: {
// In plugins, user `this.$root.connected` for example
connected: CONNECTED,
darkMode: DARK_MODE
beforeCreate () {
if (this.$options.clientState) {
const newData = {
connected: CONNECTED,
darkMode: DARK_MODE
}
this.$options.apollo = {
...this.$options.apollo,
...newData
}
// Proxy prop on `this`
for (const key in newData) {
Object.defineProperty(this, key, {
get: () => this.$data.$apolloData.data[key],
enumerable: true,
configurable: true
})
}
}
}
}

0 comments on commit c378658

Please sign in to comment.