2019-04-29 00:11:57 +00:00
|
|
|
<template>
|
|
|
|
<div>
|
2021-11-19 10:36:12 +00:00
|
|
|
<MkButton class="kudkigyw" :primary="block.primary" @click="click()">{{ hpml.interpolate(block.text) }}</MkButton>
|
2019-04-29 00:11:57 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2021-01-30 01:59:05 +00:00
|
|
|
import { defineComponent, PropType, unref } from 'vue';
|
2020-01-29 19:37:25 +00:00
|
|
|
import MkButton from '../ui/button.vue';
|
2021-11-11 17:02:25 +00:00
|
|
|
import * as os from '@/os';
|
|
|
|
import { ButtonBlock } from '@/scripts/hpml/block';
|
|
|
|
import { Hpml } from '@/scripts/hpml/evaluator';
|
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: {
|
|
|
|
MkButton
|
|
|
|
},
|
2019-04-29 00:11:57 +00:00
|
|
|
props: {
|
2021-01-30 01:59:05 +00:00
|
|
|
block: {
|
|
|
|
type: Object as PropType<ButtonBlock>,
|
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
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
click() {
|
2021-01-30 01:59:05 +00:00
|
|
|
if (this.block.action === 'dialog') {
|
2020-04-20 12:35:27 +00:00
|
|
|
this.hpml.eval();
|
2021-11-18 09:45:58 +00:00
|
|
|
os.alert({
|
2021-01-30 01:59:05 +00:00
|
|
|
text: this.hpml.interpolate(this.block.content)
|
2019-04-29 00:11:57 +00:00
|
|
|
});
|
2021-01-30 01:59:05 +00:00
|
|
|
} else if (this.block.action === 'resetRandom') {
|
2020-04-20 12:35:27 +00:00
|
|
|
this.hpml.updateRandomSeed(Math.random());
|
|
|
|
this.hpml.eval();
|
2021-01-30 01:59:05 +00:00
|
|
|
} else if (this.block.action === 'pushEvent') {
|
2020-10-17 11:12:00 +00:00
|
|
|
os.api('page-push', {
|
2020-04-20 12:35:27 +00:00
|
|
|
pageId: this.hpml.page.id,
|
2021-01-30 01:59:05 +00:00
|
|
|
event: this.block.event,
|
|
|
|
...(this.block.var ? {
|
|
|
|
var: unref(this.hpml.vars)[this.block.var]
|
2019-07-06 20:12:31 +00:00
|
|
|
} : {})
|
2019-07-06 09:14:50 +00:00
|
|
|
});
|
|
|
|
|
2021-11-18 09:45:58 +00:00
|
|
|
os.alert({
|
2019-07-06 09:14:50 +00:00
|
|
|
type: 'success',
|
2021-01-30 01:59:05 +00:00
|
|
|
text: this.hpml.interpolate(this.block.message)
|
2019-07-06 09:14:50 +00:00
|
|
|
});
|
2021-01-30 01:59:05 +00:00
|
|
|
} else if (this.block.action === 'callAiScript') {
|
|
|
|
this.hpml.callAiScript(this.block.fn);
|
2019-04-29 00:11:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2020-01-29 19:37:25 +00:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
.kudkigyw {
|
|
|
|
display: inline-block;
|
|
|
|
min-width: 200px;
|
|
|
|
max-width: 450px;
|
|
|
|
margin: 8px 0;
|
|
|
|
}
|
2019-04-29 00:11:57 +00:00
|
|
|
</style>
|