mirror of
https://github.com/Floriansylvain/RenewCMS.git
synced 2026-08-19 11:43:22 +02:00
Article edition now getting article from DB by ID
This commit is contained in:
@@ -44,7 +44,7 @@ const router = createRouter({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/articles/edit/:articleID?',
|
path: '/articles/edit/:articleID',
|
||||||
name: 'edition',
|
name: 'edition',
|
||||||
component: ArticlesEdit,
|
component: ArticlesEdit,
|
||||||
meta: {
|
meta: {
|
||||||
@@ -53,10 +53,10 @@ const router = createRouter({
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/articles/new',
|
path: '/articles/new',
|
||||||
name: 'edition',
|
name: 'new',
|
||||||
component: ArticlesNew,
|
component: ArticlesNew,
|
||||||
meta: {
|
meta: {
|
||||||
title: 'GohCMS - Edition'
|
title: 'GohCMS - Nouveau'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
import { useAuthStore } from "@/stores/AuthStore"
|
||||||
|
|
||||||
|
export interface Article {
|
||||||
|
idName: string,
|
||||||
|
date: number,
|
||||||
|
content: {
|
||||||
|
html: string
|
||||||
|
},
|
||||||
|
pageId: string,
|
||||||
|
online: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
const baseURL = `http://${__APP_ENV__.APP_HOST_ADDRESS}:${__APP_ENV__.APP_API_PORT}`
|
||||||
|
|
||||||
|
export async function getArticle(id: string) : Promise<Article> {
|
||||||
|
return await fetch(`${baseURL}/articles/${id}`, {
|
||||||
|
method: 'GET',
|
||||||
|
headers: { "Authorization": `Bearer ${useAuthStore().token}` }
|
||||||
|
})
|
||||||
|
.then(result => result.json())
|
||||||
|
.catch(error => {
|
||||||
|
console.error(error)
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -1,11 +1,17 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { getArticle, type Article } from '@/utils/database';
|
||||||
import Editor from '@tinymce/tinymce-vue';
|
import Editor from '@tinymce/tinymce-vue';
|
||||||
import { ref, type Ref } from 'vue';
|
import { onMounted, ref, type Ref } from 'vue';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
|
|
||||||
const articleID = useRoute().params.articleID
|
let article: Ref<Article | void> = ref()
|
||||||
const editorData: Ref<string> = ref('')
|
const editorData: Ref<string> = ref('')
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
article.value = await getArticle(useRoute().params.articleID as string)
|
||||||
|
editorData.value = article.value.content.html
|
||||||
|
})
|
||||||
|
|
||||||
function abort() {
|
function abort() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user