<script setup lang="ts">
import { ref } from "vue"
import contentConfig from "./config/content.config";
import searchConfig from "./config/search.config"
import { usePageSearch, type PageHooks } from "/@/hooks/page";
import { useRenderIcon } from "/@/components/ReIcon/src/hooks";
import ContentModal from "./contentModal.vue"

const PageName = "publish";
const currentContent = ref({})
const visible = ref(false)

const hooks: PageHooks = { pageSearchHook: () => usePageSearch(undefined, undefined, searchConfig) };

function handlePreview(row) { 
  currentContent.value = JSON.parse(row.content || "{}")
  visible.value = true
}
</script>

<template>
  <PageAuth :pageName="PageName">
    <PageContainer
      :hooks="hooks"
      :searchConfig="searchConfig" 
      :content-config="contentConfig" 
    >
      <template #content_action="row">
        <ElTooltip content="查看推送内容" placement="top">
          <ElButton
            @click="handlePreview(row)"
            :icon="useRenderIcon('eye-view')"
            type="primary" 
            size="small"
            link 
          />
        </ElTooltip>
      </template>
    </PageContainer>

    <ContentModal :content="currentContent" v-model:visible="visible" />
  </PageAuth>
</template>
