import Taro from '@tarojs/taro' import { goTo } from './navigation' export default function navTo(url: string, isLogin = false) { if (isLogin) { if (!Taro.getStorageSync('access_token') || !Taro.getStorageSync('UserId')) { Taro.showToast({ title: '请先登录', icon: 'none', duration: 500 }); return false; } } // 使用新的导航工具,自动处理路径格式化 goTo(url) } // 转base64 export function fileToBase64(filePath:string) { return new Promise((resolve) => { let fileManager = Taro.getFileSystemManager(); fileManager.readFile({ filePath, encoding: 'base64', success: (e: any) => { resolve(`data:image/jpg;base64,${e.data}`); } }); }); }; /** * 转义微信富文本图片样式 * @param htmlText */ export function wxParse(htmlText:string) { // Replace tags with max-width, height and margin styles to remove spacing htmlText = htmlText.replace(/\