feat(升级中心): 实现备用更新方案并优化版本检查逻辑
This commit is contained in:
@@ -7,8 +7,8 @@ export const ENV = process.env.NODE_ENV || 'development';
|
||||
*/
|
||||
const BASE_URL_MAP = {
|
||||
development: {
|
||||
// MAIN: 'http://192.168.110.100:9300/pb/', // 张川川
|
||||
MAIN: 'https://global.nuttyreading.com/', // 线上
|
||||
MAIN: 'http://192.168.110.100:9300/pb/', // 张川川
|
||||
// MAIN: 'https://global.nuttyreading.com/', // 线上
|
||||
// PAYMENT: 'https://dev-pay.example.com', // 暂时用不到
|
||||
// CDN: 'https://cdn-dev.example.com', // 暂时用不到
|
||||
},
|
||||
@@ -21,7 +21,6 @@ const BASE_URL_MAP = {
|
||||
|
||||
export const APP_INFO = {
|
||||
TYPE: 'abroad', // APP 名称
|
||||
VERSION_CODE: '1.0.0', // APP 版本号,可能升级的时候会用,这里需要再确定?
|
||||
}
|
||||
|
||||
export const REQUEST_TIMEOUT = 30000;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { IRequestOptions } from '../types'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import { APP_INFO } from '@/api/config'
|
||||
import { getCurrentVersion } from '@/uni_modules/uni-upgrade-center-app/utils/call-check-version'
|
||||
|
||||
export function requestInterceptor(options: IRequestOptions): IRequestOptions {
|
||||
const headers = { ...(options.headers || {}) }
|
||||
@@ -21,9 +22,12 @@ export function requestInterceptor(options: IRequestOptions): IRequestOptions {
|
||||
headers['Content-Type'] = 'application/json;charset=UTF-8'
|
||||
}
|
||||
|
||||
getCurrentVersion().then((version_code: string) => {
|
||||
headers['version_code'] = version_code || ''
|
||||
})
|
||||
|
||||
headers['appType'] = APP_INFO.TYPE
|
||||
headers['version_code'] = APP_INFO.VERSION_CODE || '1.0.0'
|
||||
|
||||
|
||||
return {
|
||||
...options,
|
||||
header: headers,
|
||||
|
||||
14
api/modules/sys.ts
Normal file
14
api/modules/sys.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { mainClient, skeletonClient } from '@/api/clients'
|
||||
import type { IApiResponse } from '@/api/types'
|
||||
|
||||
/**
|
||||
* 请求更新包
|
||||
*/
|
||||
export async function requestUpdatePackage(type: string, version: string) {
|
||||
const res = await skeletonClient.request<IApiResponse>({
|
||||
url: 'common/apkConfig/getUpdateUrl',
|
||||
method: 'POST',
|
||||
data: { type, version }
|
||||
})
|
||||
return res
|
||||
}
|
||||
Reference in New Issue
Block a user