Merge pull request #42 from Rem-Blove/main

fix: 枚举失效问题 & 分离全局声明和模块化内容
This commit is contained in:
菲鸽 2025-01-06 13:32:39 +08:00 committed by GitHub
commit 424fd937d9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 36 additions and 28 deletions

View File

@ -31,6 +31,7 @@
</template>
<script lang="ts" setup>
import { TestEnum } from '@/typings'
import PLATFORM from '@/utils/platform'
defineOptions({
@ -46,6 +47,7 @@ const description = ref(
// uni API
onLoad(() => {
console.log(author)
console.log(TestEnum.A)
})
</script>

28
src/typings.d.ts vendored Normal file
View File

@ -0,0 +1,28 @@
// 全局要用的类型放到这里
declare global {
type IResData<T> = {
code: number
msg: string
data: T
}
// uni.uploadFile文件上传参数
type IUniUploadFileOptions = {
file?: File
files?: UniApp.UploadFileOptionFiles[]
filePath?: string
name?: string
formData?: any
}
type IUserInfo = {
nickname?: string
avatar?: string
/** 微信的 openid非微信没有这个字段 */
openid?: string
token?: string
}
}
export {} // 防止模块污染

View File

@ -1,29 +1,6 @@
// 全局要用的类型放到这里
// 枚举定义
type IResData<T> = {
code: number
msg: string
data: T
}
// uni.uploadFile文件上传参数
type IUniUploadFileOptions = {
file?: File
files?: UniApp.UploadFileOptionFiles[]
filePath?: string
name?: string
formData?: any
}
type IUserInfo = {
nickname?: string
avatar?: string
/** 微信的 openid非微信没有这个字段 */
openid?: string
token?: string
}
enum TestEnum {
A = 'a',
B = 'b',
export enum TestEnum {
A = '1',
B = '2',
}

View File

@ -20,7 +20,8 @@
"@uni-helper/uni-types",
"@types/wechat-miniprogram",
"wot-design-uni/global.d.ts",
"z-paging/types"
"z-paging/types",
"./src/typings.d.ts"
]
},
"vueCompilerOptions": {