2021-03-17 11:29:01 +00:00
|
|
|
<script>
|
2021-04-05 09:29:28 +00:00
|
|
|
import EventBus from '@/AppEventBus';
|
2021-03-17 11:29:01 +00:00
|
|
|
import LiveEditor from './views/liveeditor/LiveEditor';
|
|
|
|
import { services, data } from './views/liveeditor/LiveEditorData';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'appdoc',
|
|
|
|
props: {
|
|
|
|
name: null,
|
|
|
|
sources: null,
|
|
|
|
service: null,
|
|
|
|
data: null,
|
|
|
|
dependencies: null,
|
2021-03-25 09:04:37 +00:00
|
|
|
extPages: null,
|
2021-03-31 12:28:03 +00:00
|
|
|
extFiles: null,
|
2021-04-05 09:29:28 +00:00
|
|
|
component: null,
|
|
|
|
github: null
|
|
|
|
},
|
2021-04-15 14:53:33 +00:00
|
|
|
viewGithubListener: null,
|
2021-04-05 09:29:28 +00:00
|
|
|
mounted() {
|
2021-04-15 14:53:33 +00:00
|
|
|
this.viewGithubListener = () => {
|
2021-04-05 09:29:28 +00:00
|
|
|
window.open('https://github.com/primefaces/primevue/blob/master/src/views/' + this.github, '_blank');
|
2021-04-15 14:53:33 +00:00
|
|
|
};
|
|
|
|
EventBus.on('view-github', this.viewGithubListener);
|
2021-04-05 09:29:28 +00:00
|
|
|
},
|
|
|
|
beforeUnmount() {
|
2021-04-15 14:53:33 +00:00
|
|
|
EventBus.off('view-github', this.viewGithubListener);
|
2021-03-17 11:29:01 +00:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
renderPanels() {
|
|
|
|
let tabs = [];
|
|
|
|
|
|
|
|
if (this.$slots.default) {
|
|
|
|
tabs.push(<TabPanel header="Documentation">{this.$slots.default()}</TabPanel>);
|
|
|
|
}
|
|
|
|
|
2021-04-05 09:29:28 +00:00
|
|
|
this.renderSource('options-api', tabs);
|
|
|
|
this.renderSource('composition-api', tabs);
|
2021-03-17 11:29:01 +00:00
|
|
|
|
|
|
|
if (this.service) {
|
2021-03-23 10:47:50 +00:00
|
|
|
let serviceArr = [];
|
|
|
|
|
|
|
|
this.service.forEach(el => {
|
|
|
|
serviceArr.push(el.split(','))
|
|
|
|
})
|
2021-03-17 11:29:01 +00:00
|
|
|
/* eslint-disable */
|
2021-03-23 10:47:50 +00:00
|
|
|
serviceArr.forEach((el, i) => {
|
|
|
|
tabs.push(
|
2021-04-05 09:29:28 +00:00
|
|
|
<TabPanel key={el} header={`${el}.js`}>
|
2021-03-23 10:47:50 +00:00
|
|
|
<pre v-code="script"><code>
|
|
|
|
{services[el]}
|
|
|
|
</code></pre>
|
|
|
|
</TabPanel>
|
|
|
|
);
|
|
|
|
})
|
2021-03-17 11:29:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (this.data) {
|
2021-03-22 14:08:02 +00:00
|
|
|
let dataArr = [];
|
|
|
|
|
|
|
|
this.data.forEach(el => {
|
|
|
|
dataArr.push(el.split(','))
|
|
|
|
})
|
|
|
|
|
2021-03-17 11:29:01 +00:00
|
|
|
dataArr.forEach((el, i) => {
|
|
|
|
tabs.push(
|
|
|
|
<TabPanel key={`${el}_i`} header={`${el}.json`}>
|
|
|
|
<pre v-code="script" style={{maxHeight: '500px'}}><code>
|
|
|
|
{data[el]}
|
|
|
|
</code></pre>
|
|
|
|
</TabPanel>
|
|
|
|
)
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return tabs;
|
2021-04-05 09:29:28 +00:00
|
|
|
},
|
|
|
|
renderSource(sourceType, tabs) {
|
|
|
|
if (this.sources && this.sources[sourceType]) {
|
|
|
|
tabs.push(
|
|
|
|
<TabPanel key={sourceType} header={this.sources[sourceType].tabName}>
|
|
|
|
<pre v-code><code>
|
2021-04-06 09:16:59 +00:00
|
|
|
{this.sources[sourceType].content.replace('<\\/script>', '<\/script>')}
|
2021-04-05 09:29:28 +00:00
|
|
|
</code></pre>
|
|
|
|
</TabPanel>
|
|
|
|
);
|
|
|
|
}
|
2021-03-17 11:29:01 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
render() {
|
|
|
|
return (
|
2021-04-05 09:29:28 +00:00
|
|
|
<div class="content-section documentation" id="app-doc">
|
|
|
|
<LiveEditor name={this.name} sources={this.sources} service={this.service} data={this.data} dependencies={this.dependencies} extPages={this.extPages} extFiles={this.extFiles} component={this.component} />
|
2021-03-17 11:29:01 +00:00
|
|
|
<TabView>
|
|
|
|
{
|
|
|
|
this.renderPanels()
|
|
|
|
}
|
|
|
|
</TabView>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|