2019-04-29 00:11:57 +00:00
|
|
|
<template>
|
2019-04-29 06:17:31 +00:00
|
|
|
<div class="hkcxmtwj">
|
2021-08-06 13:29:19 +00:00
|
|
|
<MkSwitch :model-value="value" @update:modelValue="updateValue($event)">{{ hpml.interpolate(block.text) }}</MkSwitch>
|
2019-04-29 00:11:57 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2021-01-30 01:59:05 +00:00
|
|
|
import { computed, defineComponent, PropType } from 'vue';
|
2021-09-29 15:50:45 +00:00
|
|
|
import MkSwitch from '../form/switch.vue';
|
2021-11-11 17:02:25 +00:00
|
|
|
import * as os from '@/os';
|
|
|
|
import { Hpml } from '@/scripts/hpml/evaluator';
|
|
|
|
import { SwitchVarBlock } from '@/scripts/hpml/block';
|
2019-04-29 00:11:57 +00:00
|
|
|
|
2020-10-17 11:12:00 +00:00
|
|
|
export default defineComponent({
|
2020-01-29 19:37:25 +00:00
|
|
|
components: {
|
|
|
|
MkSwitch
|
|
|
|
},
|
2019-04-29 00:11:57 +00:00
|
|
|
props: {
|
2021-01-30 01:59:05 +00:00
|
|
|
block: {
|
|
|
|
type: Object as PropType<SwitchVarBlock>,
|
2019-04-29 00:11:57 +00:00
|
|
|
required: true
|
|
|
|
},
|
2020-04-20 12:35:27 +00:00
|
|
|
hpml: {
|
2021-01-30 01:59:05 +00:00
|
|
|
type: Object as PropType<Hpml>,
|
2019-04-29 00:11:57 +00:00
|
|
|
required: true
|
|
|
|
}
|
|
|
|
},
|
2021-01-30 01:59:05 +00:00
|
|
|
setup(props, ctx) {
|
|
|
|
const value = computed(() => {
|
|
|
|
return props.hpml.vars.value[props.block.name];
|
|
|
|
});
|
|
|
|
|
|
|
|
function updateValue(newValue: boolean) {
|
|
|
|
props.hpml.updatePageVar(props.block.name, newValue);
|
|
|
|
props.hpml.eval();
|
|
|
|
}
|
|
|
|
|
2019-04-29 00:11:57 +00:00
|
|
|
return {
|
2021-01-30 01:59:05 +00:00
|
|
|
value,
|
|
|
|
updateValue
|
2019-04-29 00:11:57 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
2019-04-29 06:17:31 +00:00
|
|
|
|
2020-01-29 19:37:25 +00:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
.hkcxmtwj {
|
|
|
|
display: inline-block;
|
|
|
|
margin: 16px auto;
|
2019-04-29 22:41:57 +00:00
|
|
|
|
2020-01-29 19:37:25 +00:00
|
|
|
& + .hkcxmtwj {
|
|
|
|
margin-left: 16px;
|
|
|
|
}
|
|
|
|
}
|
2019-04-29 06:17:31 +00:00
|
|
|
</style>
|