2019-04-29 02:11:57 +02:00
|
|
|
<template>
|
2020-04-20 14:35:27 +02:00
|
|
|
<div class="iroscrza" :class="{ center: page.alignCenter, serif: page.font === 'serif' }" v-if="hpml">
|
|
|
|
<x-block v-for="child in page.content" :value="child" @input="v => updateBlock(v)" :page="page" :hpml="hpml" :key="child.id" :h="2"/>
|
2019-04-29 02:11:57 +02:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
2020-04-20 14:35:27 +02:00
|
|
|
import { parse } from '@syuilo/aiscript';
|
2019-05-17 12:56:47 +02:00
|
|
|
import { faHeart as faHeartS } from '@fortawesome/free-solid-svg-icons';
|
2019-07-06 23:56:13 +02:00
|
|
|
import { faHeart } from '@fortawesome/free-regular-svg-icons';
|
2019-04-29 02:11:57 +02:00
|
|
|
import XBlock from './page.block.vue';
|
2020-04-20 14:35:27 +02:00
|
|
|
import { Hpml } from '../../scripts/hpml/evaluator';
|
2020-01-29 20:37:25 +01:00
|
|
|
import { url } from '../../config';
|
2019-04-29 02:11:57 +02:00
|
|
|
|
|
|
|
export default Vue.extend({
|
|
|
|
components: {
|
|
|
|
XBlock
|
|
|
|
},
|
|
|
|
|
|
|
|
props: {
|
2019-07-06 23:56:13 +02:00
|
|
|
page: {
|
|
|
|
type: Object,
|
2019-04-29 02:11:57 +02:00
|
|
|
required: true
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
2020-04-20 14:35:27 +02:00
|
|
|
hpml: null,
|
2019-05-17 12:56:47 +02:00
|
|
|
faHeartS, faHeart
|
2019-04-29 02:11:57 +02:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
created() {
|
2020-04-20 14:35:27 +02:00
|
|
|
this.hpml = new Hpml(this, this.page, {
|
2019-07-06 23:56:13 +02:00
|
|
|
randomSeed: Math.random(),
|
|
|
|
visitor: this.$store.state.i,
|
2020-04-13 16:46:53 +02:00
|
|
|
url: url,
|
|
|
|
enableAiScript: !this.$store.state.device.disablePagesScript
|
2019-07-06 23:56:13 +02:00
|
|
|
});
|
2019-04-29 02:11:57 +02:00
|
|
|
},
|
|
|
|
|
2020-04-15 17:39:21 +02:00
|
|
|
mounted() {
|
|
|
|
this.$nextTick(() => {
|
2020-04-20 14:35:27 +02:00
|
|
|
if (this.page.script && this.hpml.aiscript) {
|
2020-04-15 17:39:21 +02:00
|
|
|
let ast;
|
|
|
|
try {
|
2020-04-20 14:35:27 +02:00
|
|
|
ast = parse(this.page.script);
|
2020-04-15 17:39:21 +02:00
|
|
|
} catch (e) {
|
|
|
|
console.error(e);
|
|
|
|
/*this.$root.dialog({
|
|
|
|
type: 'error',
|
|
|
|
text: 'Syntax error :('
|
|
|
|
});*/
|
|
|
|
return;
|
|
|
|
}
|
2020-04-20 14:35:27 +02:00
|
|
|
this.hpml.aiscript.exec(ast).then(() => {
|
|
|
|
this.hpml.eval();
|
2020-04-15 17:39:21 +02:00
|
|
|
}).catch(e => {
|
|
|
|
console.error(e);
|
|
|
|
/*this.$root.dialog({
|
|
|
|
type: 'error',
|
|
|
|
text: e
|
|
|
|
});*/
|
|
|
|
});
|
|
|
|
} else {
|
2020-04-20 14:35:27 +02:00
|
|
|
this.hpml.eval();
|
2020-04-15 17:39:21 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2020-04-13 16:46:53 +02:00
|
|
|
beforeDestroy() {
|
2020-04-20 14:35:27 +02:00
|
|
|
if (this.hpml.aiscript) this.hpml.aiscript.abort();
|
2020-04-13 16:46:53 +02:00
|
|
|
},
|
2019-04-29 02:11:57 +02:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2020-01-29 20:37:25 +01:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
.iroscrza {
|
|
|
|
&.serif {
|
|
|
|
> div {
|
|
|
|
font-family: serif;
|
|
|
|
}
|
|
|
|
}
|
2019-04-29 02:11:57 +02:00
|
|
|
|
2020-01-29 20:37:25 +01:00
|
|
|
&.center {
|
|
|
|
text-align: center;
|
|
|
|
}
|
|
|
|
}
|
2019-04-29 02:11:57 +02:00
|
|
|
</style>
|