ページのソースを見れるように

This commit is contained in:
syuilo 2019-05-01 20:48:56 +09:00
parent 76c538ad25
commit 79c49bc926
No known key found for this signature in database
GPG key ID: BDC4C49D06AB9D69
7 changed files with 113 additions and 27 deletions

View file

@ -159,8 +159,9 @@ init(async (launch, os) => {
{ path: '/i/pages', component: () => import('./views/home/pages.vue').then(m => m.default) },
]},
{ path: '/@:user/pages/:page', props: true, component: () => import('./views/pages/page.vue').then(m => m.default) },
{ path: '/@:user/pages/:pageName/view-source', props: true, component: () => import('./views/pages/page-editor.vue').then(m => m.default) },
{ path: '/i/pages/new', component: () => import('./views/pages/page-editor.vue').then(m => m.default) },
{ path: '/i/pages/edit/:page', props: true, component: () => import('./views/pages/page-editor.vue').then(m => m.default) },
{ path: '/i/pages/edit/:pageId', props: true, component: () => import('./views/pages/page-editor.vue').then(m => m.default) },
{ path: '/i/messaging/:user', component: MkMessagingRoom },
{ path: '/i/drive', component: MkDrive },
{ path: '/i/drive/folder/:folder', component: MkDrive },

View file

@ -1,7 +1,7 @@
<template>
<mk-ui>
<main>
<x-page-editor :page="page"/>
<x-page-editor v-if="page !== undefined" :page="page" :readonly="readonly"/>
</main>
</mk-ui>
</template>
@ -15,9 +15,44 @@ export default Vue.extend({
},
props: {
page: {
pageId: {
type: String,
required: false
},
pageName: {
type: String,
required: false
},
user: {
type: String,
required: false
}
},
data() {
return {
page: undefined,
readonly: false
};
},
created() {
if (this.pageId) {
this.$root.api('pages/show', {
pageId: this.pageId,
}).then(page => {
this.page = page;
});
} else if (this.pageName && this.user) {
this.$root.api('pages/show', {
name: this.pageName,
username: this.user,
}).then(page => {
this.readonly = true;
this.page = page;
});
} else {
this.page = null;
}
}
});