Workplace Widget 5.10.5
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
<script setup lang="ts">
|
||||
import {computed, ref, watch, onBeforeUnmount} from 'vue';
|
||||
import type {HmiWidget} from '../types';
|
||||
import {shouldAutoStartWidget} from './cheerpjAutoStart';
|
||||
|
||||
const props = defineProps<{widget:HmiWidget;demo:boolean}>();
|
||||
const url = computed(()=>String(props.widget.props.jnlpUrl||'').trim());
|
||||
const workplace = computed(()=>props.widget.type==='ui.cheerpj-workplace');
|
||||
const autoStartEnabled = computed(()=>shouldAutoStartWidget(props.widget.type,props.widget.props));
|
||||
const javaVersion = computed(()=>[8,11,17].includes(Number(props.widget.props.javaVersion))?Number(props.widget.props.javaVersion):8);
|
||||
const windowProtocolWarning = window.location.protocol==='http:' && !['localhost','127.0.0.1'].includes(window.location.hostname);
|
||||
const displayMode = computed(()=>['fit','original'].includes(String(props.widget.props.displayMode))?String(props.widget.props.displayMode):'fit');
|
||||
@@ -49,10 +51,16 @@ function onMessage(e:MessageEvent){
|
||||
status.value=String(data.message||'').slice(0,350);
|
||||
if(data.state==='error')failure.value=status.value;
|
||||
}
|
||||
watch([url,javaVersion,displayMode],stop);
|
||||
watch(()=>props.demo, v=>{if(v)stop();},{immediate:true});
|
||||
watch(()=>[props.demo,props.widget.props.autoStart,url.value] as const,([demo,auto,jnlp])=>{
|
||||
if(!demo&&auto===true&&jnlp&&!launchRequested.value)launch();
|
||||
// The workplace starts automatically in runtime, also for legacy templates with autoStart:false.
|
||||
// The designer never starts a VM. A manual stop lasts until the widget/page is reopened.
|
||||
watch([url,javaVersion,displayMode],()=>{
|
||||
if(!launchRequested.value)return;
|
||||
stop();
|
||||
if(!props.demo && autoStartEnabled.value && url.value)launch();
|
||||
});
|
||||
watch(()=>[props.demo,autoStartEnabled.value,url.value] as const,([demo,enabled,jnlp])=>{
|
||||
if(demo || !enabled){ if(launchRequested.value)stop(); return; }
|
||||
if(jnlp&&!launchRequested.value)launch();
|
||||
},{immediate:true});
|
||||
window.addEventListener('message',onMessage);
|
||||
onBeforeUnmount(()=>window.removeEventListener('message',onMessage));
|
||||
|
||||
Reference in New Issue
Block a user