Skip to content

Commit

Permalink
Merge pull request #42 from Rem-Blove/main
Browse files Browse the repository at this point in the history
fix: 枚举失效问题 & 分离全局声明和模块化内容
  • Loading branch information
feige996 authored and Burt committed Jan 6, 2025
1 parent f96a983 commit 4667240
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 28 deletions.
2 changes: 2 additions & 0 deletions src/pages/index/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
</template>

<script lang="ts" setup>
import { TestEnum } from '@/typings'
import PLATFORM from '@/utils/platform'

defineOptions({
Expand All @@ -46,6 +47,7 @@ const description = ref(
// 测试 uni API 自动引入
onLoad(() => {
console.log(author)
console.log(TestEnum.A)
})
</script>

Expand Down
28 changes: 28 additions & 0 deletions src/typings.d.ts
Original file line number Diff line number Diff line change
@@ -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 {} // 防止模块污染
31 changes: 4 additions & 27 deletions src/typings.ts
Original file line number Diff line number Diff line change
@@ -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',
}
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down

0 comments on commit 4667240

Please sign in to comment.