feat: 添加常用函数

This commit is contained in:
Your Name
2024-12-26 18:37:09 +08:00
parent f8abb65023
commit ecd30a2e82
3 changed files with 68 additions and 2 deletions
+39
View File
@@ -2,6 +2,7 @@
import { onLaunch, onShow, onHide } from '@dcloudio/uni-app' import { onLaunch, onShow, onHide } from '@dcloudio/uni-app'
onLaunch(() => { onLaunch(() => {
uni.showModal({ title: '提示', content: 'App Launch' })
console.log('App Launch') console.log('App Launch')
}) })
onShow(() => { onShow(() => {
@@ -72,4 +73,42 @@ image {
view { view {
box-sizing: border-box; box-sizing: border-box;
} }
uni-modal {
.uni-modal {
@apply max-w-345 rounded-16;
}
.uni-modal__hd {
@apply p-0;
}
.uni-modal__title {
@apply p-16 text-left text-16 font-600;
}
.uni-modal__bd {
@apply mb-16 px-16 pt-0 text-left text-14 font-medium text-#666;
}
.uni-modal__btn {
@apply px-16 py-8 flex-none rounded-full shadow-none text-14;
&::after {
content: none;
}
&.uni-modal__btn_primary {
@apply ml-8 bg-gray-200 !text-black;
}
}
.uni-modal__ft {
@apply justify-end p-16 leading-normal;
&::after {
content: none;
}
}
}
</style> </style>
+28 -1
View File
@@ -1,7 +1,7 @@
import { pages, subPackages, tabBar } from '@/pages.json' import { pages, subPackages, tabBar } from '@/pages.json'
import { isMp } from './platform' import { isMp } from './platform'
const getLastPage = () => { export const getLastPage = () => {
// getCurrentPages() 至少有1个元素,所以不再额外判断 // getCurrentPages() 至少有1个元素,所以不再额外判断
// const lastPage = getCurrentPages().at(-1) // const lastPage = getCurrentPages().at(-1)
// 上面那个在低版本安卓中打包回报错,所以改用下面这个【虽然我加了src/interceptions/prototype.ts,但依然报错】 // 上面那个在低版本安卓中打包回报错,所以改用下面这个【虽然我加了src/interceptions/prototype.ts,但依然报错】
@@ -176,3 +176,30 @@ export const getEnvBaseUploadUrl = () => {
return baseUploadUrl return baseUploadUrl
} }
export function mergeStep(wrapped: (...rest: any[]) => Promise<any>) {
let _mergeStepRequestInstance: any = null
return async function (...args) {
if (this?._mergeStepRequestInstance ?? _mergeStepRequestInstance)
return this?._mergeStepRequestInstance ?? _mergeStepRequestInstance
if (this) {
this._mergeStepRequestInstance = wrapped.apply(this, args)
} else {
_mergeStepRequestInstance = wrapped(...args)
}
if (
Object.prototype.toString.call(
this?._mergeStepRequestInstance ?? _mergeStepRequestInstance,
) === '[object Promise]'
) {
;(this?._mergeStepRequestInstance ?? _mergeStepRequestInstance).finally(() => {
if (this?._mergeStepRequestInstance) {
this._mergeStepRequestInstance = null
} else {
_mergeStepRequestInstance = null
}
})
}
return _mergeStepRequestInstance
}
}
+1 -1
View File
@@ -5,7 +5,7 @@
"module": "ESNext", "module": "ESNext",
"moduleResolution": "Node", "moduleResolution": "Node",
"resolveJsonModule": true, "resolveJsonModule": true,
"noImplicitThis": true, "noImplicitThis": false,
"allowSyntheticDefaultImports": true, "allowSyntheticDefaultImports": true,
"allowJs": true, "allowJs": true,
"sourceMap": true, "sourceMap": true,