<!-- 体系文件流 -->
<script name="FileStream" lang="ts" setup>
import { ElMessage } from 'element-plus'

// 从路由中传过来的参数
const filename = ref<string>('')
const title = ref<string>('')

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

// 逻辑
// 关闭
const resetForm = () => {
  sessionStorage.removeItem('fileInfo')
  router.go(-1)
}

const initDialog = (params: any) => {
  // 从路由中获取参数
  title.value = params.title !== undefined ? `${params.title} - ` : ''

  const fileInfo = JSON.parse(sessionStorage.getItem('fileInfo')!)
  title.value += fileInfo.fileName
  filename.value = fileInfo.file

  ElMessage.success(filename.value)
}

onMounted(() => {
  initDialog(route.query)
})
</script>

<template>
  <app-container>
    <detail-page :title="title">
      <template #btns>
        <el-button type="info" @click="resetForm()">
          关闭
        </el-button>
      </template>
    </detail-page>
  </app-container>
</template>
