wangguoyu 6 месяцев назад
Родитель
Сommit
d305440482
2 измененных файлов с 61 добавлено и 21 удалено
  1. 47 12
      App.vue
  2. 14 9
      main.js

+ 47 - 12
App.vue

@@ -1,26 +1,61 @@
 <script>
-	 import CustomTabBar from '@/components/custom-tabbar/custom-tabbar.vue';
+	import {
+		onBackPress
+	} from "@dcloudio/uni-app"
+	import {
+		toast,
+		getUserIdentity
+	} from "@/utils/common";
+	import cacheManager from "@/utils/cacheManager.js";
 	export default {
 		// creat by wgy 0619  生命周期 钩子  
 		onLaunch: function() {
-		//	console.log('App Launch')
+			console.log('App Launch')
+
+
+
 		},
 		onShow: function() {
-		//	console.log('App Show')
+			console.log('App Show')
+			// #ifdef APP-PLUS
+			if (cacheManager.get('auth')) {
+				console.log('有auth')
+				uni.redirectTo({
+					url: `/pages/study/index`
+				})
+			} else {
+					console.log('wuasdasdasdsaauth')
+				cacheManager.clearAll()
+				uni.redirectTo({
+					url: '/pages/login/index'
+				});
+			}
+			const webview = plus.webview.currentWebview();
+			plus.key.addEventListener('backbutton', () => {
+				console.log('12312312312312231231');
+				event.preventDefault();
+				return false
+			});
+			// #endif
+
 		},
 		onHide: function() {
-			//console.log('App Hide')
+			console.log('App Hide')
+
 		}
 	}
 </script>
 
 <style lang="scss">
 	/* 公共样式 */
- @import '/common/styles/index.scss';
- body, html, #app {
-   font-family: "Helvetica Neue","Microsoft YaHei", "SimHei","SimSun", "Arial", sans-serif;
-   margin: 0;
-   padding: 0;
-   box-sizing: border-box;
- }
-</style>
+	@import '/common/styles/index.scss';
+
+	body,
+	html,
+	#app {
+		font-family: "Helvetica Neue", "Microsoft YaHei", "SimHei", "SimSun", "Arial", sans-serif;
+		margin: 0;
+		padding: 0;
+		box-sizing: border-box;
+	}
+</style>

+ 14 - 9
main.js

@@ -1,4 +1,5 @@
-import { createApp } from 'vue'
+import { createSSRApp } from 'vue'
+
 import App from './App.vue'
 //import plugins from './plugins' // plugins
 //import './permission' // permission
@@ -7,11 +8,15 @@ import uviewPlus from 'uview-plus'
 import {state,setGlobalVariable} from './common/prototype.js'//全局挂载
 const pinia = createPinia()
 // 创建Vue应用实例
-const app = createApp(App)
-app.config.globalProperties.$state = state;
-app.config.globalProperties.$setGlobalVariable = setGlobalVariable;
-//app.use(plugins)
-app.use(createPinia())
-app.use(uviewPlus)
-// 挂载Vue应用实例
-app.mount('#app')
+export function createApp() {
+    const app = createSSRApp(App)
+	app.config.globalProperties.$state = state;
+	app.config.globalProperties.$setGlobalVariable = setGlobalVariable;
+    app.use(createPinia())
+    app.use(uviewPlus)
+  //  app.use(pinia)
+
+    return {
+        app
+    };
+}