userinfo.vue 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <script setup lang="ts">
  2. import { token } from '../../plugins/pinia'
  3. import service from '../../plugins/axios'
  4. import { reactive, ref } from 'vue'
  5. const info = ref()
  6. const data = await service({
  7. url: '/userinfo',
  8. method: 'get',
  9. headers: {
  10. Authorization: 'Bearer ' + token().token,
  11. },
  12. })
  13. if (data.data.cod === 200) {
  14. info.value = data.data.data
  15. }
  16. //隐藏多余字符串
  17. function hideStr(str: string) {
  18. return str.replace(/^(.{4}).*$/, '$1...')
  19. }
  20. const outlogin = () => {
  21. token().token = ''
  22. }
  23. </script>
  24. <template>
  25. <el-row>
  26. <el-space wrap>
  27. <el-col :span="10">
  28. <el-avatar src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png" />
  29. </el-col>
  30. <el-col :span="16">
  31. <el-row>
  32. <el-col :span="24">
  33. <el-button type="text">{{hideStr(info.username)}}</el-button>
  34. </el-col>
  35. <el-col :span="24">
  36. <el-button type="text">个人主页</el-button>
  37. </el-col>
  38. </el-row>
  39. </el-col>
  40. </el-space>
  41. <el-col :span="24">
  42. <el-space wrap>
  43. <div>
  44. <el-button type="text">[用户]lv.{{info.user.level}}</el-button>
  45. </div>
  46. <div>
  47. <el-button type="text">{{info.user.exp}}/max?</el-button>
  48. </div>
  49. </el-space>
  50. </el-col>
  51. <el-divider></el-divider>
  52. <el-col :span="8">
  53. <el-row>
  54. <el-col :span="24">
  55. <div style="text-align: center;">枫币</div>
  56. </el-col>
  57. <el-col :span="24">
  58. <div style="text-align: center;">0</div>
  59. </el-col>
  60. </el-row>
  61. </el-col>
  62. <el-col :span="8">
  63. <el-row>
  64. <el-col :span="24">
  65. <div style="text-align: center;">发帖数</div>
  66. </el-col>
  67. <el-col :span="24">
  68. <div style="text-align: center;">0</div>
  69. </el-col>
  70. </el-row>
  71. </el-col>
  72. <el-col :span="8">
  73. <el-row>
  74. <el-col :span="24">
  75. <div style="text-align: center;">回帖数</div>
  76. </el-col>
  77. <el-col :span="24">
  78. <div style="text-align: center;">0</div>
  79. </el-col>
  80. </el-row>
  81. </el-col>
  82. </el-row>
  83. <el-row>
  84. <el-col :span="24">
  85. <div style="float:right;">
  86. <el-button type="text"
  87. @click="outlogin">退出</el-button>
  88. </div>
  89. </el-col>
  90. </el-row>
  91. </template>
  92. <style scoped lang="scss">
  93. </style>