Merge pull request #2 from CrazyStudent13/wx-adapter

Wx adapter
This commit is contained in:
菲鸽 2024-09-06 10:34:26 +08:00 committed by GitHub
commit 8100e0eeb5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 123 additions and 1 deletions

32
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@ -0,0 +1,32 @@
---
name: Bug report报告问题
about: Create a report to help us improve
---
<!--
注意:为更好的解决你的问题,请参考模板提供完整信息,准确描述问题,信息不全的 issue 将被关闭。
Note: In order to better solve your problem, please refer to the template to provide complete information, accurately describe the problem, and the incomplete information issue will be closed.
-->
# Bug report问题描述
please write your issue description here
## Steps to reproduce问题复现步骤
<!--
1. [xxx]
2. [xxx]
3. [xxxx]
-->
## Screenshot or Gif截图或动态图
## minimal reproduction最小可还原代码
## System Info
`npx envinfo --system --npmPackages vue --binaries --browsers`
执行上面命令,将结果贴下面

View File

@ -0,0 +1,6 @@
---
name: Feature Request新功能建议
about: Suggest an idea for this project
---
# Feature request新功能建议

52
.github/workflows/deploy-h5.yml vendored Normal file
View File

@ -0,0 +1,52 @@
name: Deploy Pages
on:
# Runs on pushes targeting the default branch
push:
branches: ['main']
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
jobs:
# Build job
build:
runs-on: ubuntu-latest
steps:
# 设置服务器时区为东八区
- name: Set time zone
run: sudo timedatectl set-timezone 'Asia/Shanghai'
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 8
- uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'pnpm'
- name: Install dependencies
run: pnpm i --no-frozen-lockfile
- name: Build
run: pnpm build:h5
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./dist/build/h5
# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4

View File

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

View File

@ -1,4 +1,6 @@
import { pages, subPackages, tabBar } from '@/pages.json' import { pages, subPackages, tabBar } from '@/pages.json'
import { isMp } from './platform'
const getLastPage = () => { const getLastPage = () => {
// getCurrentPages() 至少有1个元素所以不再额外判断 // getCurrentPages() 至少有1个元素所以不再额外判断
// const lastPage = getCurrentPages().at(-1) // const lastPage = getCurrentPages().at(-1)
@ -116,3 +118,32 @@ export const getNeedLoginPages = (): string[] => getAllPages('needLogin').map((p
* path * path
*/ */
export const needLoginPages: string[] = getAllPages('needLogin').map((page) => page.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://dev.test.net'
break
case 'trial':
baseUrl = 'https://trial.test.net'
break
case 'release':
baseUrl = 'https://prod.test.net'
break
}
}
return baseUrl
}