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.
|
|
<template> <view class="main"> <view :style="{height:iSMT+'px'}"></view> <view class="top"> <view class="top-list"> <text>自动选择</text> <radio value="0" class="radio-btn" activeBackgroundColor="red" :checked="selectedIndex === 0" @click="selectFont(0)" /> </view> <view class="top-list"> <text>新加坡服务器</text> <radio value="1" class="radio-btn" activeBackgroundColor="red" :checked="selectedIndex === 1" @click="selectFont(1)" /> </view> <view class="top-list"> <text>香港服务器</text> <radio value="2" class="radio-btn" activeBackgroundColor="red" :checked="selectedIndex === 2" @click="selectFont(2)" /> </view> </view> </view></template>
<script setup> import { ref, onMounted } from 'vue' import { getSetting } from "@/api/setting/general" const iSMT = ref(0) const selectedIndex = ref(0) const getServer = async () => { try { const res = await getSetting() if (res.code === 200) { const fontSize = res.data.fontSize const sizeMap = { 'auto': 0, 'singapore': 1, 'hongkong': 2 } console.log('看看服务器', res.data.fontSize) selectedIndex.value = sizeMap[fontSize] ?? 0; } } catch (err) { console.error("获取服务器设置失败:", err); } } const selectFont = (index) => { selectedIndex.value = index console.log('看看选中状态',selectedIndex.value) }
onMounted(() => { // 状态栏高度
iSMT.value = uni.getSystemInfoSync().statusBarHeight; console.log('看看高度', iSMT.value) getServer() })</script>
<style> .top { margin-top: 1.5vh; height: 21vh; background-color: white; }
.top-list { width: 630rpx; height: 7vh; display: flex; align-items: center; justify-content: center; margin: 0 40rpx; padding: 0 10rpx; border-bottom: 1rpx solid #eee; }
.top-list:last-child { border-bottom: none; }
.switch-btn { width: 100rpx; transform: scale(0.6); transform-origin: center right; }
.public { width: 450rpx; margin-left: auto; font-size: 10px; color: rgb(203, 203, 203); }
.arrow { margin-left: auto; } .radio-btn { margin-left: auto; transform: scale(0.6); }</style>
|