refactor(dashboard): dashboard.vue 改用 <script setup> 语法
代码评审发现 Options API 与项目 30+ 个页面(square.vue、 discover.vue、exhibition.vue 等)惯例不一致。改写为 <script setup>,并把 pageBg 提到模块顶层(不再通过 setup return 传递)。Header 组件无 script 逻辑,无需改动。
This commit is contained in:
parent
282eb72e46
commit
b31cf01da4
@ -23,40 +23,27 @@
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
<script setup>
|
||||
import { ref, onUnmounted } from 'vue'
|
||||
import DashboardHeader from './components/DashboardHeader.vue'
|
||||
import { useDashboardData } from '@/composables/useDashboardData'
|
||||
|
||||
export default {
|
||||
components: { DashboardHeader },
|
||||
setup() {
|
||||
const activeTab = ref('crystal')
|
||||
const starId = ref(uni.getStorageSync('star_id') || null)
|
||||
const pageBg = 'linear-gradient(153deg, #FF9597 0%, #80DFFF 33%, #B8B8B8 74%, #D9D9D9 100%)'
|
||||
|
||||
const { loading, error, data, isReady, dispose } = useDashboardData({
|
||||
starId: starId.value,
|
||||
})
|
||||
const activeTab = ref('crystal')
|
||||
const starId = ref(uni.getStorageSync('star_id') || null)
|
||||
|
||||
function handleTabChange(tab) {
|
||||
activeTab.value = tab
|
||||
}
|
||||
const { loading, error, data, isReady, dispose } = useDashboardData({
|
||||
starId: starId.value,
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
dispose()
|
||||
})
|
||||
|
||||
return {
|
||||
activeTab,
|
||||
loading,
|
||||
error,
|
||||
data,
|
||||
isReady,
|
||||
handleTabChange,
|
||||
pageBg: 'linear-gradient(153deg, #FF9597 0%, #80DFFF 33%, #B8B8B8 74%, #D9D9D9 100%)',
|
||||
}
|
||||
},
|
||||
function handleTabChange(tab) {
|
||||
activeTab.value = tab
|
||||
}
|
||||
|
||||
onUnmounted(() => {
|
||||
dispose()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user