From 1c11cb5aeaeb878d3f29dc35174d134535f0c792 Mon Sep 17 00:00:00 2001 From: DongChen Lin <393227948@qq.com> Date: Fri, 7 Jun 2024 22:08:20 +0800 Subject: [PATCH] update --- gui/src-tauri/Cargo.toml | 2 +- gui/src/layout/Apps.vue | 49 ++++++++++++++++++++++++++++------------ 2 files changed, 36 insertions(+), 15 deletions(-) diff --git a/gui/src-tauri/Cargo.toml b/gui/src-tauri/Cargo.toml index d7dcad2a..efe17992 100644 --- a/gui/src-tauri/Cargo.toml +++ b/gui/src-tauri/Cargo.toml @@ -17,7 +17,7 @@ tauri-build = { version = "2.0.0-beta", features = [] } # tauri = { version = "2.0.0-beta", features = ["devtools"] } [dependencies] fix-path-env = { git = "https://github.com/tauri-apps/fix-path-env-rs" } -tauri = { version = "=2.0.0-beta.22", features = ["macos-proxy"] } +tauri = { version = "=2.0.0-beta.22", features = ["macos-proxy", "unstable"] } tauri-utils = "=2.0.0-beta.17" tauri-plugin-shell = "=2.0.0-beta.5" serde = { version = "1", features = ["derive"] } diff --git a/gui/src/layout/Apps.vue b/gui/src/layout/Apps.vue index c05d6ad9..031a4f7a 100644 --- a/gui/src/layout/Apps.vue +++ b/gui/src/layout/Apps.vue @@ -4,7 +4,8 @@ import { useStore } from 'vuex'; import { useRouter } from 'vue-router'; import AppService from '@/service/AppService'; import { WebviewWindow } from '@tauri-apps/api/webviewWindow' - +import { Webview } from '@tauri-apps/api/webview' +import { getCurrent } from '@tauri-apps/api/window' const router = useRouter(); const store = useStore(); const appService = new AppService(); @@ -23,6 +24,9 @@ const pages = computed(()=>{ return _pages>0?new Array(_pages):[]; }); const appPageSize = 8; +const platform = computed(() => { + return store.getters['account/platform'] +}); const openWebview = (app)=>{ store.commit('webview/setTarget', { icon: app.icon, @@ -43,17 +47,34 @@ const openWebview = (app)=>{ options.url = "http://"+(app?.port?.listen?.ip||'127.0.0.1')+':'+app?.port?.listen?.port;; delete options.proxyUrl; } - const webview = new WebviewWindow(`${app.name}-webview`, options); - webview.once('tauri://created', function (d) { - console.log('tauri://created') - console.log(d) - // webview successfully created - }); - webview.once('tauri://error', function (e) { - console.log('tauri://error') - console.log(e) - // an error happened creating the webview - }); + if(platform.value=='android'){ + options.x = 0; + options.y = 0; + options.height = 800; + const webview = new Webview(getCurrent(),`${app.name}-webview`, options); + webview.once('tauri://created', function (d) { + console.log('tauri://created') + console.log(d) + // webview successfully created + }); + webview.once('tauri://error', function (e) { + console.log('tauri://error') + console.log(e) + // an error happened creating the webview + }); + } else { + const webview = new WebviewWindow(`${app.name}-webview`, options); + webview.once('tauri://created', function (d) { + console.log('tauri://created') + console.log(d) + // webview successfully created + }); + webview.once('tauri://error', function (e) { + console.log('tauri://error') + console.log(e) + // an error happened creating the webview + }); + } }catch(e){ console.log(e) } @@ -93,9 +114,9 @@ const appPage = computed(()=>(page)=>{