UNPKG

@tarojs/taro-h5

Version:
46 lines (43 loc) 1.84 kB
import { setTitle } from '@tarojs/router/dist/utils/navigate'; import { temporarilyNotSupport, shouldBeObject, getParameterError } from '../../../utils/index.js'; import { MethodHandler } from '../../../utils/handler.js'; // 导航栏 const showNavigationBarLoading = temporarilyNotSupport('showNavigationBarLoading'); function setNavigationBarTitle(options) { // options must be an Object const isObject = shouldBeObject(options); if (!isObject.flag) { const res = { errMsg: `setNavigationBarTitle:fail ${isObject.msg}` }; console.error(res.errMsg); return Promise.reject(res); } const { title, success, fail, complete } = options; const handle = new MethodHandler({ name: 'setNavigationBarTitle', success, fail, complete }); if (!title || typeof title !== 'string') { return handle.fail({ errMsg: getParameterError({ para: 'title', correct: 'String', wrong: title }) }); } setTitle(title); return handle.success(); } /** * 设置页面导航条颜色 */ const setNavigationBarColor = (options) => { const { backgroundColor, success, fail, complete } = options; const handle = new MethodHandler({ name: 'setNavigationBarColor', success, fail, complete }); const meta = document.createElement('meta'); meta.setAttribute('name', 'theme-color'); meta.setAttribute('content', backgroundColor); document.head.appendChild(meta); return handle.success(); }; const hideNavigationBarLoading = temporarilyNotSupport('hideNavigationBarLoading'); const hideHomeButton = temporarilyNotSupport('hideHomeButton'); export { hideHomeButton, hideNavigationBarLoading, setNavigationBarColor, setNavigationBarTitle, showNavigationBarLoading }; //# sourceMappingURL=index.js.map