Merge branch 'base' into i18n

This commit is contained in:
Burt 2024-09-11 20:50:02 +08:00
commit deda75ffdd
7 changed files with 318 additions and 188 deletions

View File

@ -41,6 +41,8 @@
- node>=18
- pnpm>=7.30
- Vue Official<=2.1.6
- TypeScript<=5.5.4
## &#x1F4C2; 快速开始

View File

@ -94,7 +94,7 @@
"qs": "6.5.3",
"vue": "3.4.21",
"vue-i18n": "^9.1.9",
"wot-design-uni": "^1.3.9",
"wot-design-uni": "^1.3.10",
"z-paging": "^2.7.10"
},
"devDependencies": {
@ -113,6 +113,7 @@
"@types/wechat-miniprogram": "^3.4.7",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"@uni-helper/uni-types": "1.0.0-alpha.3",
"@uni-helper/vite-plugin-uni-layouts": "^0.1.10",
"@uni-helper/vite-plugin-uni-manifest": "^0.2.6",
"@uni-helper/vite-plugin-uni-pages": "0.2.20",
@ -145,7 +146,7 @@
"stylelint-config-recommended-vue": "^1.5.0",
"stylelint-prettier": "^5.0.0",
"terser": "^5.31.1",
"typescript": "^4.9.5",
"typescript": "^5.5.4",
"unocss": "^0.58.9",
"unocss-applet": "^0.7.8",
"unplugin-auto-import": "^0.17.6",

423
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,7 @@
// TODO: 别忘加更改环境变量的 VITE_UPLOAD_BASEURL 地址。
const VITE_UPLOAD_BASEURL = import.meta.env.VITE_UPLOAD_BASEURL
import { getEvnBaseUploadUrl } from '@/utils'
const VITE_UPLOAD_BASEURL = `${getEvnBaseUploadUrl()}`
/**
* useUpload

View File

@ -2,6 +2,7 @@
import qs from 'qs'
import { useUserStore } from '@/store'
import { platform } from '@/utils/platform'
import { getEvnBaseUrl } from '@/utils'
export type CustomRequestOptions = UniApp.RequestOptions & {
query?: Record<string, any>
@ -10,7 +11,7 @@ export type CustomRequestOptions = UniApp.RequestOptions & {
} & IUniUploadFileOptions // 添加uni.uploadFile参数类型
// 请求基准地址
const baseUrl = import.meta.env.VITE_SERVER_BASEURL
const baseUrl = getEvnBaseUrl()
// 拦截器配置
const httpInterceptor = {

View File

@ -1,4 +1,6 @@
import { pages, subPackages, tabBar } from '@/pages.json'
import { isMp } from './platform'
const getLastPage = () => {
// getCurrentPages() 至少有1个元素所以不再额外判断
// const lastPage = getCurrentPages().at(-1)
@ -116,3 +118,61 @@ export const getNeedLoginPages = (): string[] => getAllPages('needLogin').map((p
* path
*/
export const needLoginPages: string[] = getAllPages('needLogin').map((page) => page.path)
/**
* BaseUrl
*/
export const getEvnBaseUrl = () => {
// 请求基准地址
let baseUrl = import.meta.env.VITE_SERVER_BASEURL
// 小程序端环境区分
if (isMp) {
const {
miniProgram: { envVersion },
} = uni.getAccountInfoSync()
switch (envVersion) {
case 'develop':
baseUrl = 'https://ukw0y1.laf.run'
break
case 'trial':
baseUrl = 'https://ukw0y1.laf.run'
break
case 'release':
baseUrl = 'https://ukw0y1.laf.run'
break
}
}
return baseUrl
}
/**
* UPLOAD_BASEURL
*/
export const getEvnBaseUploadUrl = () => {
// 请求基准地址
let baseUploadUrl = import.meta.env.VITE_UPLOAD_BASEURL
// 小程序端环境区分
if (isMp) {
const {
miniProgram: { envVersion },
} = uni.getAccountInfoSync()
switch (envVersion) {
case 'develop':
baseUploadUrl = 'https://ukw0y1.laf.run/upload'
break
case 'trial':
baseUploadUrl = 'https://ukw0y1.laf.run/upload'
break
case 'release':
baseUploadUrl = 'https://ukw0y1.laf.run/upload'
break
}
}
return baseUploadUrl
}

View File

@ -15,11 +15,16 @@
},
"outDir": "dist",
"lib": ["esnext", "dom"],
"types": ["@dcloudio/types", "@types/wechat-miniprogram", "wot-design-uni/global.d.ts"]
"types": [
"@dcloudio/types",
"@uni-helper/uni-types",
"@types/wechat-miniprogram",
"wot-design-uni/global.d.ts"
]
},
"vueCompilerOptions": {
"target": 3,
"nativeTags": ["block", "template", "component", "slot"]
"plugins": ["@uni-helper/uni-types/volar-plugin"]
},
"exclude": ["node_modules"],
"include": [