refs #3301 Rewrite Preferences/Appearance/Toot with composition API
This commit is contained in:
parent
875d7dbde2
commit
a9513fab4e
|
@ -44,12 +44,13 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script lang="ts">
|
||||||
|
import { defineComponent, computed, toRefs } from 'vue'
|
||||||
import moment from 'moment'
|
import moment from 'moment'
|
||||||
import DisplayStyle from '~/src/constants/displayStyle'
|
import DisplayStyle from '~/src/constants/displayStyle'
|
||||||
import TimeFormat from '~/src/constants/timeFormat'
|
import TimeFormat from '~/src/constants/timeFormat'
|
||||||
|
|
||||||
export default {
|
export default defineComponent({
|
||||||
name: 'toot',
|
name: 'toot',
|
||||||
props: {
|
props: {
|
||||||
displayNameStyle: {
|
displayNameStyle: {
|
||||||
|
@ -61,46 +62,53 @@ export default {
|
||||||
default: TimeFormat.Absolute.value
|
default: TimeFormat.Absolute.value
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
setup(props) {
|
||||||
sampleIcon() {
|
const { displayNameStyle, timeFormat } = toRefs(props)
|
||||||
return 'https://github.com/h3poteto/whalebird-desktop/raw/master/build/icons/256x256.png'
|
|
||||||
},
|
const sampleIcon = 'https://github.com/h3poteto/whalebird-desktop/raw/master/build/icons/256x256.png'
|
||||||
username() {
|
const status = '<p>Sample status</p>'
|
||||||
switch (this.displayNameStyle) {
|
const reblogsCount = 1
|
||||||
|
const favouritesCount = 5
|
||||||
|
|
||||||
|
const username = computed(() => {
|
||||||
|
switch (displayNameStyle.value) {
|
||||||
case DisplayStyle.DisplayNameAndUsername.value:
|
case DisplayStyle.DisplayNameAndUsername.value:
|
||||||
case DisplayStyle.DisplayName.value:
|
case DisplayStyle.DisplayName.value:
|
||||||
return 'Whalebird'
|
return 'Whalebird'
|
||||||
default:
|
default:
|
||||||
return 'whalebird@mastodon.social'
|
return 'whalebird@mastodon.social'
|
||||||
}
|
}
|
||||||
},
|
})
|
||||||
accountName() {
|
const accountName = computed(() => {
|
||||||
switch (this.displayNameStyle) {
|
switch (displayNameStyle.value) {
|
||||||
case DisplayStyle.DisplayNameAndUsername.value:
|
case DisplayStyle.DisplayNameAndUsername.value:
|
||||||
return 'whalebird@mastodon.social'
|
return 'whalebird@mastodon.social'
|
||||||
default:
|
default:
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
},
|
})
|
||||||
timestamp() {
|
const timestamp = computed(() => {
|
||||||
switch (this.timeFormat) {
|
switch (timeFormat.value) {
|
||||||
case TimeFormat.Absolute.value:
|
case TimeFormat.Absolute.value:
|
||||||
return '2018-08-12 20:35:41'
|
return '2018-08-12 20:35:41'
|
||||||
case TimeFormat.Relative.value:
|
case TimeFormat.Relative.value:
|
||||||
return moment('2018-08-12 20:35:41').fromNow()
|
return moment('2018-08-12 20:35:41').fromNow()
|
||||||
|
default:
|
||||||
|
return '2018-08-12 20:35:41'
|
||||||
}
|
}
|
||||||
},
|
})
|
||||||
status() {
|
|
||||||
return '<p>Sample status</p>'
|
return {
|
||||||
},
|
sampleIcon,
|
||||||
reblogsCount() {
|
username,
|
||||||
return 1
|
accountName,
|
||||||
},
|
timestamp,
|
||||||
favouritesCount() {
|
status,
|
||||||
return 5
|
reblogsCount,
|
||||||
|
favouritesCount
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|
Loading…
Reference in New Issue