65 lines
1.3 KiB
Vue
65 lines
1.3 KiB
Vue
<script setup>
|
||
import { onLaunch,onShow,onHide } from '@dcloudio/uni-app'
|
||
|
||
// 应用启动时执行
|
||
onLaunch(() => {
|
||
console.log('App 启动')
|
||
uni.onPushMessage((res) => {
|
||
console.log("收到推送消息:",res) //监听推送消息
|
||
})
|
||
|
||
// #ifdef APP-PLUS
|
||
// 只有 App 平台才获取 CID
|
||
getPushCID()
|
||
// #endif
|
||
})
|
||
onShow(() =>{
|
||
console.log('App Show')
|
||
})
|
||
|
||
onHide(() =>{
|
||
console.log('App Hide')
|
||
})
|
||
|
||
// 获取 uniPush 2.0 CID
|
||
function getPushCID() {
|
||
uni.getPushClientId({
|
||
success: (res) => {
|
||
console.log('推送初始化成功')
|
||
console.log('CID =', res.cid)
|
||
|
||
// 存起来备用
|
||
uni.setStorageSync('push_cid', res.cid)
|
||
},
|
||
fail: (err) => {
|
||
console.error('获取推送 CID 失败', err)
|
||
}
|
||
})
|
||
}
|
||
</script>
|
||
|
||
<style lang="scss">
|
||
@import "@/uni_modules/uview-plus/index.scss";
|
||
/*每个页面公共css */
|
||
</style>
|
||
|
||
<style>
|
||
/* 全局给 uni.showToast 加内边距 */
|
||
.uni-toast {
|
||
padding: 5px !important;
|
||
/* 上下20 左右40,自己改数值 */
|
||
min-height: auto !important;
|
||
box-sizing: border-box !important;
|
||
}
|
||
|
||
/* 文字也可以居中、调整行高 */
|
||
.uni-toast-content {
|
||
/* line-height: 1.6 !important; */
|
||
padding: 0 !important;
|
||
}
|
||
|
||
/* button:after{
|
||
border-radius: 50px;
|
||
} */
|
||
</style>
|