Skip to content

Commit

Permalink
🐛 fix(remove): Remove logic which the same page is forbidden to open
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanghengxin committed Jan 18, 2023
1 parent acb2a28 commit a995a2b
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 84 deletions.
36 changes: 18 additions & 18 deletions src/mixins/app/Business_OpenThirdApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,24 @@ export default {
const port = appInfo.port ? `:${appInfo.port}` : ''
const url = `${protocol}://${hostIp}${port}${appInfo.index}`
let href = window.location.href.split("#")[0]
if (url === href) {
this.$buefy.toast.open({
message: this.$t('The page to be opened is the same as current page'),
type: 'is-warning',
position: 'is-top',
duration: 5000,
queue: false,
container: null,
animation: 'fade',
onOpen: () => {
},
onClose: () => {
},
ariaRole: 'alert',
ariaLive: 'polite'
})
return
}
// if (url === href) {
// this.$buefy.toast.open({
// message: this.$t('The page to be opened is the same as current page'),
// type: 'is-warning',
// position: 'is-top',
// duration: 5000,
// queue: false,
// container: null,
// animation: 'fade',
// onOpen: () => {
// },
// onClose: () => {
// },
// ariaRole: 'alert',
// ariaLive: 'polite'
// })
// return
// }
if (appInfo.image.toLowerCase().indexOf("qbittorrent") === -1) {
window.location.replace(url);
} else {
Expand Down
133 changes: 67 additions & 66 deletions src/views/AppLauncherCheck.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,89 +6,90 @@
*
* Copyright (c) 2022 by IceWhale, All Rights Reserved.
-->
<template>
<div class="is-flex is-flex-direction-column is-align-items-center is-justify-content-center is-fullheight" v-if="isCheckFailed">
<b-image :key="appDetailData.icon" :src="appDetailData.icon"
:src-fallback="require('@/assets/img/app/default.png')" class="is-64x64 icon-shadow"
webp-fallback=".jpg"></b-image>
<h2 class="has-text-emphasis-01 has-text-white mt-2">{{ appDetailData.name }}</h2>
<h1 v-if="status === 'pending'" class="has-text-sub-03 has-text-white mt-6">{{ $t('Preparing for launch') }}
</h1>
<h1 v-else class="has-text-sub-03 has-text-white mt-6">{{ $t('APP may not be available') }}</h1>
<b-image v-if="status === 'pending'" :src="require('@/assets/img/waiting.svg')" alt="pending"
class="is-48x48 mt-6" />
<span v-else class="has-text-full-03 has-text-grey-600 mt-6">{{
$t('Please')
}}
<template>
<div v-if="isCheckFailed"
class="is-flex is-flex-direction-column is-align-items-center is-justify-content-center is-fullheight">
<b-image :key="appDetailData.icon" :src="appDetailData.icon"
:src-fallback="require('@/assets/img/app/default.png')" class="is-64x64 icon-shadow"
webp-fallback=".jpg"></b-image>
<h2 class="has-text-emphasis-01 has-text-white mt-2">{{ appDetailData.name }}</h2>
<h1 v-if="status === 'pending'" class="has-text-sub-03 has-text-white mt-6">{{ $t('Preparing for launch') }}
</h1>
<h1 v-else class="has-text-sub-03 has-text-white mt-6">{{ $t('APP may not be available') }}</h1>
<b-image v-if="status === 'pending'" :src="require('@/assets/img/waiting.svg')" alt="pending"
class="is-48x48 mt-6"/>
<span v-else class="has-text-full-03 has-text-grey-600 mt-6">{{
$t('Please')
}}
<a @click="openThirdApp(appDetailData);">{{ $t('Click here') }}
</a> {{ $t('to open the app. If it does not work, please restart or try again later.') }}
</span>
<img :src="require('@/assets/img/logo/logo.svg')" alt="" class="is-absolute position" />
</div>
<img :src="require('@/assets/img/logo/logo.svg')" alt="" class="is-absolute position"/>
</div>
</template>

<script>
import business_OpenThirdApp from "@/mixins/app/Business_OpenThirdApp";

export default {
name: "AppLauncherCheck",
mixins: [business_OpenThirdApp],
data() {
return {
appDetailData: {
icon: "",
name: ""
},
status: "pending",
timer: null,
isCheckFailed:false
}
},
name: "AppLauncherCheck",
mixins: [business_OpenThirdApp],
data() {
return {
appDetailData: {
icon: "",
name: ""
},
status: "pending",
timer: null,
isCheckFailed: false
}
},

created() {
this.appDetailData = JSON.parse(this.$route.query.appDetailData)
let counter = 0
this.timer && clearInterval(this.timer)
this.timer = setInterval((async () => {
counter += 1
let isOk = await this.$api.container.containerLauncherCheck(this.appDetailData.id).then((res) => {
return res.status === 200
}).catch(async () => {
if (counter === 1) {
await this.$api.container.updateState(this.appDetailData.id, "start").catch((err) => {
this.$buefy.toast.open({
message: err.response.data.data || err.response.data.message,
type: 'is-danger',
position: 'is-top',
duration: 5000
})
})
}
return false
});
if(!isOk){
this.isCheckFailed = true
}
if (isOk) {
clearInterval(this.timer)
this.openThirdApp(this.appDetailData);
} else if (counter > 10) {
this.status = "reject"
clearInterval(this.timer)
}
})(), 1000)
},
created() {
this.appDetailData = JSON.parse(this.$route.query.appDetailData)
let counter = 0
this.timer && clearInterval(this.timer)
this.timer = setInterval((async () => {
counter += 1
let isOk = await this.$api.container.containerLauncherCheck(this.appDetailData.id).then((res) => {
return res.status === 200
}).catch(async () => {
if (counter === 1) {
await this.$api.container.updateState(this.appDetailData.id, "start").catch((err) => {
this.$buefy.toast.open({
message: err.response.data.data || err.response.data.message,
type: 'is-danger',
position: 'is-top',
duration: 5000
})
})
}
return false
});
if (!isOk) {
this.isCheckFailed = true
}
if (isOk) {
clearInterval(this.timer)
this.openThirdApp(this.appDetailData)
} else if (counter > 10) {
this.status = "reject"
clearInterval(this.timer)
}
})(), 1000)
},
}
</script>

<style lang="scss" scoped>
.is-fullheight {
background: hsla(208, 20%, 12%, 1);
height: 100vh;
background: hsla(208, 20%, 12%, 1);
height: 100vh;
}

.position {
left: 2rem;
bottom: 1.25rem;
left: 2rem;
bottom: 1.25rem;
}
</style>

0 comments on commit a995a2b

Please sign in to comment.