/**
 * AI写作页面 Store
 */
import { defineStore } from 'pinia'

type currentRightMenu = 0 | 1 | 2 // 0 = 写作 1 = 润色 2 = 助手
type currentAiWritingStep = 0 | 1 | 2 | 3 // 0 = 选择场景 1 = 基础信息 2 = 大纲信息 2 = 参考文档
type currentSceneType = 0 | 1 // 0 = 法定公文类 1 = 事务公文类
type currentScene = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 // 跟formConfig.js 中的 sceneConfig 对应
type currentPolish = 0 | 1 | 2 | 3 // 0 = 生成标题 1 = 润色 2 = 扩写 2 = 缩写

export interface docsStateTypes {
  currentRightMenu: currentRightMenu
  currentAiWritingStep: currentAiWritingStep
  currentSceneType: currentSceneType
  currentScene: currentScene
  currentPolish: currentPolish
  document_id: string
  outlineId: string
  aiLoadingText: string
  modelId: string
  auditLoading: boolean
  auditLoadingText: string
  auditLoadingStatus: string
}

const useDocsStore = defineStore({
  id: 'docs',
  state: (): docsStateTypes => ({
    currentRightMenu: 0, // 当前最右侧菜单当前
    currentAiWritingStep: 0, // 当前写作步骤
    currentSceneType: 0, // 当前场景类型
    currentScene: 0, // 当前场景
    currentPolish: 0, // 当前润色场景
    document_id: '', // 当前文档ID
    outlineId: '', // 当前大纲ID
    aiLoadingText: 'AI正在生成文章',
    modelId: '', // 当前模型ID
    auditLoadingText: 'AI正在审核文章', // 智能审核加载文案
    auditLoading: false, // 智能审核加载状态
    auditLoadingStatus: '', // 智能审核加载状态
  }),
  actions: {
    setCurrentRightMenu(val: currentRightMenu) {
      this.currentRightMenu = val
    },
    setCurrentAiWritingStep(val: currentAiWritingStep) {
      this.currentAiWritingStep = val
    },
    setCurrentSceneType(val: currentSceneType) {
      this.currentSceneType = val
    },
    setCurrentScene(val: currentScene) {
      this.currentScene = val
    },
    setCurrentPolish(val: currentPolish) {
      this.currentPolish = val
    },
    setDocumentId(val: string) {
      this.document_id = val
    },
    setOutlineId(val: string) {
      this.outlineId = val
    },
    setAiLoadingText(val: string) {
      this.aiLoadingText = val
    },
    setModelId(val: string) {
      this.modelId = val
    },
    setAuditLoadingStatus(val: string) {
      this.auditLoadingStatus = val
    },
    setAuditLoadingText(val: string) {
      this.auditLoading = !!val
      this.auditLoadingText = val
    },
    resetData() {
      this.currentRightMenu = 0 // 当前最右侧菜单当前
      this.currentAiWritingStep = 0 // 当前写作步骤
      this.currentSceneType = 0 // 当前场景类型
      this.currentScene = 0 // 当前场景
      this.currentPolish = 0 // 当前润色场景
      this.document_id = '' // 当前文档ID
      this.outlineId = '' // 当前大纲ID
      this.aiLoadingText = '' // 当前大纲ID
    }
  }
})

export default useDocsStore
