AssetManager.UniApp/App.vue

86 lines
1.7 KiB
Vue

<script>
export default {
onLaunch: function() {
console.log('App Launch')
},
onShow: function() {
console.log('App Show')
},
onHide: function() {
console.log('App Hide')
}
}
</script>
<template>
<view id="app">
<!-- 全局uView配置 -->
<u-config :config="uConfig">
<router-view />
<!-- 全局toast组件 -->
<u-toast ref="uToast" />
<!-- 全局modal组件 -->
<u-modal ref="uModal" />
</u-config>
</view>
</template>
<script setup>
// uView全局配置
const uConfig = {
// 主色调匹配项目品牌色
primaryColor: '#064e3b',
successColor: '#10B981',
warningColor: '#f59e0b',
errorColor: '#ef4444'
}
// 挂载全局方法
uni.$u.toast = (title, options = {}) => {
uni.$refs.uToast.show({
title,
...options
})
}
uni.$u.toast.success = (title) => {
uni.$refs.uToast.show({
title,
type: 'success'
})
}
uni.$u.toast.error = (title) => {
uni.$refs.uToast.show({
title,
type: 'error'
})
}
uni.$u.toast.loading = (title) => {
uni.$refs.uToast.show({
title,
type: 'loading'
})
}
uni.$u.showModal = (options) => {
uni.$refs.uModal.show(options)
}
</script>
<style>
/* 每个页面公共css */
page {
background-color: #F3F4F6;
font-family: 'Inter', 'Noto Sans SC', sans-serif;
--brand-color: #064e3b;
--brand-light: #10B981;
}
/* 通用工具类 */
.bg-white { background-color: #ffffff; }
.rounded-2xl { border-radius: 32rpx; }
.shadow-sm { box-shadow: 0 2rpx 6rpx rgba(0,0,0,0.05); }
.flex-row { display: flex; flex-direction: row; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
</style>