Skip to content

Commit

Permalink
chore: use ts in lifeindex and radar pages
Browse files Browse the repository at this point in the history
  • Loading branch information
LaicZhang committed Apr 22, 2022
1 parent e502707 commit 55682df
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 29 deletions.
39 changes: 11 additions & 28 deletions src/views/echarts/LifeIndex.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,35 +32,18 @@
</div>
</template>

<script>
<script setup lang="ts">
import { reactive } from 'vue'
import store from '@/store'
export default {
name: 'LifeIndex',
data() {
return {
clothesIndex: {},
rayIndex: {},
carIndex: {},
clothesIndexText: '',
rayIndexText: '',
carIndexText: '',
}
},
mounted() {
this.getLifeIndex()
},
methods: {
getLifeIndex() {
const today = store.state.weatherData.today
this.clothesIndex = today.lifeIndex.ct
this.rayIndex = today.lifeIndex.uv
this.carIndex = today.lifeIndex.xc
this.clothesIndexText = `${this.clothesIndex.liNm}:${this.clothesIndex.liAttr},${this.clothesIndex.liDese}`
this.rayIndexText = `${this.rayIndex.liNm}:${this.rayIndex.liAttr},${this.rayIndex.liDese}`
this.carIndexText = `${this.carIndex.liNm}:${this.carIndex.liAttr},${this.carIndex.liDese}`
},
},
}
const today = store.state.weatherData.today.lifeIndex
const clothesIndex = reactive(today.ct)
const rayIndex = reactive(today.uv)
const carIndex = reactive(today.xc)
const clothesIndexText = `${clothesIndex.liNm}:${clothesIndex.liAttr},${clothesIndex.liDese}`
const rayIndexText = `${rayIndex.liNm}:${rayIndex.liAttr},${rayIndex.liDese}`
const carIndexText = `${carIndex.liNm}:${carIndex.liAttr},${carIndex.liDese}`
</script>

<style>
Expand Down
3 changes: 2 additions & 1 deletion src/views/echarts/Radar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ const myRef = ref(null)
const init = () => {
const myChart = echarts.init(document.getElementById('radar') as HTMLElement)
const realTime = store.state.weatherData.realTime
const indicator = [
type IndicatorInterface = Record<string, any>
const indicator: IndicatorInterface = [
{ name: '能见度', max: 20 },
{ name: 'AQI', max: 300 },
{ name: '温度', max: 40 },
Expand Down

1 comment on commit 55682df

@vercel
Copy link

@vercel vercel bot commented on 55682df Apr 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.