Skip to content

Commit

Permalink
use iframe app
Browse files Browse the repository at this point in the history
  • Loading branch information
lindongchen committed Jul 23, 2024
1 parent ee6375a commit afeec08
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
8 changes: 7 additions & 1 deletion gui/src/layout/AppLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ watch(isSidebarActive, (newVal) => {
}
});
const app = computed(() => {
return store.getters['notice/app'];
});
const mobileLeftbar = computed(() => {
return store.getters['account/mobileLeftbar'];
});
Expand Down Expand Up @@ -74,6 +77,8 @@ const isMobile = computed(() => windowWidth.value<=768);
const toggleLeft = () => {
store.commit('account/setMobileLeftbar', false);
}
const windowHeight = ref(window.innerHeight);
const viewHeight = computed(() => windowHeight.value - 0);
</script>

<template>
Expand All @@ -87,8 +92,9 @@ const toggleLeft = () => {
</div> -->
<div class="layout-main-container" >
<div class="layout-main" >

<iframe v-if="app && !!app.url" :src="app.url" width="100%" frameborder="0" :height="viewHeight"/>
<router-view
v-else
v-slot="{ Component }"
>
<keep-alive>
Expand Down
2 changes: 2 additions & 0 deletions gui/src/router/guards.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ const progressStart = (to, from, next) => {
const loginGuard = (to, from, next, options) => {
const { toast } = options;
const store = useStore();

store.commit('notice/setApp', null);
if (!loginIgnore.includes(to) && !checkAuthorization()) {
const toast = useToast();
toast.add({ severity: 'warn', summary: 'Tips', detail: 'Login is invalid, please login again', life: 3000 });
Expand Down
7 changes: 7 additions & 0 deletions gui/src/store/modules/notice.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export default {
state: {
confirm:null,
toast:null,
app:null,
},
getters: {
confirm: (state) => {
Expand All @@ -11,6 +12,9 @@ export default {
toast: (state) => {
return state.toast;
},
app: (state) => {
return state.app;
},
},
mutations: {
setConfirm(state, confirm) {
Expand All @@ -19,5 +23,8 @@ export default {
setToast(state, toast) {
state.toast = toast;
},
setApp(state, app) {
state.app = app;
},
},
};
4 changes: 2 additions & 2 deletions gui/src/utils/webview.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { invoke } from '@tauri-apps/api/core';
// import { getCurrent as getCurrentDL } from '@tauri-apps/plugin-deep-link';

const openWebview = (app)=>{

if(!window.__TAURI_INTERNALS__ ){
window.open(app.url);
store.commit('notice/setApp', app);
// window.open(app.url);
return
}
try{
Expand Down

0 comments on commit afeec08

Please sign in to comment.