|
@@ -6,7 +6,7 @@ import { formatDistanceToNow, parseISO } from 'date-fns'
|
|
|
import zh from 'date-fns/locale/zh-CN'
|
|
|
|
|
|
import { EditScene } from './edit-scene'
|
|
|
-import { Card, Col, Avatar, Modal } from 'antd'
|
|
|
+import { Card, Col, Avatar, Modal, List, Skeleton } from 'antd'
|
|
|
import { EditOutlined, PaperClipOutlined, DeleteOutlined, ExclamationCircleOutlined, SettingOutlined } from '@ant-design/icons';
|
|
|
import style from './style.module.css'
|
|
|
import { useHistory } from 'react-router'
|
|
@@ -26,45 +26,50 @@ const confirm = (msg: string) => {
|
|
|
})
|
|
|
};
|
|
|
|
|
|
-const useSceneLinks = (scene: Scene) => {
|
|
|
+export const useSceneLinks = (scene: Scene) => {
|
|
|
const history = useHistory()
|
|
|
const goto = (link: string) => () => window.location.href = link
|
|
|
|
|
|
switch (scene.type) {
|
|
|
case SceneType.GIS:
|
|
|
return {
|
|
|
- gotoScene: goto(`http://data3d.4dage.com?sid=${scene.id}`),
|
|
|
+ gotoScene: `http://data3d.4dage.com?sid=${scene.id}`,
|
|
|
editScene: () => history.push(`/${scene.id}/grid`)
|
|
|
}
|
|
|
case SceneType.LASER:
|
|
|
- const gotoLink = goto(`https://laser.4dkankan.com/index.html?m=${scene.m}`)
|
|
|
+ const gotoLink = `https://laser.4dkankan.com/index.html?m=${scene.m}`
|
|
|
return {
|
|
|
gotoScene: gotoLink,
|
|
|
- editScene: gotoLink
|
|
|
+ editScene: goto(gotoLink)
|
|
|
}
|
|
|
case SceneType.KANKAN:
|
|
|
return {
|
|
|
- gotoScene: goto(`https://www.4dkankan.com/spg.html?m=${scene.m}`),
|
|
|
+ gotoScene: `https://www.4dkankan.com/spg.html?m=${scene.m}`,
|
|
|
editScene: goto(`https://www.4dkankan.com/epg.html?m=${scene.m}`)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-export const SignScene = (scene: Scene) => {
|
|
|
+export const SignScene = (scene: Scene & { goto: (link: string) => void }) => {
|
|
|
const [editIng, setEditIng] = useState(false)
|
|
|
const date = parseISO(scene.time)
|
|
|
const timeAgo = formatDistanceToNow(date, { locale: zh })
|
|
|
const dispatch = useDispatch()
|
|
|
- const deleteHandler = async () => {
|
|
|
+ const deleteHandler = async (ev) => {
|
|
|
+ ev.stopPropagation()
|
|
|
if (await confirm('确定要删除此场景?')) {
|
|
|
await dispatch(deleteScene(scene.id)).unwrap()
|
|
|
}
|
|
|
}
|
|
|
- const { gotoScene, editScene } = useSceneLinks(scene)
|
|
|
+ const { gotoScene, editScene: editSceneRaw } = useSceneLinks(scene)
|
|
|
+ const editScene = (ev) => {
|
|
|
+ ev.stopPropagation()
|
|
|
+ editSceneRaw()
|
|
|
+ }
|
|
|
|
|
|
const renderActions = [
|
|
|
- <PaperClipOutlined key="query" translate={undefined} onClick={gotoScene} />,
|
|
|
- <SettingOutlined key="setting" translate={undefined} onClick={() => setEditIng(true)} />,
|
|
|
+ // <PaperClipOutlined key="query" translate={undefined} onClick={gotoScene} />,
|
|
|
+ // <SettingOutlined key="setting" translate={undefined} onClick={() => setEditIng(true)} />,
|
|
|
<DeleteOutlined key="delete" translate={undefined} onClick={deleteHandler} />,
|
|
|
]
|
|
|
|
|
@@ -77,6 +82,10 @@ export const SignScene = (scene: Scene) => {
|
|
|
return (
|
|
|
<>
|
|
|
{editIng && <EditScene onClose={() => setEditIng(false)} {...scene} />}
|
|
|
+ <List.Item actions={renderActions} className={style.scene} onClick={() => scene.goto(gotoScene)}>
|
|
|
+ <List.Item.Meta title={scene.title}/>
|
|
|
+ </List.Item>
|
|
|
+{/*
|
|
|
<Col span={6} className={style.scene}>
|
|
|
<Card
|
|
|
bordered={true}
|
|
@@ -88,7 +97,7 @@ export const SignScene = (scene: Scene) => {
|
|
|
description={`创建时间: ${timeAgo}`}
|
|
|
/>
|
|
|
</Card>
|
|
|
- </Col>
|
|
|
+ </Col> */}
|
|
|
</>
|
|
|
)
|
|
|
}
|