智慧教务系统UniApp前端项目(使用中2025-0517)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

82 lines
2.5 KiB

import Vue from 'vue'
import App from './App'
import store from './store'
import api from './api'
import util from './common/util.js'
import {Api_url} from 'common/config.js'
import minxin from './common/mixins/shopro-share.js'
import http from './common/axios.js'
// import ElementUI from 'element-ui';
// import 'element-ui/lib/theme-chalk/index.css';
Vue.config.productionTip = false
Vue.prototype.$getimg = Api_url
//Vue.use(ElementUI);
App.mpType = 'app'
Vue.prototype.$store = store
Vue.prototype.$api = api
Vue.prototype.$api = http
Vue.prototype.$util = util
Vue.prototype.$getimg = Api_url
Vue.mixin(minxin)
/**
* 全局封装跳转方法:this.$navigateTo({ url: 'xxx' })
* 支持在页面栈 >= 8 层时,关闭全部页面打开页面
*/
Vue.prototype.$navigateTo = function (options) {
// 只接受 { url: 'xxx' } 的形式作为参数
if (typeof options !== 'object' || !options.url) {
console.error('跳转参数错误', options);
// uni.showToast({ title: '参数错误', icon: 'none' });
return;
}
const url = options.url; // 获取要跳转的页面路径
const maxStackSize = 4; // 页面栈最大保留数量
const pages = getCurrentPages(); // 获取当前页面栈
const currentPage = pages[pages.length - 1];
const currentRoute = currentPage.route;
console.log('view-页面栈长度:',pages.length)
// 判断当前页面栈是否已满
if (pages.length >= maxStackSize) {
// 页面栈已满,使用 reLaunch 关闭所有页面并跳转
uni.reLaunch({
url,
success: () => {
// 可选:用于调试
// console.log('已通过 reLaunch 跳转到:', url);
},
fail: (err) => {
console.error('reLaunch 跳转失败:', err);
// uni.showToast({ title: '页面跳转失败', icon: 'none' });
}
});
} else {
// 页面栈未满,正常使用 navigateTo 正常跳转
uni.navigateTo({
url,
success: () => {
// 可选:用于调试
// console.log('当前页面栈:', getCurrentPages().map(p => p.route));
},
fail: (err) => {
console.error('navigateTo 跳转失败:', err);
// uni.showToast({ title: '页面跳转失败', icon: 'none' });
}
});
}
};
const app = new Vue({
store,
...App
})
app.$mount()