提交 b05afc33 编写于 作者: D DCloud_LXH

feat(App):...

feat(App): setTabBarBadge、setTabBarItem、setTabBarStyle、hideTabBar、showTabBar、showTabBarRedDot、removeTabBarBadge、hideTabBarRedDot
上级 678cb2bc
...@@ -236,7 +236,7 @@ export function defineSyncApi<T extends ApiLike>( ...@@ -236,7 +236,7 @@ export function defineSyncApi<T extends ApiLike>(
export function defineAsyncApi<T extends AsyncApiLike, P = AsyncApiOptions<T>>( export function defineAsyncApi<T extends AsyncApiLike, P = AsyncApiOptions<T>>(
name: string, name: string,
fn: ( fn: (
args: Omit<P, CALLBACK_TYPES>, args: P extends undefined ? undefined : Omit<P, CALLBACK_TYPES>,
res: { res: {
resolve: (res: AsyncApiRes<P> | void) => void resolve: (res: AsyncApiRes<P> | void) => void
reject: (errMsg?: string, errRes?: any) => void reject: (errMsg?: string, errRes?: any) => void
......
...@@ -10,79 +10,79 @@ const __uniRoutes = instanceContext.__uniRoutes; ...@@ -10,79 +10,79 @@ const __uniRoutes = instanceContext.__uniRoutes;
var serviceContext = (function (vue) { var serviceContext = (function (vue) {
'use strict'; 'use strict';
/* /*
* base64-arraybuffer * base64-arraybuffer
* https://github.com/niklasvh/base64-arraybuffer * https://github.com/niklasvh/base64-arraybuffer
* *
* Copyright (c) 2012 Niklas von Hertzen * Copyright (c) 2012 Niklas von Hertzen
* Licensed under the MIT license. * Licensed under the MIT license.
*/ */
var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
// Use a lookup table to find the index. // Use a lookup table to find the index.
var lookup = /*#__PURE__*/ (function () { var lookup = /*#__PURE__*/ (function () {
const lookup = new Uint8Array(256); const lookup = new Uint8Array(256);
for (var i = 0; i < chars.length; i++) { for (var i = 0; i < chars.length; i++) {
lookup[chars.charCodeAt(i)] = i; lookup[chars.charCodeAt(i)] = i;
} }
return lookup return lookup
})(); })();
function encode$3(arraybuffer) { function encode$3(arraybuffer) {
var bytes = new Uint8Array(arraybuffer), var bytes = new Uint8Array(arraybuffer),
i, i,
len = bytes.length, len = bytes.length,
base64 = ''; base64 = '';
for (i = 0; i < len; i += 3) { for (i = 0; i < len; i += 3) {
base64 += chars[bytes[i] >> 2]; base64 += chars[bytes[i] >> 2];
base64 += chars[((bytes[i] & 3) << 4) | (bytes[i + 1] >> 4)]; base64 += chars[((bytes[i] & 3) << 4) | (bytes[i + 1] >> 4)];
base64 += chars[((bytes[i + 1] & 15) << 2) | (bytes[i + 2] >> 6)]; base64 += chars[((bytes[i + 1] & 15) << 2) | (bytes[i + 2] >> 6)];
base64 += chars[bytes[i + 2] & 63]; base64 += chars[bytes[i + 2] & 63];
} }
if (len % 3 === 2) { if (len % 3 === 2) {
base64 = base64.substring(0, base64.length - 1) + '='; base64 = base64.substring(0, base64.length - 1) + '=';
} else if (len % 3 === 1) { } else if (len % 3 === 1) {
base64 = base64.substring(0, base64.length - 2) + '=='; base64 = base64.substring(0, base64.length - 2) + '==';
} }
return base64 return base64
} }
function decode$1(base64) { function decode$1(base64) {
var bufferLength = base64.length * 0.75, var bufferLength = base64.length * 0.75,
len = base64.length, len = base64.length,
i, i,
p = 0, p = 0,
encoded1, encoded1,
encoded2, encoded2,
encoded3, encoded3,
encoded4; encoded4;
if (base64[base64.length - 1] === '=') { if (base64[base64.length - 1] === '=') {
bufferLength--; bufferLength--;
if (base64[base64.length - 2] === '=') { if (base64[base64.length - 2] === '=') {
bufferLength--; bufferLength--;
} }
} }
var arraybuffer = new ArrayBuffer(bufferLength), var arraybuffer = new ArrayBuffer(bufferLength),
bytes = new Uint8Array(arraybuffer); bytes = new Uint8Array(arraybuffer);
for (i = 0; i < len; i += 4) { for (i = 0; i < len; i += 4) {
encoded1 = lookup[base64.charCodeAt(i)]; encoded1 = lookup[base64.charCodeAt(i)];
encoded2 = lookup[base64.charCodeAt(i + 1)]; encoded2 = lookup[base64.charCodeAt(i + 1)];
encoded3 = lookup[base64.charCodeAt(i + 2)]; encoded3 = lookup[base64.charCodeAt(i + 2)];
encoded4 = lookup[base64.charCodeAt(i + 3)]; encoded4 = lookup[base64.charCodeAt(i + 3)];
bytes[p++] = (encoded1 << 2) | (encoded2 >> 4); bytes[p++] = (encoded1 << 2) | (encoded2 >> 4);
bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2); bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2);
bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63); bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63);
} }
return arraybuffer return arraybuffer
} }
/** /**
...@@ -1067,6 +1067,12 @@ var serviceContext = (function (vue) { ...@@ -1067,6 +1067,12 @@ var serviceContext = (function (vue) {
function cacheStringFunction(fn) { function cacheStringFunction(fn) {
return cache(fn); return cache(fn);
} }
function getLen(str = '') {
return ('' + str).replace(/[^\x00-\xff]/g, '**').length;
}
function removeLeadingSlash(str) {
return str.indexOf('/') === 0 ? str.substr(1) : str;
}
const invokeArrayFns = (fns, arg) => { const invokeArrayFns = (fns, arg) => {
let ret; let ret;
for (let i = 0; i < fns.length; i++) { for (let i = 0; i < fns.length; i++) {
...@@ -5011,6 +5017,104 @@ var serviceContext = (function (vue) { ...@@ -5011,6 +5017,104 @@ var serviceContext = (function (vue) {
const API_STOP_PULL_DOWN_REFRESH = 'stopPullDownRefresh'; const API_STOP_PULL_DOWN_REFRESH = 'stopPullDownRefresh';
const IndexProtocol = {
index: {
type: Number,
required: true,
},
};
const IndexOptions = {
beforeInvoke() {
const pageMeta = getCurrentPageMeta();
if (pageMeta && !pageMeta.isTabBar) {
return 'not TabBar page';
}
},
formatArgs: {
index(value) {
if (!__uniConfig.tabBar.list[value]) {
return 'tabbar item not found';
}
},
},
};
const API_SET_TAB_BAR_ITEM = 'setTabBarItem';
const SetTabBarItemProtocol =
/*#__PURE__*/ extend({
text: String,
iconPath: String,
selectedIconPath: String,
pagePath: String,
}, IndexProtocol);
const SetTabBarItemOptions = {
beforeInvoke: IndexOptions.beforeInvoke,
formatArgs: /*#__PURE__*/ extend({
pagePath(value, params) {
if (value) {
params.pagePath = removeLeadingSlash(value);
}
},
}, IndexOptions.formatArgs),
};
const API_SET_TAB_BAR_STYLE = 'setTabBarStyle';
const SetTabBarStyleProtocol = {
color: String,
selectedColor: String,
backgroundColor: String,
backgroundImage: String,
backgroundRepeat: String,
borderStyle: String,
};
const GRADIENT_RE = /^(linear|radial)-gradient\(.+?\);?$/;
const SetTabBarStyleOptions = {
beforeInvoke: IndexOptions.beforeInvoke,
formatArgs: {
backgroundImage(value, params) {
if (value && !GRADIENT_RE.test(value)) {
params.backgroundImage = getRealPath(value);
}
},
borderStyle(value, params) {
if (value) {
params.borderStyle = value === 'white' ? 'white' : 'black';
}
},
},
};
const API_HIDE_TAB_BAR = 'hideTabBar';
const HideTabBarProtocol = {
animation: Boolean,
};
const API_SHOW_TAB_BAR = 'showTabBar';
const ShowTabBarProtocol = HideTabBarProtocol;
const API_HIDE_TAB_BAR_RED_DOT = 'hideTabBarRedDot';
const HideTabBarRedDotProtocol = IndexProtocol;
const HideTabBarRedDotOptions = IndexOptions;
const API_SHOW_TAB_BAR_RED_DOT = 'showTabBarRedDot';
const ShowTabBarRedDotProtocol = IndexProtocol;
const ShowTabBarRedDotOptions = IndexOptions;
const API_REMOVE_TAB_BAR_BADGE = 'removeTabBarBadge';
const RemoveTabBarBadgeProtocol = IndexProtocol;
const RemoveTabBarBadgeOptions = IndexOptions;
const API_SET_TAB_BAR_BADGE = 'setTabBarBadge';
const SetTabBarBadgeProtocol =
/*#__PURE__*/ extend({
text: {
type: String,
required: true,
},
}, IndexProtocol);
const SetTabBarBadgeOptions = {
beforeInvoke: IndexOptions.beforeInvoke,
formatArgs: /*#__PURE__*/ extend({
text(value, params) {
if (getLen(value) >= 4) {
params.text = '...';
}
},
}, IndexOptions.formatArgs),
};
const API_GET_PROVIDER = 'getProvider'; const API_GET_PROVIDER = 'getProvider';
const GetProviderProtocol = { const GetProviderProtocol = {
service: { service: {
...@@ -5257,7 +5361,7 @@ var serviceContext = (function (vue) { ...@@ -5257,7 +5361,7 @@ var serviceContext = (function (vue) {
})); }));
}; };
} }
function isTabBarPage(path = '') { function isTabBarPage$1(path = '') {
if (!(__uniConfig.tabBar && Array.isArray(__uniConfig.tabBar.list))) { if (!(__uniConfig.tabBar && Array.isArray(__uniConfig.tabBar.list))) {
return false; return false;
} }
...@@ -5482,7 +5586,7 @@ var serviceContext = (function (vue) { ...@@ -5482,7 +5586,7 @@ var serviceContext = (function (vue) {
* @param {number} index * @param {number} index
* @param {string} text * @param {string} text
*/ */
function setTabBarBadge(type, index, text) { function setTabBarBadge$1(type, index, text) {
if (!tabBar) { if (!tabBar) {
return; return;
} }
...@@ -5509,7 +5613,7 @@ var serviceContext = (function (vue) { ...@@ -5509,7 +5613,7 @@ var serviceContext = (function (vue) {
/** /**
* 动态设置 tabBar 某一项的内容 * 动态设置 tabBar 某一项的内容
*/ */
function setTabBarItem(index, text, iconPath, selectedIconPath) { function setTabBarItem$1(index, text, iconPath, selectedIconPath) {
const item = { const item = {
index, index,
}; };
...@@ -5528,14 +5632,14 @@ var serviceContext = (function (vue) { ...@@ -5528,14 +5632,14 @@ var serviceContext = (function (vue) {
* 动态设置 tabBar 的整体样式 * 动态设置 tabBar 的整体样式
* @param {Object} style 样式 * @param {Object} style 样式
*/ */
function setTabBarStyle(style) { function setTabBarStyle$1(style) {
tabBar && tabBar.setTabBarStyle(style); tabBar && tabBar.setTabBarStyle(style);
} }
/** /**
* 隐藏 tabBar * 隐藏 tabBar
* @param {boolean} animation 是否需要动画效果 * @param {boolean} animation 是否需要动画效果
*/ */
function hideTabBar(animation) { function hideTabBar$1(animation) {
visible = false; visible = false;
tabBar && tabBar &&
tabBar.hideTabBar({ tabBar.hideTabBar({
...@@ -5546,7 +5650,7 @@ var serviceContext = (function (vue) { ...@@ -5546,7 +5650,7 @@ var serviceContext = (function (vue) {
* 显示 tabBar * 显示 tabBar
* @param {boolean} animation 是否需要动画效果 * @param {boolean} animation 是否需要动画效果
*/ */
function showTabBar(animation) { function showTabBar$1(animation) {
visible = true; visible = true;
tabBar && tabBar &&
tabBar.showTabBar({ tabBar.showTabBar({
...@@ -5603,11 +5707,11 @@ var serviceContext = (function (vue) { ...@@ -5603,11 +5707,11 @@ var serviceContext = (function (vue) {
} }
return false; return false;
}, },
setTabBarBadge, setTabBarBadge: setTabBarBadge$1,
setTabBarItem, setTabBarItem: setTabBarItem$1,
setTabBarStyle, setTabBarStyle: setTabBarStyle$1,
hideTabBar, hideTabBar: hideTabBar$1,
showTabBar, showTabBar: showTabBar$1,
append(webview) { append(webview) {
tabBar && tabBar &&
tabBar.append({ tabBar.append({
...@@ -5665,6 +5769,35 @@ var serviceContext = (function (vue) { ...@@ -5665,6 +5769,35 @@ var serviceContext = (function (vue) {
} }
function setPullDownRefreshWebview(webview) { function setPullDownRefreshWebview(webview) {
pullDownRefreshWebview = webview; pullDownRefreshWebview = webview;
}
function isTabBarPage(path = '') {
if (!(__uniConfig.tabBar && Array.isArray(__uniConfig.tabBar.list))) {
return false;
}
try {
if (!path) {
const pages = getCurrentPages();
if (!pages.length) {
return false;
}
const page = pages[pages.length - 1];
if (!page) {
return false;
}
return page.$page.meta.isTabBar;
}
if (!/^\//.test(path)) {
path = '/' + path;
}
const route = __uniRoutes.find((route) => route.path === path);
return route && route.meta.isTabBar;
}
catch (e) {
if (process.env.NODE_ENV !== 'production') {
console.log('getCurrentPages is not ready');
}
}
return false;
} }
function getStatusbarHeight() { function getStatusbarHeight() {
...@@ -5731,7 +5864,7 @@ var serviceContext = (function (vue) { ...@@ -5731,7 +5864,7 @@ var serviceContext = (function (vue) {
height: 0, height: 0,
cover: false, cover: false,
}; };
if (isTabBarPage()) { if (isTabBarPage$1()) {
tabBarView.height = tabBar$1.visible ? tabBar$1.height : 0; tabBarView.height = tabBar$1.visible ? tabBar$1.height : 0;
tabBarView.cover = tabBar$1.cover; tabBarView.cover = tabBar$1.cover;
} }
...@@ -8596,6 +8729,74 @@ var serviceContext = (function (vue) { ...@@ -8596,6 +8729,74 @@ var serviceContext = (function (vue) {
} }
}, SetNavigationBarColorProtocol, SetNavigationBarColorOptions); }, SetNavigationBarColorProtocol, SetNavigationBarColorOptions);
const setTabBarBadge = defineAsyncApi(API_SET_TAB_BAR_BADGE, ({ index, text }, { resolve, reject }) => {
tabBar$1.setTabBarBadge('text', index, text);
resolve();
}, SetTabBarBadgeProtocol, SetTabBarBadgeOptions);
const setTabBarItem = defineAsyncApi(API_SET_TAB_BAR_ITEM, ({ index, text, iconPath, selectedIconPath, pagePath }, { resolve, reject }) => {
tabBar$1.setTabBarItem(index, text, iconPath, selectedIconPath);
const route = pagePath && __uniRoutes.find(({ path }) => path === pagePath);
if (route) {
const meta = route.meta;
meta.isTabBar = true;
meta.tabBarIndex = index;
meta.isQuit = true;
const tabBar = __uniConfig.tabBar;
if (tabBar && tabBar.list && tabBar.list[index] && pagePath) {
tabBar.list[index].pagePath = pagePath.startsWith('/')
? pagePath.substring(1)
: pagePath;
}
}
resolve();
}, SetTabBarItemProtocol, SetTabBarItemOptions);
const setTabBarStyle = defineAsyncApi(API_SET_TAB_BAR_STYLE, (style = {}, { resolve, reject }) => {
if (!isTabBarPage()) {
return {
errMsg: 'setTabBarStyle:fail not TabBar page',
};
}
const borderStyles = {
black: 'rgba(0,0,0,0.4)',
white: 'rgba(255,255,255,0.4)',
};
const borderStyle = style.borderStyle;
if (borderStyle && borderStyle in borderStyles) {
style.borderStyle = borderStyles[borderStyle];
}
tabBar$1.setTabBarStyle(style);
resolve();
}, SetTabBarStyleProtocol, SetTabBarStyleOptions);
const hideTabBar = defineAsyncApi(API_HIDE_TAB_BAR, (args, { resolve, reject }) => {
const animation = args && args.animation;
if (!isTabBarPage()) {
return reject('not TabBar page');
}
tabBar$1.hideTabBar(Boolean(animation));
resolve();
}, HideTabBarProtocol);
const showTabBar = defineAsyncApi(API_SHOW_TAB_BAR, (args, { resolve, reject }) => {
const animation = args && args.animation;
if (!isTabBarPage()) {
return reject('not TabBar page');
}
tabBar$1.showTabBar(Boolean(animation));
resolve();
}, ShowTabBarProtocol);
const showTabBarRedDot = defineAsyncApi(API_SHOW_TAB_BAR_RED_DOT, ({ index }, { resolve, reject }) => {
tabBar$1.setTabBarBadge('redDot', index);
resolve();
}, ShowTabBarRedDotProtocol, ShowTabBarRedDotOptions);
const setTabBarBadgeNone = (index) => tabBar$1.setTabBarBadge('none', index);
const removeTabBarBadge = defineAsyncApi(API_REMOVE_TAB_BAR_BADGE, ({ index }, { resolve, reject }) => {
setTabBarBadgeNone(index);
resolve();
}, RemoveTabBarBadgeProtocol, RemoveTabBarBadgeOptions);
const hideTabBarRedDot = defineAsyncApi(API_HIDE_TAB_BAR_RED_DOT, ({ index }, { resolve, reject }) => {
setTabBarBadgeNone(index);
resolve();
}, HideTabBarRedDotProtocol, HideTabBarRedDotOptions);
const providers = { const providers = {
oauth(callback) { oauth(callback) {
plus.oauth.getServices((services) => { plus.oauth.getServices((services) => {
...@@ -10179,6 +10380,9 @@ var serviceContext = (function (vue) { ...@@ -10179,6 +10380,9 @@ var serviceContext = (function (vue) {
if (typeof callback !== 'function') { if (typeof callback !== 'function') {
return; return;
} }
if (!this._callbacks[type]) {
this._callbacks[type] = [];
}
this._callbacks[type].push(callback); this._callbacks[type].push(callback);
} }
_removeEventListener(type, callback) { _removeEventListener(type, callback) {
...@@ -11396,6 +11600,14 @@ var serviceContext = (function (vue) { ...@@ -11396,6 +11600,14 @@ var serviceContext = (function (vue) {
showNavigationBarLoading: showNavigationBarLoading, showNavigationBarLoading: showNavigationBarLoading,
hideNavigationBarLoading: hideNavigationBarLoading, hideNavigationBarLoading: hideNavigationBarLoading,
setNavigationBarColor: setNavigationBarColor, setNavigationBarColor: setNavigationBarColor,
setTabBarBadge: setTabBarBadge,
setTabBarItem: setTabBarItem,
setTabBarStyle: setTabBarStyle,
hideTabBar: hideTabBar,
showTabBar: showTabBar,
showTabBarRedDot: showTabBarRedDot,
removeTabBarBadge: removeTabBarBadge,
hideTabBarRedDot: hideTabBarRedDot,
getProvider: getProvider, getProvider: getProvider,
login: login, login: login,
getUserInfo: getUserInfo, getUserInfo: getUserInfo,
......
...@@ -49,6 +49,7 @@ export * from './ui/stopPullDownRefresh' ...@@ -49,6 +49,7 @@ export * from './ui/stopPullDownRefresh'
export * from './ui/loadFontFace' export * from './ui/loadFontFace'
export * from './ui/pageScrollTo' export * from './ui/pageScrollTo'
export * from './ui/navigationBar' export * from './ui/navigationBar'
export * from './ui/tabBar'
export * from './plugin/getProvider' export * from './plugin/getProvider'
export * from './plugin/oauth' export * from './plugin/oauth'
......
import {
API_HIDE_TAB_BAR,
API_HIDE_TAB_BAR_RED_DOT,
API_REMOVE_TAB_BAR_BADGE,
API_SET_TAB_BAR_BADGE,
API_SET_TAB_BAR_ITEM,
API_SET_TAB_BAR_STYLE,
API_SHOW_TAB_BAR,
API_SHOW_TAB_BAR_RED_DOT,
API_TYPE_HIDE_TAB_BAR,
API_TYPE_HIDE_TAB_BAR_RED_DOT,
API_TYPE_REMOVE_TAB_BAR_BADGE,
API_TYPE_SET_TAB_BAR_BADGE,
API_TYPE_SET_TAB_BAR_ITEM,
API_TYPE_SET_TAB_BAR_STYLE,
API_TYPE_SHOW_TAB_BAR,
API_TYPE_SHOW_TAB_BAR_RED_DOT,
defineAsyncApi,
HideTabBarProtocol,
HideTabBarRedDotOptions,
HideTabBarRedDotProtocol,
RemoveTabBarBadgeOptions,
RemoveTabBarBadgeProtocol,
SetTabBarBadgeOptions,
SetTabBarBadgeProtocol,
SetTabBarItemOptions,
SetTabBarItemProtocol,
SetTabBarStyleOptions,
SetTabBarStyleProtocol,
ShowTabBarProtocol,
ShowTabBarRedDotOptions,
ShowTabBarRedDotProtocol,
} from '@dcloudio/uni-api'
import { isTabBarPage } from '../../utils'
import tabBar from '../../framework/app/tabBar'
export const setTabBarBadge = defineAsyncApi<API_TYPE_SET_TAB_BAR_BADGE>(
API_SET_TAB_BAR_BADGE,
({ index, text }, { resolve, reject }) => {
tabBar.setTabBarBadge('text', index, text)
resolve()
},
SetTabBarBadgeProtocol,
SetTabBarBadgeOptions
)
export const setTabBarItem = defineAsyncApi<API_TYPE_SET_TAB_BAR_ITEM>(
API_SET_TAB_BAR_ITEM,
(
{ index, text, iconPath, selectedIconPath, pagePath },
{ resolve, reject }
) => {
tabBar.setTabBarItem(index, text, iconPath, selectedIconPath)
const route = pagePath && __uniRoutes.find(({ path }) => path === pagePath)
if (route) {
const meta = route.meta
meta.isTabBar = true
meta.tabBarIndex = index
meta.isQuit = true
const tabBar = __uniConfig.tabBar
if (tabBar && tabBar.list && tabBar.list[index] && pagePath) {
tabBar.list[index].pagePath = pagePath.startsWith('/')
? pagePath.substring(1)
: pagePath
}
}
resolve()
},
SetTabBarItemProtocol,
SetTabBarItemOptions
)
export const setTabBarStyle = defineAsyncApi<API_TYPE_SET_TAB_BAR_STYLE>(
API_SET_TAB_BAR_STYLE,
(style = {}, { resolve, reject }) => {
if (!isTabBarPage()) {
return {
errMsg: 'setTabBarStyle:fail not TabBar page',
}
}
const borderStyles = {
black: 'rgba(0,0,0,0.4)',
white: 'rgba(255,255,255,0.4)',
}
const borderStyle = style.borderStyle
if (borderStyle && borderStyle in borderStyles) {
style.borderStyle = borderStyles[borderStyle as keyof typeof borderStyles]
}
tabBar.setTabBarStyle(style)
resolve()
},
SetTabBarStyleProtocol,
SetTabBarStyleOptions
)
export const hideTabBar = defineAsyncApi<API_TYPE_HIDE_TAB_BAR>(
API_HIDE_TAB_BAR,
(args, { resolve, reject }) => {
const animation = args && args.animation
if (!isTabBarPage()) {
return reject('not TabBar page')
}
tabBar.hideTabBar(Boolean(animation))
resolve()
},
HideTabBarProtocol
)
export const showTabBar = defineAsyncApi<API_TYPE_SHOW_TAB_BAR>(
API_SHOW_TAB_BAR,
(args, { resolve, reject }) => {
const animation = args && args.animation
if (!isTabBarPage()) {
return reject('not TabBar page')
}
tabBar.showTabBar(Boolean(animation))
resolve()
},
ShowTabBarProtocol
)
export const showTabBarRedDot = defineAsyncApi<API_TYPE_SHOW_TAB_BAR_RED_DOT>(
API_SHOW_TAB_BAR_RED_DOT,
({ index }, { resolve, reject }) => {
tabBar.setTabBarBadge('redDot', index)
resolve()
},
ShowTabBarRedDotProtocol,
ShowTabBarRedDotOptions
)
const setTabBarBadgeNone = (index: number) =>
tabBar.setTabBarBadge('none', index)
export const removeTabBarBadge = defineAsyncApi<API_TYPE_REMOVE_TAB_BAR_BADGE>(
API_REMOVE_TAB_BAR_BADGE,
({ index }, { resolve, reject }) => {
setTabBarBadgeNone(index)
resolve()
},
RemoveTabBarBadgeProtocol,
RemoveTabBarBadgeOptions
)
export const hideTabBarRedDot = defineAsyncApi<API_TYPE_HIDE_TAB_BAR_RED_DOT>(
API_HIDE_TAB_BAR_RED_DOT,
({ index }, { resolve, reject }) => {
setTabBarBadgeNone(index)
resolve()
},
HideTabBarRedDotProtocol,
HideTabBarRedDotOptions
)
...@@ -22,7 +22,7 @@ let tabBar: any ...@@ -22,7 +22,7 @@ let tabBar: any
function setTabBarBadge( function setTabBarBadge(
type: 'none' | 'text' | 'redDot', type: 'none' | 'text' | 'redDot',
index: number, index: number,
text: string text?: string
) { ) {
if (!tabBar) { if (!tabBar) {
return return
......
...@@ -27,3 +27,32 @@ export function setPullDownRefreshWebview( ...@@ -27,3 +27,32 @@ export function setPullDownRefreshWebview(
) { ) {
pullDownRefreshWebview = webview pullDownRefreshWebview = webview
} }
export function isTabBarPage(path = '') {
if (!(__uniConfig.tabBar && Array.isArray(__uniConfig.tabBar.list))) {
return false
}
try {
if (!path) {
const pages = getCurrentPages()
if (!pages.length) {
return false
}
const page = pages[pages.length - 1]
if (!page) {
return false
}
return page.$page.meta.isTabBar
}
if (!/^\//.test(path)) {
path = '/' + path
}
const route = __uniRoutes.find((route) => route.path === path)
return route && route.meta.isTabBar
} catch (e) {
if (process.env.NODE_ENV !== 'production') {
console.log('getCurrentPages is not ready')
}
}
return false
}
...@@ -786,7 +786,7 @@ var safeAreaInsets = { ...@@ -786,7 +786,7 @@ var safeAreaInsets = {
onChange, onChange,
offChange offChange
}; };
var out = safeAreaInsets; var D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out = safeAreaInsets;
const onEventPrevent = /* @__PURE__ */ withModifiers(() => { const onEventPrevent = /* @__PURE__ */ withModifiers(() => {
}, ["prevent"]); }, ["prevent"]);
const onEventStop = /* @__PURE__ */ withModifiers(() => { const onEventStop = /* @__PURE__ */ withModifiers(() => {
...@@ -798,10 +798,10 @@ function getWindowOffset() { ...@@ -798,10 +798,10 @@ function getWindowOffset() {
const left = parseInt(style.getPropertyValue("--window-left")); const left = parseInt(style.getPropertyValue("--window-left"));
const right = parseInt(style.getPropertyValue("--window-right")); const right = parseInt(style.getPropertyValue("--window-right"));
return { return {
top: top ? top + out.top : 0, top: top ? top + D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.top : 0,
bottom: bottom ? bottom + out.bottom : 0, bottom: bottom ? bottom + D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.bottom : 0,
left: left ? left + out.left : 0, left: left ? left + D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.left : 0,
right: right ? right + out.right : 0 right: right ? right + D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.right : 0
}; };
} }
function updateCssVar(cssVars) { function updateCssVar(cssVars) {
...@@ -13347,7 +13347,7 @@ function normalizePageMeta(pageMeta) { ...@@ -13347,7 +13347,7 @@ function normalizePageMeta(pageMeta) {
}, pageMeta.pullToRefresh)); }, pageMeta.pullToRefresh));
const { type, style } = navigationBar; const { type, style } = navigationBar;
if (style !== "custom" && type !== "transparent") { if (style !== "custom" && type !== "transparent") {
pullToRefresh.offset += NAVBAR_HEIGHT + out.top; pullToRefresh.offset += NAVBAR_HEIGHT + D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.top;
} }
pageMeta.pullToRefresh = pullToRefresh; pageMeta.pullToRefresh = pullToRefresh;
} }
...@@ -15545,7 +15545,7 @@ const getSystemInfoSync = /* @__PURE__ */ defineSyncApi("getSystemInfoSync", () ...@@ -15545,7 +15545,7 @@ const getSystemInfoSync = /* @__PURE__ */ defineSyncApi("getSystemInfoSync", ()
const windowWidth = getWindowWidth(screenWidth); const windowWidth = getWindowWidth(screenWidth);
let windowHeight = window.innerHeight; let windowHeight = window.innerHeight;
const language = navigator.language; const language = navigator.language;
const statusBarHeight = out.top; const statusBarHeight = D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.top;
let osname; let osname;
let osversion; let osversion;
let model; let model;
...@@ -15658,12 +15658,12 @@ const getSystemInfoSync = /* @__PURE__ */ defineSyncApi("getSystemInfoSync", () ...@@ -15658,12 +15658,12 @@ const getSystemInfoSync = /* @__PURE__ */ defineSyncApi("getSystemInfoSync", ()
const system = `${osname} ${osversion}`; const system = `${osname} ${osversion}`;
const platform = osname.toLocaleLowerCase(); const platform = osname.toLocaleLowerCase();
const safeArea = { const safeArea = {
left: out.left, left: D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.left,
right: windowWidth - out.right, right: windowWidth - D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.right,
top: out.top, top: D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.top,
bottom: windowHeight - out.bottom, bottom: windowHeight - D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.bottom,
width: windowWidth - out.left - out.right, width: windowWidth - D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.left - D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.right,
height: windowHeight - out.top - out.bottom height: windowHeight - D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.top - D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.bottom
}; };
const { top: windowTop, bottom: windowBottom } = getWindowOffset(); const { top: windowTop, bottom: windowBottom } = getWindowOffset();
windowHeight -= windowTop; windowHeight -= windowTop;
...@@ -15683,10 +15683,10 @@ const getSystemInfoSync = /* @__PURE__ */ defineSyncApi("getSystemInfoSync", () ...@@ -15683,10 +15683,10 @@ const getSystemInfoSync = /* @__PURE__ */ defineSyncApi("getSystemInfoSync", ()
model, model,
safeArea, safeArea,
safeAreaInsets: { safeAreaInsets: {
top: out.top, top: D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.top,
right: out.right, right: D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.right,
bottom: out.bottom, bottom: D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.bottom,
left: out.left left: D__DCloud_local_git_uniAppNext_node_modules_safeAreaInsets_out.left
} }
}; };
}); });
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册