提交 7a5248f4 作者: 方治民

feat: 新增全局 Message 工具方法、横竖屏实例等

上级 821b7b8f
......@@ -18,6 +18,7 @@ export function configAutoImportPlugin(): Plugin {
'@/config/app': ['$app'],
'@/api/services': ['defs'],
'@/api/services/mods': ['API'],
'@/commom/message': ['Message'],
},
],
})
......
<script setup lang="ts">
import { Message } from '@/common/message'
onLaunch(() => {
console.log('App Launch')
})
......@@ -12,17 +14,11 @@
})
onError((err) => {
uni.showToast({
title: 'App Error: ' + err,
icon: 'none',
})
Message.toast('App Error: ' + err)
})
onUnhandledRejection((err) => {
uni.showToast({
title: 'App UnhandledRejection: ' + err,
icon: 'none',
})
Message.toast('App UnhandledRejection: ' + err)
})
</script>
......
// 本文件由FirstUI授权予长沙壹润信息科技发展有限公司(手机号: 156 16 26 019 5,身份证尾号:503 75T)专用,请尊重知识产权,勿私下传播,违者追究法律责任。
const fui = {
toast: function (text: string) {
text &&
if (text) {
// #ifndef APP-PLUS
uni.showToast({
title: text,
icon: 'none',
duration: 2000,
})
// #endif
// #ifdef APP-PLUS
plus.nativeUI.toast(text, {
duration: 'short',
})
// #endif
}
},
modal: function (
title: string,
......
export const Message = {
/**
* 消息轻提示
* @param text 消息内容
*/
toast: function (text: string) {
if (text) {
// #ifndef APP-PLUS
uni.showToast({
title: text,
icon: 'none',
duration: 2000,
})
// #endif
// #ifdef APP-PLUS
plus.nativeUI.toast(text, {
duration: 'short',
})
// #endif
}
},
}
......@@ -120,11 +120,11 @@
left: 0;
right: 0;
/* #ifndef APP-NVUE */
left: constant(safe-area-inset-left);
/* left: constant(safe-area-inset-left);
left: env(safe-area-inset-left);
right: constant(safe-area-inset-right);
right: env(safe-area-inset-right)
/* #endif */
right: env(safe-area-inset-right) */
/* #endif */
}
.fui-footer__link {
......@@ -212,4 +212,4 @@
}
/* #endif */
</style>
\ No newline at end of file
</style>
<script setup lang="ts">
import { Message } from '@/common/message'
import dayjs from 'dayjs'
const year = ref(dayjs().year())
......@@ -6,14 +7,27 @@
// TODO: 测试接口
API.example.hello.request().then((body) => {
console.log(body)
title.value = body
Message.toast(body)
console.log(body)
})
const change = () => {
const orientation = plus.navigator.getOrientation()
Message.toast('Orientation: ' + orientation)
if (orientation === 0) {
plus.screen.lockOrientation('landscape-primary')
} else if (orientation === 90) {
plus.screen.lockOrientation('portrait-primary')
}
}
</script>
<template>
<view class="content">
<fui-avatar src="/static/logo.png" radius="14" />
<fui-avatar src="/static/logo.png" radius="14" @click="change" />
<view class="info">
<text class="title">{{ title }}</text>
<text class="title">{{ $t('app.hello') }}</text>
......
......@@ -18,6 +18,7 @@ declare global {
const isReadonly: typeof import('vue')['isReadonly']
const isRef: typeof import('vue')['isRef']
const markRaw: typeof import('vue')['markRaw']
const Message: typeof import('@/commom/message')['Message']
const nextTick: typeof import('vue')['nextTick']
const onActivated: typeof import('vue')['onActivated']
const onAddToFavorites: typeof import('@dcloudio/uni-app')['onAddToFavorites']
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论