diff --git a/examples/mini-program-example/src/pages/api/media/video/index.tsx b/examples/mini-program-example/src/pages/api/media/video/index.tsx index 37fe3ef26fb2..918e1d5efab8 100644 --- a/examples/mini-program-example/src/pages/api/media/video/index.tsx +++ b/examples/mini-program-example/src/pages/api/media/video/index.tsx @@ -220,6 +220,36 @@ export default class Index extends React.Component { }) }, }, + { + id: 'chooseMedium', + inputData: { + count: 9, + mediaType: ['image'], + sourceType: ['album', 'camera'], + maxDuration: 30, + sizeType: ['original', 'compressed'], + camera: 'back', + mediaId: '', + takingSupported: false, + editSupported: false, + searchSupported: false, + }, + func: (apiIndex, data) => { + TestConsole.consoleTest('chooseMedium') + // @ts-ignore + Taro.chooseMedium({ + ...data, + success: (res) => { + TestConsole.consoleSuccess.call(this, res, apiIndex) + }, + fail: (res) => { + TestConsole.consoleFail.call(this, res, apiIndex) + }, + }).then((res) => { + TestConsole.consoleResult.call(this, res, apiIndex) + }) + }, + }, { id: 'createVideoContext', func: (apiIndex) => { diff --git a/packages/taro-platform-harmony-hybrid/build/config/harmony-definition.json b/packages/taro-platform-harmony-hybrid/build/config/harmony-definition.json index 6bc71654ff87..655a152f4f60 100644 --- a/packages/taro-platform-harmony-hybrid/build/config/harmony-definition.json +++ b/packages/taro-platform-harmony-hybrid/build/config/harmony-definition.json @@ -391,7 +391,7 @@ "WriteResult": false, "addCard": false, "addFileToFavorites": false, - "addInterceptor": false, + "addInterceptor": true, "addPhoneCalendar": { "object": { "title": true, @@ -585,6 +585,33 @@ "type": true } }, + "chooseMedium": { + "object": { + "count": true, + "mediaType": { + "video": true, + "image": true, + "mix": true + }, + "sourceType": { + "album": true, + "camera": true + }, + "maxDuration": true, + "sizeType": true, + "camera": { + "back": true, + "front": true + }, + "takingSupported": true, + "editSupported": true, + "searchSupported": true + }, + "success": { + "tempFiles": true, + "type": true + } + }, "chooseMessageFile": false, "choosePoi": false, "chooseVideo": { @@ -608,7 +635,7 @@ "width": true } }, - "cleanInterceptors": false, + "cleanInterceptors": true, "clearStorage": true, "clearStorageSync": true, "closeBLEConnection": { diff --git a/packages/taro-platform-harmony-hybrid/src/api/apis/NativeApi.ts b/packages/taro-platform-harmony-hybrid/src/api/apis/NativeApi.ts index ae40b8be8ca6..68ffd6148069 100644 --- a/packages/taro-platform-harmony-hybrid/src/api/apis/NativeApi.ts +++ b/packages/taro-platform-harmony-hybrid/src/api/apis/NativeApi.ts @@ -159,6 +159,12 @@ class NativeApi { return options } + // @ts-ignore + @(syncAndRelease) + chooseMediumAssets (options: any): any { + return options + } + // @ts-ignore @(syncAndRelease) getVideoInfo (options: any): any { diff --git a/packages/taro-platform-harmony-hybrid/src/api/apis/media/video/chooseMedium.ts b/packages/taro-platform-harmony-hybrid/src/api/apis/media/video/chooseMedium.ts new file mode 100644 index 000000000000..600e589948eb --- /dev/null +++ b/packages/taro-platform-harmony-hybrid/src/api/apis/media/video/chooseMedium.ts @@ -0,0 +1,222 @@ +import { showActionSheet } from '@tarojs/taro-h5' + +import native from '../../NativeApi' +import { shouldBeObject } from '../../utils' +import { MethodHandler } from '../../utils/handler' + +namespace chooseMedium { + export interface Option { + /** 最多可以选择的文件个数 + * @default 9 + * @supported harmny-hybrid + */ + count?: number + /** 文件类型 + * @default ['image', 'video'] + * @supported harmny-hybrid + */ + mediaType?: Array + /** 图片和视频选择的来源 + * @default ['album', 'camera'] + * @supported harmny-hybrid + */ + sourceType?: Array + /** 拍摄视频最长拍摄时间,单位秒。时间范围为 3s 至 60s 之间 + * @default 10 + * @supported harmny-hybrid + */ + maxDuration?: number + /** 仅在 sourceType 为 camera 时生效,是否压缩文件 + * @default ['original', 'compressed'] + * @supported harmny-hybrid + */ + sizeType?: Array<'original' | 'compressed'> + /** 仅在 sourceType 为 camera 时生效,使用前置或后置摄像头 + * @default "back" + * @supported harmny-hybrid + */ + camera?: string + /** 仅在 sourceType 为 album 时生效,相册中是否允许拍照 + * @default "false" + * @supported harmny-hybrid + */ + takingSupported?: boolean + /** 仅在 sourceType 为 album 时生效,相册中是否允许编辑照片 + * @default "false" + * @supported harmny-hybrid + */ + editSupported?: boolean + /** 仅在 sourceType 为 album 时生效,相册中是否允许搜索 + * @default "false" + * @supported harmny-hybrid + */ + searchSupported?: boolean + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: (res: TaroGeneral.CallbackResult) => void + /** 接口调用失败的回调函数 */ + fail?: (res: TaroGeneral.CallbackResult) => void + /** 接口调用成功的回调函数 */ + success?: (result: SuccessCallbackResult) => void + /** 用来上传的input元素ID + * @supported harmny-hybrid + */ + mediaId?: string + } + export interface SuccessCallbackResult extends TaroGeneral.CallbackResult { + /** 本地临时文件列表 */ + tempFiles: ChooseMedium[] + /** 文件类型,有效值有 image 、video、mix */ + type: string + } + + /** 本地临时文件列表 */ + export interface ChooseMedium { + /** 本地临时文件路径 (本地路径) */ + tempFilePath: string + /** 本地临时文件大小,单位 B */ + size: number + /** 视频的时间长度 */ + duration: number + /** 视频的高度 */ + height: number + /** 视频的宽度 */ + width: number + /** 视频缩略图临时文件路径 */ + thumbTempFilePath: string + /** 选择的文件的类型 */ + fileType: string + /** 相册中是否支持拍照 */ + takingSupported?: boolean + /** 相册中是否支持编辑照片 */ + editSupported?: boolean + /** 相册中是否支持搜索 */ + searchSupported?: boolean + } + export interface mediaType { + /** 只能拍摄视频或从相册选择视频 */ + video + /** 只能拍摄图片或从相册选择图片 */ + image + /** 可同时选择图片和视频 */ + mix + } + export interface sourceType { + /** 从相册选择 */ + album + /** 使用相机拍摄 */ + camera + } + export interface camera { + /** 使用后置摄像头 */ + back + /** 使用前置摄像头 */ + front + } +} + + +interface harmony { + /** 拍摄或从手机相册中选择图片或视频。 + * @supported harmony_hybrid + * @example + * ```tsx + * Taro.chooseMedium({ + * count: 9, + * mediaType: ['image','video'], + * sourceType: ['album', 'camera'], + * maxDuration: 30, + * camera: 'back', + * takingSupported: false, + * editSupported: false, + * searchSupported: false, + * success: (res) => { + * console.log(res.tempFiles) + * console.log(res.type) + * } + * }) + * ``` + */ + chooseMedium (option: chooseMedium.Option): Promise +} +/** + * 拍摄或从手机相册中选择图片或视频 + * + * @canUse chooseMedium + * @__object [count, mediaType[video, image, mix], sourceType[album, camera], maxDuration, sizeType, camera[back, front],takingSupported,editSupported,searchSupported] + * @__success [tempFiles, type] + */ +export const chooseMedium: harmony['chooseMedium'] = async (options) => { + const name = 'chooseMedium' + + // options must be an Object + const isValid = shouldBeObject(options).flag || typeof options === 'undefined' + if (!isValid) { + const res = { errMsg: `${name}:fail invalid params` } + console.error(res.errMsg) + return Promise.reject(res) + } + + const { + count = 9, + mediaType = ['video', 'image'], + sourceType = ['album', 'camera'], + maxDuration = 10, + sizeType = ['original', 'compressed'], + camera = 'back', + takingSupported = false, + editSupported = false, + searchSupported = false, + success, + fail, + } = options as Exclude + + const handle = new MethodHandler<{ + tempFiles?: chooseMedium.ChooseMedium[] + type?: string + errMsg?: string + }>({ name, success, fail }) + + let sourceSelected + if (sourceType.length === 1) { + sourceSelected = sourceType[0] + } else if (typeof sourceType !== 'object' || (sourceType.includes('album') && sourceType.includes('camera'))) { + const selected = await showActionSheet({ itemList: ['拍摄', '从相册选择'] }).then( + (res) => { + sourceSelected = res.tapIndex === 0 ? 'camera' : 'album' + return true + }, + () => { + return false + } + ) + if (!selected) { + return handle.fail({ errMsg: 'fail cancel' }) + } + } + + return new Promise((resolve, reject) => { + native.chooseMediumAssets({ + count: count, + mediaType: mediaType, + sourceType: sourceSelected, + maxDuration: maxDuration, + sizeType: sizeType, + camera: camera, + takingSupported: takingSupported, + editSupported: editSupported, + searchSupported: searchSupported, + apiName: name, + success: (res: any) => { + const result: chooseMedium.SuccessCallbackResult = { + tempFiles: res.tempFiles, + type: res.type, + errMsg: res.errMsg, + } + handle.success(result, { resolve, reject }) + }, + fail: (err: any) => { + handle.fail(err, { resolve, reject }) + }, + }) + }) +} diff --git a/packages/taro-platform-harmony-hybrid/src/api/apis/media/video/index.ts b/packages/taro-platform-harmony-hybrid/src/api/apis/media/video/index.ts index 947e18e8269c..bb4733859953 100644 --- a/packages/taro-platform-harmony-hybrid/src/api/apis/media/video/index.ts +++ b/packages/taro-platform-harmony-hybrid/src/api/apis/media/video/index.ts @@ -16,6 +16,7 @@ export { createVideoContext } from '@tarojs/taro-h5' * 拍摄视频或从手机相册中选视频。 */ export * from './chooseMedia' +export * from './chooseMedium' /** * VideoContext 实例 diff --git a/packages/taro-platform-harmony-hybrid/src/api/apis/network/request/index.ts b/packages/taro-platform-harmony-hybrid/src/api/apis/network/request/index.ts index 3507247cfb54..3378a084a431 100644 --- a/packages/taro-platform-harmony-hybrid/src/api/apis/network/request/index.ts +++ b/packages/taro-platform-harmony-hybrid/src/api/apis/network/request/index.ts @@ -1,11 +1,13 @@ -import { request as h5Request } from '@tarojs/taro-h5' - -import { request as nativeReuqest } from './nativeRequest' +import { addInterceptor as h5AddInterceptor, cleanInterceptors as h5CleanInterceptors, request as h5Request } from '@tarojs/taro-h5' +import { addInterceptor as nativeAddInterceptor, cleanInterceptors as nativeCleanInterceptors, request as nativeReuqest } from './nativeRequest' /** - * 封装请求方法 - * @param options 请求选项 + * 发起 HTTPS 网络请求 + * + * @canUse request + * @__object [url, data, header, timeout, method[OPTIONS, GET, HEAD, POST, PUT, PATCH, DELETE, TRACE, CONNECT], dataType[json, text, base64, arraybuffer], responseType[text, arraybuffer], enableCache] + * @__success [data, header, statusCode, cookies] * @param useNativeRequest 默认使用true */ export function request (options: any, useNativeRequest: boolean = true) { @@ -13,3 +15,29 @@ export function request (options: any, useNativeRequest: boolean = true) { } +/** + * 网络请求任务对象 + * + * @canUse RequestTask + * @__class [abort, onHeadersReceived, offHeadersReceived] + */ + +/** + * 使用拦截器 + * + * @canUse addInterceptor + */ +export function addInterceptor (interceptor, useNativeRequest: boolean = true) { + return useNativeRequest ? nativeAddInterceptor(interceptor) : h5AddInterceptor(interceptor) +} + +/** + * 清除所有拦截器 + * + * @canUse cleanInterceptors + */ +export function cleanInterceptors (interceptor, useNativeRequest: boolean = true) { + return useNativeRequest ? nativeCleanInterceptors(interceptor) : h5CleanInterceptors(interceptor) +} + + diff --git a/packages/taro-platform-harmony-hybrid/src/api/apis/network/request/nativeRequest.ts b/packages/taro-platform-harmony-hybrid/src/api/apis/network/request/nativeRequest.ts index ec627dae335c..8a9a0bd7f896 100644 --- a/packages/taro-platform-harmony-hybrid/src/api/apis/network/request/nativeRequest.ts +++ b/packages/taro-platform-harmony-hybrid/src/api/apis/network/request/nativeRequest.ts @@ -63,36 +63,15 @@ function taroInterceptor (chain) { const { Link } = Taro const link = new Link(taroInterceptor) -/** - * 发起 HTTPS 网络请求 - * - * @canUse request - * @__object [url, data, header, timeout, method[OPTIONS, GET, HEAD, POST, PUT, PATCH, DELETE, TRACE, CONNECT], dataType[json, text, base64, arraybuffer], responseType[text, arraybuffer], enableCache] - * @__success [data, header, statusCode, cookies] - */ + export function request (options) { const result = link.request.bind(link)(options) result.catch(() => {}) return result } -/** - * 网络请求任务对象 - * - * @canUse RequestTask - * @__class [abort, onHeadersReceived, offHeadersReceived] - */ -/** - * 使用拦截器 - * - * @canNotUse addInterceptor - */ export const addInterceptor = link.addInterceptor.bind(link) -/** - * 清除所有拦截器 - * - * @canNotUse cleanInterceptors - */ + export const cleanInterceptors = link.cleanInterceptors.bind(link) diff --git a/packages/taro-platform-harmony-hybrid/src/api/apis/taro.ts b/packages/taro-platform-harmony-hybrid/src/api/apis/taro.ts index 51621da68bab..6fadc070d749 100644 --- a/packages/taro-platform-harmony-hybrid/src/api/apis/taro.ts +++ b/packages/taro-platform-harmony-hybrid/src/api/apis/taro.ts @@ -16,6 +16,7 @@ import { switchTab, } from './index' import native from './NativeApi' +import { invertColor } from './utils/colorConvert' // import { permanentlyNotSupport } from './utils' // @ts-ignore @@ -207,6 +208,11 @@ if (typeof window !== 'undefined') { // 更新导航栏状态 Taro.eventCenter.on('__taroSetNavigationStyle', (style, textStyle, backgroundColor) => { if (typeof window !== 'undefined') { + if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) { + // 当前处于深色模式,对textStyle和backgroundColor进行反转 + textStyle = textStyle === 'black' ? 'white' : 'black' + backgroundColor = invertColor(backgroundColor) + } native.setNavigationStyle({ style, textStyle, backgroundColor }) // @ts-ignore Object.assign(window.currentNavigation, { diff --git a/packages/taro-platform-harmony-hybrid/src/api/apis/utils/colorConvert.ts b/packages/taro-platform-harmony-hybrid/src/api/apis/utils/colorConvert.ts new file mode 100644 index 000000000000..34162b14b80c --- /dev/null +++ b/packages/taro-platform-harmony-hybrid/src/api/apis/utils/colorConvert.ts @@ -0,0 +1,34 @@ +/** + * 匹配到缩写的颜色值时进行扩写,如 '#fff'扩写后为'#ffffff' + * @param hex + */ +function expandHex (hex) { + return hex.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i, function (_m, r, g, b) { + return '#' + r + r + g + g + b + b + }) +} + +/** + * 颜色反转,用于适配深色模式 + * @param hex 十六进制颜色值 + */ +export function invertColor (hex: string) { + // 扩展缩写的颜色值 + hex = expandHex(hex) + + // 移除 # 符号 + hex = hex.replace('#', '') + + // 将十六进制转换为RGB + let r = parseInt(hex.substring(0, 2), 16) + let g = parseInt(hex.substring(2, 4), 16) + let b = parseInt(hex.substring(4, 6), 16) + + // 反转RGB值 + r = 255 - r + g = 255 - g + b = 255 - b + + // 将RGB值转换回十六进制 + return '#' + (r.toString(16).padStart(2, '0')) + (g.toString(16).padStart(2, '0')) + (b.toString(16).padStart(2, '0')) +} diff --git a/packages/taro-plugin-mini-ci/package.json b/packages/taro-plugin-mini-ci/package.json index 9080c471cd7b..16f7d839f672 100644 --- a/packages/taro-plugin-mini-ci/package.json +++ b/packages/taro-plugin-mini-ci/package.json @@ -44,7 +44,7 @@ "dingtalk-miniapp-opensdk": "^1.0.7", "jd-miniprogram-ci": "^1.0.2", "minidev": "^1.5.1", - "tt-ide-cli": "^0.1.13" + "tt-ide-cli": "^0.1.20" }, "peerDependenciesMeta": { "dingtalk-miniapp-opensdk": { diff --git a/packages/taro-plugin-mini-ci/src/TTCI.ts b/packages/taro-plugin-mini-ci/src/TTCI.ts index 89d683a54df5..134496a99215 100644 --- a/packages/taro-plugin-mini-ci/src/TTCI.ts +++ b/packages/taro-plugin-mini-ci/src/TTCI.ts @@ -16,7 +16,7 @@ export default class TTCI extends BaseCI { process.exit(1) } try { - // 调试使用版本是: tt-ide-cli@0.1.13 + // 调试使用版本是: tt-ide-cli@0.1.20 this.tt = getNpmPkgSync('tt-ide-cli', process.cwd()) } catch (error) { printLog(processTypeEnum.ERROR, chalk.red('请安装依赖:tt-ide-cli')) @@ -41,7 +41,7 @@ export default class TTCI extends BaseCI { path: this.projectPath } }) - console.log(chalk.green(`打开IDE成功`)) + console.log(chalk.green('打开IDE成功')) } catch (error) { printLog(processTypeEnum.ERROR, chalk.red('打开IDE失败', error)) } diff --git a/packages/taro-plugin-react/src/runtime/connect.ts b/packages/taro-plugin-react/src/runtime/connect.ts index 878af8a9337e..7c31a0308c4a 100644 --- a/packages/taro-plugin-react/src/runtime/connect.ts +++ b/packages/taro-plugin-react/src/runtime/connect.ts @@ -189,7 +189,12 @@ export function createReactApp ( } function waitAppWrapper (cb: () => void) { - appWrapper ? cb() : appWrapperPromise.then(() => cb()) + /** + * 当同个事件触发多次时,waitAppWrapper 会出现同步和异步任务的执行顺序问题, + * 导致某些场景下 onShow 会优于 onLaunch 执行 + */ + appWrapperPromise.then(() => cb()) + // appWrapper ? cb() : appWrapperPromise.then(() => cb()) } function renderReactRoot () { @@ -275,7 +280,11 @@ export function createReactApp ( }, unmount (id: string, cb: () => void) { - appWrapper.unmount(id, cb) + if (appWrapper) { + appWrapper.unmount(id, cb) + } else { + appWrapperPromise.then(appWrapper => appWrapper.unmount(id, cb)) + } } }, { config: setDefaultDescriptor({ diff --git a/packages/taro-router/src/api.ts b/packages/taro-router/src/api.ts index aff9190d8742..e4933c0f1c1e 100644 --- a/packages/taro-router/src/api.ts +++ b/packages/taro-router/src/api.ts @@ -60,21 +60,18 @@ async function navigate (option: Option | NavigateBackOption, method: MethodName try { if ('url' in option) { - const pathPieces = processNavigateUrl(option) - const state = { timestamp: Date.now() } - if (pathPieces.pathname) { - const originPath = routesAlias.getOrigin(pathPieces.pathname) - if (!RouterConfig.isPage(addLeadingSlash(originPath)) && !RouterConfig.isPage(addLeadingSlash(pathPieces.pathname))) { - const res = { errMsg: `${method}:fail page ${originPath} is not found` } - fail?.(res) - complete?.(res) - if (fail || complete) { - return resolve(res) - } else { - return reject(res) - } + if (!RouterConfig.isPage(addLeadingSlash(option.url))) { + const res = { errMsg: `${method}:fail page ${option.url} is not found` } + fail?.(res) + complete?.(res) + if (fail || complete) { + return resolve(res) + } else { + return reject(res) } } + const pathPieces = processNavigateUrl(option) + const state = { timestamp: Date.now() } if (method === 'navigateTo') { history.push(pathPieces, state) } else if (method === 'redirectTo' || method === 'switchTab') { diff --git a/packages/taro-router/src/router/index.ts b/packages/taro-router/src/router/index.ts index 0e57d69a58e8..fb6de12c3b9d 100644 --- a/packages/taro-router/src/router/index.ts +++ b/packages/taro-router/src/router/index.ts @@ -1,4 +1,4 @@ -import { prependBasename } from '../history' +import { addLeadingSlash } from '@tarojs/runtime' import type { MpaRouterConfig, SpaRouterConfig } from '../../types/router' @@ -27,7 +27,8 @@ export class RouterConfig { static get customRoutes () { return this.router.customRoutes || {} } + // 这个方法不考虑 basename 和 customRoutes,只判断原始的 url 是否在 pages 中 static isPage (url = '') { - return this.pages.findIndex(e => prependBasename(e) === url) !== -1 + return this.pages.findIndex(e => addLeadingSlash(e) === url) !== -1 } } diff --git a/packages/taro-router/src/router/navigation-bar.ts b/packages/taro-router/src/router/navigation-bar.ts index 8830d8ccbf34..09b0bd903b7a 100644 --- a/packages/taro-router/src/router/navigation-bar.ts +++ b/packages/taro-router/src/router/navigation-bar.ts @@ -41,7 +41,7 @@ export default class NavigationBarHandler { } private toHomeFn () { - reLaunch({ url: this.pageContext.homePage }) + reLaunch({ url: this.pageContext.originHomePage }) } private backFn () { diff --git a/packages/taro-router/src/router/page.ts b/packages/taro-router/src/router/page.ts index d77c7a9ca4d6..27652a824f21 100644 --- a/packages/taro-router/src/router/page.ts +++ b/packages/taro-router/src/router/page.ts @@ -25,10 +25,12 @@ export default class PageHandler { protected navigationBarHandler: NavigationBarHandler public homePage: string + public originHomePage: string constructor (config: SpaRouterConfig, public history: History) { this.config = config this.homePage = getHomePage(this.routes[0].path, this.basename, this.customRoutes, this.config.entryPagePath) + this.originHomePage = this.config.entryPagePath || this.routes[0].path || this.basename this.mount() this.navigationBarHandler = new NavigationBarHandler(this) } @@ -260,23 +262,33 @@ export default class PageHandler { } } - hide (page?: PageInstance | null) { + hide (page?: PageInstance | null, animation = false) { if (!page) return // NOTE: 修复多页并发问题,此处可能因为路由跳转过快,执行时页面可能还没有创建成功 const pageEl = this.getPageContainer(page) if (pageEl) { - if (this.hideTimer) { - clearTimeout(this.hideTimer) - this.hideTimer = null + if (animation) { + if (this.hideTimer) { + clearTimeout(this.hideTimer) + this.hideTimer = null + this.lastHidePage?.classList?.add?.('taro_page_shade') + } + this.lastHidePage = pageEl + this.hideTimer = setTimeout(() => { + this.hideTimer = null + pageEl.classList.add('taro_page_shade') + }, this.animationDuration + this.animationDelay) + page.onHide?.() + } else { + if (this.hideTimer) { + clearTimeout(this.hideTimer) + this.hideTimer = null + this.lastHidePage?.classList?.add?.('taro_page_shade') + } pageEl.classList.add('taro_page_shade') + this.lastHidePage = pageEl } - this.lastHidePage = pageEl - this.hideTimer = setTimeout(() => { - this.hideTimer = null - pageEl.classList.add('taro_page_shade') - }, this.animationDuration + this.animationDelay) - page.onHide?.() } else { setTimeout(() => this.hide(page), 0) } diff --git a/packages/taro-router/src/router/spa.ts b/packages/taro-router/src/router/spa.ts index af03d54fc53f..6c0d082d0a53 100644 --- a/packages/taro-router/src/router/spa.ts +++ b/packages/taro-router/src/router/spa.ts @@ -132,6 +132,7 @@ export function createRouter ( } else if (currentPage && handler.isTabBar(handler.pathname)) { if (handler.isSamePage(currentPage)) return if (handler.isTabBar(currentPage!.path!)) { + // NOTE: 从 tabBar 页面切换到 tabBar 页面 handler.hide(currentPage) stacks.pushTab(currentPage!.path!.split('?')[0]) } else if (stacks.length > 0) { @@ -170,7 +171,7 @@ export function createRouter ( handler.unload(currentPage, delta) shouldLoad = true } else if (action === 'PUSH') { - handler.hide(currentPage) + handler.hide(currentPage, true) shouldLoad = true } diff --git a/packages/taro-router/src/style.ts b/packages/taro-router/src/style.ts index ec8f724b567c..d356a8486f4f 100644 --- a/packages/taro-router/src/style.ts +++ b/packages/taro-router/src/style.ts @@ -64,8 +64,9 @@ ${ } ` : ''} - .taro_page_shade, - .taro_router > .taro_page.taro_page_show.taro_page_stationed:not(.taro_page_shade):not(.taro_tabbar_page):not(:last-child) { + .taro_page_shade:has(+.taro_page_stationed), + .taro_page_shade.taro_tabbar_page, + .taro_router > .taro_page.taro_page_show.taro_page_stationed:not(.taro_page_shade):not(.taro_tabbar_page):not(:last-child):has(+.taro_page_stationed) { display: none; } ` diff --git a/packages/taro/types/api/network/request.d.ts b/packages/taro/types/api/network/request.d.ts index 416a73fba41c..d191d33a58f4 100644 --- a/packages/taro/types/api/network/request.d.ts +++ b/packages/taro/types/api/network/request.d.ts @@ -78,7 +78,7 @@ declare module '../../index' { /** 接口调用失败的回调函数 */ fail?: (res: TaroGeneral.CallbackResult) => void /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: (res: TaroGeneral.CallbackResult) => void + complete?: (res: Partial & TaroGeneral.CallbackResult) => void /** 设置是否使用 jsonp 方式获取数据 * @default false * @supported h5