123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- import { uniAppHook } from './config';
- import H5init from '../vueRouter/init';
- import { appInit, removeBackPressEvent, pageIsHeadBack } from '../appRouter/init';
- import appletsInit from '../appletsRouter/init';
- import { appPlatform } from './util';
- import { proxyIndexHook } from '../appRouter/hooks';
- import { appletsProxyIndexHook } from '../appletsRouter/hooks';
- const getMixins = function (Router) {
- return {
- H5: {
- beforeCreate() {
- if (this.$options.router) {
- H5init(Router.$root, this.$options.router, this);
- }
- },
- },
- APP: {
- onLaunch() {
- uniAppHook.onLaunched = true;
- appInit.call(this, Router.$root);
- },
- onLoad() {
-
- if (uniAppHook.onLaunched && !uniAppHook.pageReady) {
- uniAppHook.onLaunched = false;
- proxyIndexHook.call(this, Router.$root);
- }
- removeBackPressEvent(this.$mp.page, this.$options);
- },
- onBackPress(...args) {
- return pageIsHeadBack.call(Router.$root, this.$mp.page, this.$options, args);
- },
- },
- APPLETS: {
- onLaunch() {
- uniAppHook.onLaunched = true;
- appletsInit.call(this, Router.$root);
- },
- onLoad() {
- if (uniAppHook.onLaunched && !uniAppHook.pageReady) {
- uniAppHook.onLaunched = false;
- appletsProxyIndexHook.call(this, Router.$root);
- }
- },
- },
- };
- };
- const initMixins = function (Vue, Router) {
- Vue.mixin({
- ...getMixins(Router)[appPlatform(true)],
- });
- };
- export default initMixins;
|