2020-06-28 06:33:20 +09:00
|
|
|
<template>
|
|
|
|
<div>
|
2020-07-03 10:42:43 +09:00
|
|
|
<h3>{{ translatedCode.title }}</h3>
|
2020-06-28 06:33:20 +09:00
|
|
|
<div class="metadata">
|
2020-07-10 07:57:16 +09:00
|
|
|
<span>
|
2020-07-10 07:59:26 +09:00
|
|
|
{{ getLabel('codeinfo.version') }} {{ translatedCode.version }} ({{ translatedCode.date }})
|
2020-07-10 07:57:16 +09:00
|
|
|
</span>
|
2020-07-10 07:59:26 +09:00
|
|
|
<span v-if="code.author.includes(',')"
|
|
|
|
>{{ getLabel('codeinfo.authors') }} {{ translatedCode.author }}</span
|
|
|
|
>
|
2020-07-03 10:42:43 +09:00
|
|
|
<span v-else>{{ getLabel('codeinfo.author') }} {{ translatedCode.author }}</span>
|
2020-06-28 06:33:20 +09:00
|
|
|
</div>
|
2022-10-15 19:31:18 +09:00
|
|
|
<Preview v-if="showPreview" :config="previewConfig" />
|
2020-07-03 10:42:43 +09:00
|
|
|
<p class="description" v-html="translatedCode.description"></p>
|
2022-10-07 23:02:40 +09:00
|
|
|
<component v-if="configUI" :is="configUI" :version="version"
|
2022-10-15 19:31:18 +09:00
|
|
|
:previewConfig="previewConfig" @config="$emit('config', {[code.id]: $event})" />
|
2020-06-28 06:33:20 +09:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2020-07-03 10:42:43 +09:00
|
|
|
import { translate, translateCode } from '../i18n/localeHelper';
|
2023-02-05 23:25:44 +09:00
|
|
|
import { previewIds } from './codes/preview.js';
|
2022-04-08 12:48:37 +09:00
|
|
|
import configUIs from './codes/ui.js';
|
2020-07-03 10:42:43 +09:00
|
|
|
|
2020-06-28 06:33:20 +09:00
|
|
|
export default {
|
|
|
|
props: {
|
2020-06-29 03:04:31 +09:00
|
|
|
anchor: { type: Boolean },
|
2020-06-28 06:33:20 +09:00
|
|
|
code: { type: Object },
|
2022-04-08 12:48:37 +09:00
|
|
|
version: { type: String },
|
2022-10-15 19:31:18 +09:00
|
|
|
previewConfig: { type: Object },
|
2020-06-28 06:33:20 +09:00
|
|
|
},
|
2020-07-10 07:57:16 +09:00
|
|
|
computed: {
|
2020-07-10 07:59:26 +09:00
|
|
|
translatedCode: function () {
|
2020-07-10 09:39:45 +09:00
|
|
|
return translateCode(this.code, this.$lang);
|
2020-07-10 07:59:26 +09:00
|
|
|
},
|
2022-04-08 12:48:37 +09:00
|
|
|
configUI: function () {
|
|
|
|
return configUIs[this.code.id];
|
|
|
|
},
|
2022-10-15 19:31:18 +09:00
|
|
|
showPreview() {
|
2023-02-05 23:25:44 +09:00
|
|
|
return previewIds.includes(this.code.id);
|
2022-10-15 19:31:18 +09:00
|
|
|
},
|
2020-07-03 10:42:43 +09:00
|
|
|
},
|
2020-06-29 03:04:31 +09:00
|
|
|
data() {
|
2020-07-10 07:57:16 +09:00
|
|
|
return {};
|
2020-06-29 03:04:31 +09:00
|
|
|
},
|
2020-07-03 10:42:43 +09:00
|
|
|
methods: {
|
|
|
|
getLabel(key) {
|
|
|
|
return translate(key, this.$lang);
|
|
|
|
},
|
|
|
|
},
|
2020-06-28 06:33:20 +09:00
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
.metadata span {
|
|
|
|
display: block;
|
|
|
|
font-style: italic;
|
|
|
|
font-size: 0.9rem;
|
|
|
|
}
|
|
|
|
|
|
|
|
.description td {
|
|
|
|
padding: 0;
|
|
|
|
}
|
|
|
|
</style>
|