fix isAppRunning
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
APP_VERSION="0.5.44"
|
||||
APP_VERSION="0.5.46"
|
||||
SERVICE_WORKER_FILE="service-worker.js"
|
||||
APP_ID="13"
|
||||
DIRECTORY_LOCAL="newfreeplanet"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_VERSION="0.5.44"
|
||||
APP_VERSION="0.5.46"
|
||||
SERVICE_WORKER_FILE="service-worker.js"
|
||||
APP_ID="13"
|
||||
DIRECTORY_LOCAL=newfreeplanet
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_VERSION="0.5.44"
|
||||
APP_VERSION="0.5.46"
|
||||
SERVICE_WORKER_FILE="service-worker.js"
|
||||
APP_ID="13"
|
||||
DIRECTORY_LOCAL="newfreeplanet"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_VERSION="0.5.44"
|
||||
APP_VERSION="0.5.46"
|
||||
SERVICE_WORKER_FILE="service-worker.js"
|
||||
APP_ID="13"
|
||||
DIRECTORY_LOCAL=newfreeplanet
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_VERSION="0.5.44"
|
||||
APP_VERSION="0.5.46"
|
||||
SERVICE_WORKER_FILE="service-worker.js"
|
||||
APP_ID="14"
|
||||
DIRECTORY_LOCAL="newfreeplanet"
|
||||
|
||||
19
src/App.ts
19
src/App.ts
@@ -75,29 +75,14 @@ export default {
|
||||
console.log('scrolled')
|
||||
}
|
||||
}
|
||||
|
||||
let displayMode = 'browser';
|
||||
const mqStandAlone = '(display-mode: standalone)';
|
||||
if (navigator)
|
||||
console.log('navigator')
|
||||
// @ts-ignore
|
||||
if (navigator && navigator.standalone)
|
||||
console.log('navigator.standalone')
|
||||
// @ts-ignore
|
||||
if (((navigator && (navigator.standalone))) ||
|
||||
(window.matchMedia(mqStandAlone).matches)) {
|
||||
console.log('navigator.standalone')
|
||||
displayMode = 'standalone'
|
||||
}
|
||||
|
||||
globalStore.isAppRunning = displayMode === 'standalone';
|
||||
console.log('isapp running = ', globalStore.isAppRunning)
|
||||
}
|
||||
|
||||
|
||||
function mounted() {
|
||||
darkcookie.value = tools.getCookie('darkmode', false, false, false) === '-1'
|
||||
|
||||
scroll()
|
||||
tools.checkApp()
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { defineComponent, ref, computed, PropType, toRef } from 'vue'
|
||||
import { defineComponent, ref, computed, PropType, toRef, onMounted } from 'vue'
|
||||
import { useUserStore } from '@store/UserStore'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useGlobalStore } from '@store/globalStore'
|
||||
@@ -19,36 +19,41 @@ export default defineComponent({
|
||||
const globalStore = useGlobalStore()
|
||||
const { t } = useI18n()
|
||||
|
||||
const deferredPrompt = ref(<any>null)
|
||||
|
||||
const isAppRunning = computed(() => globalStore.isAppRunning )
|
||||
|
||||
const finishLoading = computed(() => globalStore.finishLoading)
|
||||
|
||||
const deferredPrompt = computed(() => globalStore.deferredPrompt)
|
||||
|
||||
function initprompt() {
|
||||
window.addEventListener('beforeinstallprompt', (event) => {
|
||||
event.preventDefault()
|
||||
console.log('beforeinstallprompt !')
|
||||
// Stash the event so it can be triggered later.
|
||||
deferredPrompt.value = event
|
||||
globalStore.deferredPrompt = event
|
||||
})
|
||||
}
|
||||
|
||||
function installApp() {
|
||||
if (deferredPrompt.value)
|
||||
deferredPrompt.value.prompt()
|
||||
if (globalStore.deferredPrompt)
|
||||
globalStore.deferredPrompt.prompt()
|
||||
}
|
||||
|
||||
initprompt()
|
||||
function mounted() {
|
||||
initprompt()
|
||||
tools.checkApp()
|
||||
}
|
||||
|
||||
onMounted(mounted)
|
||||
|
||||
return {
|
||||
userStore,
|
||||
tools,
|
||||
costanti,
|
||||
finishLoading,
|
||||
deferredPrompt,
|
||||
installApp,
|
||||
isAppRunning,
|
||||
deferredPrompt,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -103,6 +103,8 @@ export default defineComponent({
|
||||
userStore.signin($router, signin.value)
|
||||
.then((riscode: any) => {
|
||||
console.log('signin FINITO CALL: riscode=', riscode)
|
||||
tools.checkApp()
|
||||
|
||||
if ($q.screen.lt.sm) {
|
||||
globalStore.setleftDrawerOpen(false)
|
||||
}
|
||||
|
||||
@@ -87,6 +87,7 @@ export default defineComponent({
|
||||
const isalreadyReg = ref(false)
|
||||
const needTelegram = ref(false)
|
||||
const slide = ref('1')
|
||||
const inputAportador = ref(<any>null)
|
||||
const inputEmail = ref(<any>null)
|
||||
const inputUsername = ref(<any>null)
|
||||
const inputName = ref(<any>null)
|
||||
@@ -98,7 +99,7 @@ export default defineComponent({
|
||||
let ret = true
|
||||
if (slide.value === '1') {
|
||||
// Invitante + Email
|
||||
ret = !signup.email || !v$.value.aportador_solidario || v$.value.aportador_solidario.$invalid || (inputEmail.value && inputEmail.value.hasError)
|
||||
ret = !signup.email || !signup.aportador_solidario || inputAportador.value.hasError || (inputEmail.value && inputEmail.value.hasError)
|
||||
} else if (slide.value === '2') {
|
||||
// Username
|
||||
ret = !signup.username || (inputUsername.value && inputUsername.value.hasError)
|
||||
@@ -391,6 +392,7 @@ export default defineComponent({
|
||||
needTelegram,
|
||||
slide,
|
||||
checkifDisabled,
|
||||
inputAportador,
|
||||
inputEmail,
|
||||
inputUsername,
|
||||
inputName,
|
||||
|
||||
@@ -113,6 +113,7 @@
|
||||
showaportador &&
|
||||
signup.aportador_solidario !== tools.APORTADOR_NONE
|
||||
"
|
||||
ref="inputAportador"
|
||||
bg-color="lightblue"
|
||||
:readonly="!!ap_iniziale"
|
||||
v-model="signup.aportador_solidario"
|
||||
|
||||
@@ -156,6 +156,7 @@ export default defineComponent({
|
||||
comune: 1,
|
||||
userId: 1,
|
||||
username: 1,
|
||||
name: 1,
|
||||
surname: 1,
|
||||
lasttimeonline: 1,
|
||||
mycities: 1,
|
||||
|
||||
@@ -34,7 +34,7 @@ export default function () {
|
||||
function getTeacherByUsername(username: string) {
|
||||
const op = getOperatorByUsername(username)
|
||||
if (!!op) {
|
||||
return op.name ? op.name : '' + ' ' + op.surname ? op.surname : ''
|
||||
return (op.name ? op.name : '') + ' ' + op.surname ? op.surname : ''
|
||||
} else {
|
||||
return ''
|
||||
}
|
||||
|
||||
@@ -457,6 +457,7 @@ export interface IGlobalState {
|
||||
myselector: ISelector,
|
||||
addNewRecord: string,
|
||||
isAppRunning: boolean
|
||||
deferredPrompt: any
|
||||
}
|
||||
|
||||
export interface IMenuList {
|
||||
|
||||
@@ -7394,6 +7394,27 @@ export const tools = {
|
||||
return myarr
|
||||
},
|
||||
|
||||
checkApp() {
|
||||
const globalStore = useGlobalStore()
|
||||
|
||||
try {
|
||||
let displayMode = 'browser';
|
||||
const mqStandAlone = '(display-mode: standalone)';
|
||||
// @ts-ignore
|
||||
if (((navigator && (navigator.standalone))) ||
|
||||
(window.matchMedia(mqStandAlone).matches)) {
|
||||
console.log('navigator.standalone')
|
||||
displayMode = 'standalone'
|
||||
}
|
||||
console.log('displayMode = ', displayMode)
|
||||
|
||||
globalStore.isAppRunning = displayMode === 'standalone';
|
||||
} catch (e) {
|
||||
console.log('error navigator.standalone ?!')
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
// getLocale() {
|
||||
// if (navigator.languages && navigator.languages.length > 0) {
|
||||
// return navigator.languages[0]
|
||||
|
||||
@@ -449,12 +449,12 @@ export const useUserStore = defineStore('UserStore', {
|
||||
let myrec = this.getRecByCol(user, col)
|
||||
|
||||
if (!!myrec.name)
|
||||
name = myrec.name
|
||||
name = myrec.name + ' '
|
||||
if (!!myrec.surname)
|
||||
name += ' ' + myrec.surname
|
||||
name += myrec.surname + ' '
|
||||
|
||||
if (!name) {
|
||||
name = myrec.username
|
||||
name += myrec.username + ' '
|
||||
}
|
||||
if (col && col.field === 'extrarec' && !name) {
|
||||
name = myrec.dest
|
||||
@@ -996,6 +996,8 @@ export const useUserStore = defineStore('UserStore', {
|
||||
|
||||
await globalStore.clearDataAfterLogout()
|
||||
|
||||
tools.checkApp()
|
||||
|
||||
return Api.SendReq('/users/me/token', 'DELETE', null)
|
||||
.then((res) => {
|
||||
console.log(res)
|
||||
|
||||
@@ -183,6 +183,7 @@ export const useGlobalStore = defineStore('GlobalStore', {
|
||||
myselector: { data: {}, table: ''},
|
||||
addNewRecord: '',
|
||||
isAppRunning: false,
|
||||
deferredPrompt: null,
|
||||
}),
|
||||
|
||||
getters: {
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
<div v-if="site.confpages.showNameSurname">
|
||||
<div class="text-h6">
|
||||
<span v-if="checkifShow('name') && myuser.name"> {{ myuser.name }}</span>
|
||||
<span v-if="checkifShow('surname') && myuser.surname">{{
|
||||
<span v-if="checkifShow('surname') && myuser.surname"> {{
|
||||
myuser.surname
|
||||
}}</span>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user