Live.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <script setup>
  2. /* Import modules. */
  3. import numeral from 'numeral'
  4. /* Initialize stores. */
  5. import { useSystemStore } from '@/stores/system'
  6. const System = useSystemStore()
  7. const displayTicker = computed(() => {
  8. if (!System.ticker) {
  9. return '$0.00'
  10. }
  11. /* Set quote. */
  12. const quote = System.ticker.quote
  13. /* Validate quote. */
  14. if (!quote) {
  15. return '$0.00'
  16. }
  17. /* Set price. */
  18. const price = quote?.USD?.price
  19. /* Validate price. */
  20. if (!price) {
  21. return '$0.00'
  22. }
  23. /* Return formatted price. */
  24. return numeral(price * 1000000).format('$0,0.00')
  25. })
  26. const displayPctChg = computed(() => {
  27. if (!System.ticker) {
  28. return '0.0%'
  29. }
  30. /* Set quote. */
  31. const quote = System.ticker.quote
  32. /* Validate quote. */
  33. if (!quote) {
  34. return '0.0%'
  35. }
  36. /* Set percentage change. */
  37. const pctChg24h = quote?.USD?.pctChg24h
  38. /* Validate change. */
  39. if (!pctChg24h) {
  40. return '0.0%'
  41. }
  42. /* Return formatted price. */
  43. return numeral(pctChg24h / 100).format('0.00%')
  44. })
  45. const displayVol = computed(() => {
  46. if (!System.ticker) {
  47. return '0'
  48. }
  49. /* Set quote. */
  50. const quote = System.ticker.quote
  51. /* Validate quote. */
  52. if (!quote) {
  53. return '0'
  54. }
  55. /* Set percentage change. */
  56. const vol = quote?.USD?.vol24
  57. /* Validate change. */
  58. if (!vol) {
  59. return '0'
  60. }
  61. /* Return formatted price. */
  62. return numeral(vol).format('0[.]0a')
  63. })
  64. // onMounted(() => {
  65. // console.log('Mounted!')
  66. // // Now it's safe to perform setup operations.
  67. // })
  68. // onBeforeUnmount(() => {
  69. // console.log('Before Unmount!')
  70. // // Now is the time to perform all cleanup operations.
  71. // })
  72. </script>
  73. <template>
  74. <main class="flex flex-col gap-4">
  75. <p class="px-3 py-2 bg-rose-100 text-sm border border-rose-200 rounded-lg shadow-md">
  76. Thanks for visiting.
  77. This area is still under development and will be updated soon.
  78. </p>
  79. <h2 class="text-2xl font-medium">
  80. {{displayTicker}} mNEXA / USD
  81. </h2>
  82. <h3 class="text-xl font-medium">
  83. Change: {{displayPctChg}}
  84. </h3>
  85. <h3 class="text-xl font-medium">
  86. Volume: {{displayVol}}
  87. </h3>
  88. </main>
  89. </template>