import App from './App' import uView from '@/uni_modules/uview-ui' import '@/static/css/fui.css' import '@/static/css/flex.css' import '@/static/css/uflex.css' // #ifndef VUE3 import Vue from 'vue' import './uni.promisify.adaptor' Vue.config.productionTip = false App.mpType = 'app' Vue.use(uView) const app = new Vue({ ...App }) app.$mount() // #endif // 定义全局方法 const navBack = (delta = 1) => { uni.navigateBack({ delta, }); } let lastNavTime = 0; const navTo = (url, type = '') => { const now = Date.now(); if (now - lastNavTime < 300) return; // 0.3秒内重复点击不跳转 lastNavTime = now; const pageStackLen = getCurrentPages().length; if (type === 'tabbar') { uni.switchTab({ url }); } else if (type === 'redirect') { uni.redirectTo({ url }); } else { console.log('页面调用栈', getCurrentPages().length) if (pageStackLen >= 9) { uni.reLaunch({ url }); } else { uni.navigateTo({ url }); } } }; // #ifdef VUE3 import { createSSRApp } from 'vue' export function createApp() { const app = createSSRApp(App) app.config.globalProperties.navBack = navBack app.config.globalProperties.navTo = navTo return { app } } // #endif