<template>
  <ArticleAdd 
    :article-id="articleId"
    :show-back-button="true"
    back-button-text="返回"
    @back="handleBack"
    @publish-success="handlePublishSuccess"
    @save-draft-success="handleSaveDraftSuccess"
  />
</template>

<script setup lang="ts">
import { computed } from 'vue';
import { useRouter, useRoute } from 'vue-router';
import { ArticleAdd } from './components';

defineOptions({
  name: 'ArticleAddView'
});

const router = useRouter();
const route = useRoute();

const articleId = computed(() => route.query.id as string | undefined);

// 返回上一页
function handleBack() {
  router.back();
}

// 发布成功后跳转到文章详情页
function handlePublishSuccess(id: string) {
  router.push({
    path: '/article/show',
    query: { articleId: id }
  });
}

// 保存草稿成功
function handleSaveDraftSuccess() {
  // 可以添加其他逻辑
  console.log('草稿已保存');
}
</script>

<style lang="scss" scoped>
</style>
