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:
zheng020 2026-06-02 22:03:50 +08:00
parent 282eb72e46
commit b31cf01da4

View File

@ -23,40 +23,27 @@
</view> </view>
</template> </template>
<script> <script setup>
import { ref, onUnmounted } from 'vue' import { ref, onUnmounted } from 'vue'
import DashboardHeader from './components/DashboardHeader.vue' import DashboardHeader from './components/DashboardHeader.vue'
import { useDashboardData } from '@/composables/useDashboardData' import { useDashboardData } from '@/composables/useDashboardData'
export default { const pageBg = 'linear-gradient(153deg, #FF9597 0%, #80DFFF 33%, #B8B8B8 74%, #D9D9D9 100%)'
components: { DashboardHeader },
setup() {
const activeTab = ref('crystal')
const starId = ref(uni.getStorageSync('star_id') || null)
const { loading, error, data, isReady, dispose } = useDashboardData({ const activeTab = ref('crystal')
starId: starId.value, const starId = ref(uni.getStorageSync('star_id') || null)
})
function handleTabChange(tab) { const { loading, error, data, isReady, dispose } = useDashboardData({
activeTab.value = tab starId: starId.value,
} })
onUnmounted(() => { function handleTabChange(tab) {
dispose() activeTab.value = tab
})
return {
activeTab,
loading,
error,
data,
isReady,
handleTabChange,
pageBg: 'linear-gradient(153deg, #FF9597 0%, #80DFFF 33%, #B8B8B8 74%, #D9D9D9 100%)',
}
},
} }
onUnmounted(() => {
dispose()
})
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>