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="theme"> <view class="left"> <image class="img-theme" src="/static/my/whiteTheme.png" mode="widthFix" /> <radio value="0" class="radio-btn" activeBackgroundColor="red" :checked="selectedIndex === 0" @click="selectFont(0)" /> </view> <view class="left"> <image class="img-theme" src="/static/my/blackTheme.png" mode="widthFix" /> <radio value="1" class="radio-btn" activeBackgroundColor="red" :checked="selectedIndex === 1" @click="selectFont(1)" /> </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 getTheme = async () => { try { const res = await getSetting() if (res.code === 200) { const theme = res.data.theme const sizeMap = { 'light': 0, 'dark': 1 } console.log('看看主题', res.data.theme) selectedIndex.value = sizeMap[theme] ?? 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) getTheme() })</script>
<style> .theme { margin-top: 1.5vh; height: 34vh; background-color: white; display: flex; justify-content: space-around; }
.img-theme { width: 316rpx; height: 362rpx; }
.left { width: 350rpx; display: flex; flex-direction: column; justify-content: center; align-items: center; }
.radio-btn { margin-top: 36rpx; transform: scale(0.8); }</style>
|