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