Merge branch 'base' into i18n

This commit is contained in:
Burt 2025-01-06 14:02:33 +08:00
commit a4a49e7b1e
9 changed files with 70 additions and 41 deletions

View File

@ -36,6 +36,7 @@
"manifest.json": "jsonc" // manifest.json "manifest.json": "jsonc" // manifest.json
}, },
"cSpell.words": [ "cSpell.words": [
"Aplipay",
"climblee", "climblee",
"commitlint", "commitlint",
"dcloudio", "dcloudio",
@ -44,9 +45,12 @@
"refresherrefresh", "refresherrefresh",
"scrolltolower", "scrolltolower",
"tabbar", "tabbar",
"Toutiao",
"unibest", "unibest",
"uvui", "uvui",
"WechatMiniprogram" "Wechat",
"WechatMiniprogram",
"Weixin"
], ],
"typescript.tsdk": "node_modules\\typescript\\lib", "typescript.tsdk": "node_modules\\typescript\\lib",
// //

10
env/.env vendored
View File

@ -10,6 +10,16 @@ VITE_APP_PUBLIC_BASE=/unibest/
VITE_SERVER_BASEURL = 'https://ukw0y1.laf.run' VITE_SERVER_BASEURL = 'https://ukw0y1.laf.run'
VITE_UPLOAD_BASEURL = 'https://ukw0y1.laf.run/upload' VITE_UPLOAD_BASEURL = 'https://ukw0y1.laf.run/upload'
# 有些同学可能需要在微信小程序里面根据 develop、trial、release 分别设置上传地址,参考代码如下。
# 下面的变量如果没有设置,会默认使用 VITE_SERVER_BASEURL or VITE_UPLOAD_BASEURL
VITE_SERVER_BASEURL__WEIXIN_DEVELOP = 'https://ukw0y1.laf.run'
VITE_SERVER_BASEURL__WEIXIN_TRIAL = 'https://ukw0y1.laf.run'
VITE_SERVER_BASEURL__WEIXIN_RELEASE = 'https://ukw0y1.laf.run'
VITE_UPLOAD_BASEURL__WEIXIN_DEVELOP = 'https://ukw0y1.laf.run/upload'
VITE_UPLOAD_BASEURL__WEIXIN_TRIAL = 'https://ukw0y1.laf.run/upload'
VITE_UPLOAD_BASEURL__WEIXIN_RELEASE = 'https://ukw0y1.laf.run/upload'
# h5是否需要配置代理 # h5是否需要配置代理
VITE_APP_PROXY=false VITE_APP_PROXY=false
VITE_APP_PROXY_PREFIX = '/api' VITE_APP_PROXY_PREFIX = '/api'

View File

@ -1,7 +1,7 @@
{ {
"name": "unibest", "name": "unibest",
"type": "commonjs", "type": "commonjs",
"version": "2.5.4", "version": "2.5.5",
"description": "unibest - 最好的 uniapp 开发模板", "description": "unibest - 最好的 uniapp 开发模板",
"author": { "author": {
"name": "feige996", "name": "feige996",

View File

@ -32,6 +32,7 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { TestEnum } from '@/typings'
import PLATFORM from '@/utils/platform' import PLATFORM from '@/utils/platform'
defineOptions({ defineOptions({
@ -47,6 +48,7 @@ const description = ref(
// uni API // uni API
onLoad(() => { onLoad(() => {
console.log(author) console.log(author)
console.log(TestEnum.A)
}) })
</script> </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> = { export enum TestEnum {
code: number A = '1',
msg: string B = '2',
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',
} }

View File

@ -1,5 +1,5 @@
import { pages, subPackages, tabBar } from '@/pages.json' import { pages, subPackages, tabBar } from '@/pages.json'
import { isMp } from './platform' import { isMpWeixin } from './platform'
const getLastPage = () => { const getLastPage = () => {
// getCurrentPages() 至少有1个元素所以不再额外判断 // getCurrentPages() 至少有1个元素所以不再额外判断
@ -126,21 +126,21 @@ export const getEnvBaseUrl = () => {
// 请求基准地址 // 请求基准地址
let baseUrl = import.meta.env.VITE_SERVER_BASEURL let baseUrl = import.meta.env.VITE_SERVER_BASEURL
// 小程序端环境区分 // 微信小程序端环境区分
if (isMp) { if (isMpWeixin) {
const { const {
miniProgram: { envVersion }, miniProgram: { envVersion },
} = uni.getAccountInfoSync() } = uni.getAccountInfoSync()
switch (envVersion) { switch (envVersion) {
case 'develop': case 'develop':
baseUrl = 'https://ukw0y1.laf.run' baseUrl = import.meta.env.VITE_SERVER_BASEURL__WEIXIN_DEVELOP || baseUrl
break break
case 'trial': case 'trial':
baseUrl = 'https://ukw0y1.laf.run' baseUrl = import.meta.env.VITE_SERVER_BASEURL__WEIXIN_TRIAL || baseUrl
break break
case 'release': case 'release':
baseUrl = 'https://ukw0y1.laf.run' baseUrl = import.meta.env.VITE_SERVER_BASEURL__WEIXIN_RELEASE || baseUrl
break break
} }
} }
@ -155,21 +155,21 @@ export const getEnvBaseUploadUrl = () => {
// 请求基准地址 // 请求基准地址
let baseUploadUrl = import.meta.env.VITE_UPLOAD_BASEURL let baseUploadUrl = import.meta.env.VITE_UPLOAD_BASEURL
// 小程序端环境区分 // 微信小程序端环境区分
if (isMp) { if (isMpWeixin) {
const { const {
miniProgram: { envVersion }, miniProgram: { envVersion },
} = uni.getAccountInfoSync() } = uni.getAccountInfoSync()
switch (envVersion) { switch (envVersion) {
case 'develop': case 'develop':
baseUploadUrl = 'https://ukw0y1.laf.run/upload' baseUploadUrl = import.meta.env.VITE_UPLOAD_BASEURL__WEIXIN_DEVELOP || baseUploadUrl
break break
case 'trial': case 'trial':
baseUploadUrl = 'https://ukw0y1.laf.run/upload' baseUploadUrl = import.meta.env.VITE_UPLOAD_BASEURL__WEIXIN_TRIAL || baseUploadUrl
break break
case 'release': case 'release':
baseUploadUrl = 'https://ukw0y1.laf.run/upload' baseUploadUrl = import.meta.env.VITE_UPLOAD_BASEURL__WEIXIN_RELEASE || baseUploadUrl
break break
} }
} }

View File

@ -8,10 +8,17 @@ export const platform = __UNI_PLATFORM__
export const isH5 = __UNI_PLATFORM__ === 'h5' export const isH5 = __UNI_PLATFORM__ === 'h5'
export const isApp = __UNI_PLATFORM__ === 'app' export const isApp = __UNI_PLATFORM__ === 'app'
export const isMp = __UNI_PLATFORM__.startsWith('mp-') export const isMp = __UNI_PLATFORM__.startsWith('mp-')
export const isMpWeixin = __UNI_PLATFORM__.startsWith('mp-weixin')
export const isMpAplipay = __UNI_PLATFORM__.startsWith('mp-alipay')
export const isMpToutiao = __UNI_PLATFORM__.startsWith('mp-toutiao')
const PLATFORM = { const PLATFORM = {
platform, platform,
isH5, isH5,
isApp, isApp,
isMp, isMp,
isMpWeixin,
isMpAplipay,
isMpToutiao,
} }
export default PLATFORM export default PLATFORM

View File

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