Commit fd970a17 authored by 前端-许佳敏's avatar 前端-许佳敏

新增判断页面状态hooks

parent c2d92ecf
import { history } from 'umi'
import { useState } from 'react'
export enum PageStatus {
ADD,
EDIT,
PREVIEW
}
export const usePageStatus = () => {
const { preview, id = '' } = history.location.query
// 默认预览状态
let pageStatus = PageStatus.PREVIEW
if (preview === '1') {
pageStatus = PageStatus.PREVIEW
} else {
if (id) {
pageStatus = PageStatus.EDIT
} else {
pageStatus = PageStatus.ADD
}
}
return {
pageStatus,
id,
preview
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment