From e5415a87843c693a8fd8af0145670a3644ac642e Mon Sep 17 00:00:00 2001 From: chenghuan Date: Fri, 26 Dec 2025 17:11:58 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E5=8D=87=E7=BA=A7=E4=B8=AD=E5=BF=83):=20?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E5=A4=87=E7=94=A8=E6=9B=B4=E6=96=B0=E6=96=B9?= =?UTF-8?q?=E6=A1=88=E5=B9=B6=E4=BC=98=E5=8C=96=E7=89=88=E6=9C=AC=E6=A3=80?= =?UTF-8?q?=E6=9F=A5=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/config.ts | 5 +- api/interceptors/request.ts | 8 +- api/modules/sys.ts | 14 ++ locale/en.json | 2 +- locale/zh-Hans.json | 2 +- pages/user/settings/index.vue | 41 ++++- .../utils/call-check-version.js | 155 ++++++++++++++---- .../utils/check-update.js | 16 +- .../uni-upgrade-center-app/utils/tools.js | 32 ++++ utils/index.ts | 23 +++ 10 files changed, 245 insertions(+), 53 deletions(-) create mode 100644 api/modules/sys.ts create mode 100644 uni_modules/uni-upgrade-center-app/utils/tools.js diff --git a/api/config.ts b/api/config.ts index f437afb..5360003 100644 --- a/api/config.ts +++ b/api/config.ts @@ -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; diff --git a/api/interceptors/request.ts b/api/interceptors/request.ts index 593b7fb..48972f9 100644 --- a/api/interceptors/request.ts +++ b/api/interceptors/request.ts @@ -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, diff --git a/api/modules/sys.ts b/api/modules/sys.ts new file mode 100644 index 0000000..e273c2a --- /dev/null +++ b/api/modules/sys.ts @@ -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({ + url: 'common/apkConfig/getUpdateUrl', + method: 'POST', + data: { type, version } + }) + return res +} diff --git a/locale/en.json b/locale/en.json index 0379430..35d29da 100644 --- a/locale/en.json +++ b/locale/en.json @@ -20,7 +20,7 @@ "coin": "Coin", "days": "Days", "and": "and", - "call": "Call" + "queryFailed": "Query failed" }, "tabar.course": "COURSE", "tabar.book": "EBOOK", diff --git a/locale/zh-Hans.json b/locale/zh-Hans.json index 42c30e8..06405f2 100644 --- a/locale/zh-Hans.json +++ b/locale/zh-Hans.json @@ -20,7 +20,7 @@ "coin": "天医币", "days": "天", "and": "和", - "call": "拨打电话" + "queryFailed": "查询失败" }, "tabar.course": "课程", "tabar.book": "图书", diff --git a/pages/user/settings/index.vue b/pages/user/settings/index.vue index 985ed63..43cb301 100644 --- a/pages/user/settings/index.vue +++ b/pages/user/settings/index.vue @@ -66,7 +66,7 @@