You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

109 lines
2.2 KiB

  1. <template>
  2. <view class="main">
  3. <view :style="{height:iSMT+'px'}"></view>
  4. <view class="top">
  5. <view class="top-list">
  6. <text>自动选择</text>
  7. <radio value="0" class="radio-btn" activeBackgroundColor="red"
  8. :checked="selectedIndex === 0" @click="selectFont(0)" />
  9. </view>
  10. <view class="top-list">
  11. <text>新加坡服务器</text>
  12. <radio value="1" class="radio-btn" activeBackgroundColor="red"
  13. :checked="selectedIndex === 1" @click="selectFont(1)" />
  14. </view>
  15. <view class="top-list">
  16. <text>香港服务器</text>
  17. <radio value="2" class="radio-btn" activeBackgroundColor="red"
  18. :checked="selectedIndex === 2" @click="selectFont(2)" />
  19. </view>
  20. </view>
  21. </view>
  22. </template>
  23. <script setup>
  24. import {
  25. ref,
  26. onMounted
  27. } from 'vue'
  28. import {
  29. getSetting
  30. } from "@/api/setting/general"
  31. const iSMT = ref(0)
  32. const selectedIndex = ref(0)
  33. const getServer = async () => {
  34. try {
  35. const res = await getSetting()
  36. if (res.code === 200) {
  37. const fontSize = res.data.fontSize
  38. const sizeMap = {
  39. 'auto': 0,
  40. 'singapore': 1,
  41. 'hongkong': 2
  42. }
  43. console.log('看看服务器', res.data.fontSize)
  44. selectedIndex.value = sizeMap[fontSize] ?? 0;
  45. }
  46. } catch (err) {
  47. console.error("获取服务器设置失败:", err);
  48. }
  49. }
  50. const selectFont = (index) => {
  51. selectedIndex.value = index
  52. console.log('看看选中状态',selectedIndex.value)
  53. }
  54. onMounted(() => {
  55. // 状态栏高度
  56. iSMT.value = uni.getSystemInfoSync().statusBarHeight;
  57. console.log('看看高度', iSMT.value)
  58. getServer()
  59. })
  60. </script>
  61. <style>
  62. .top {
  63. margin-top: 1.5vh;
  64. height: 21vh;
  65. background-color: white;
  66. }
  67. .top-list {
  68. width: 630rpx;
  69. height: 7vh;
  70. display: flex;
  71. align-items: center;
  72. justify-content: center;
  73. margin: 0 40rpx;
  74. padding: 0 10rpx;
  75. border-bottom: 1rpx solid #eee;
  76. }
  77. .top-list:last-child {
  78. border-bottom: none;
  79. }
  80. .switch-btn {
  81. width: 100rpx;
  82. transform: scale(0.6);
  83. transform-origin: center right;
  84. }
  85. .public {
  86. width: 450rpx;
  87. margin-left: auto;
  88. font-size: 10px;
  89. color: rgb(203, 203, 203);
  90. }
  91. .arrow {
  92. margin-left: auto;
  93. }
  94. .radio-btn {
  95. margin-left: auto;
  96. transform: scale(0.6);
  97. }
  98. </style>