bill %!s(int64=2) %!d(string=hai) anos
pai
achega
f58e60c48b

+ 3 - 2
src/store/scene.ts

@@ -13,6 +13,7 @@ import {
   SceneTypeDomain, 
   SceneTypePaths 
 } from 'constant'
+import { onlyOpenWindow } from 'utils'
 
 import type { ThunkState } from './help'
 import type { Scenes, Scene, SceneIdents } from 'api'
@@ -83,8 +84,8 @@ export const getSceneLink = (scene: Scene, flag: SceneLinkFlag): URL => {
   return url
 }
 
-export const openSceneQueryPage = (scene: Scene) => window.open(getSceneLink(scene, SceneLinkFlag.query))
-export const openSceneEditPage = (scene: Scene) => window.open(getSceneLink(scene, SceneLinkFlag.edit))
+export const openSceneQueryPage = (scene: Scene) => onlyOpenWindow(getSceneLink(scene, SceneLinkFlag.query))
+export const openSceneEditPage = (scene: Scene) => onlyOpenWindow(getSceneLink(scene, SceneLinkFlag.edit))
 
 export const sceneIsSuccess = (scene: Scene) => 
   (scene.type !== SceneType.SWMX && scene.status === QuoteSceneStatus.SUCCESS)

+ 2 - 1
src/utils/index.ts

@@ -5,4 +5,5 @@ export * from './encode'
 export * from './setState'
 export * from './serve'
 export * from './sys'
-export * from './url'
+export * from './url'
+export * from './only-open'

+ 17 - 0
src/utils/only-open.ts

@@ -0,0 +1,17 @@
+
+// let cacheWin: Window | null
+
+export const onlyOpenWindow = (url: string | URL) => {
+  window.open(url)
+
+  // if (cacheWin && !cacheWin.closed) {
+  //   cacheWin.location.replace('jvascript:void(0)')
+  //   setTimeout(() => {
+  //     cacheWin!.location.replace(url)
+  //     cacheWin!.focus()
+  //   })
+  // } else {
+  //   cacheWin = window.open(url)
+  // }
+  // console.log(cacheWin)
+}

+ 3 - 5
src/views/example/files/list.tsx

@@ -3,7 +3,7 @@ import { ActionsButton } from 'components'
 import style from '../style.module.scss'
 import { AntUploadProps, addExampleFile, deleteExampleFile } from 'api'
 import { UploadOutlined } from '@ant-design/icons'
-import { confirm } from 'utils'
+import { confirm, onlyOpenWindow } from 'utils'
 import { 
   Modal, 
   Button, 
@@ -56,9 +56,7 @@ export const ExampleFiles = (props: ExampleScenesProps) => {
         const actions = [
           {
             text: '查看', 
-            action: () => {
-              window.open(data.filesUrl)
-            }, 
+            action: () => onlyOpenWindow(data.filesUrl), 
           },
           {
             text: '删除', 
@@ -161,7 +159,7 @@ export const AddExampleFile = (props: AddExampleFileProps) => {
     listType: 'picture',
     maxCount: 1,
     onPreview(file) {
-      window.open(file.response)
+      onlyOpenWindow(file.response)
     }
   };
 

+ 5 - 5
src/views/example/index.tsx

@@ -9,7 +9,7 @@ import { EditExampleTitle, InsertExample } from './edit'
 import { setExample, repExampleScenes, deleteExample, getToken } from 'api'
 import { ExampleScenes } from './scene/list'
 import { useState } from 'react'
-import { confirm, getHref } from 'utils'
+import { confirm, getHref, onlyOpenWindow } from 'utils'
 import { ExampleFiles } from './files/list'
 import { SceneType, SceneTypeDomain, SceneTypePaths } from 'constant'
 
@@ -110,10 +110,10 @@ export const ExamplePage = () => {
           example={record}
           sceneManage={() => setScenesCaseId(record.caseId)}
           file={() => setFileCaseId(record.caseId)}
-          query={() => window.open(`${getFuseCodeLink(record.caseId)}#show/summary`)}
-          fuse={() => window.open(`${getFuseCodeLink(record.caseId)}#fuseEdit/merge`)}
-          getView={() => window.open(`${getFuseCodeLink(record.caseId)}#sceneEdit/view`)}
-          record={() =>window.open(`${getFuseCodeLink(record.caseId)}#sceneEdit/record`)} 
+          query={() => onlyOpenWindow(`${getFuseCodeLink(record.caseId)}#show/summary`)}
+          fuse={() => onlyOpenWindow(`${getFuseCodeLink(record.caseId)}#fuseEdit/merge`)}
+          getView={() => onlyOpenWindow(`${getFuseCodeLink(record.caseId)}#sceneEdit/view`)}
+          record={() => onlyOpenWindow(`${getFuseCodeLink(record.caseId)}#sceneEdit/record`)} 
         /> 
       )
     }

+ 15 - 13
src/views/example/scene/list.tsx

@@ -7,12 +7,12 @@ import { sceneTitleColumn, sceneTimeColumn, getSceneActions } from 'views/scene'
 import { getSceneIdent, getScenesIdents } from 'store'
 import { SelectScenes } from './select'
 import style from '../style.module.scss'
+import { confirm } from 'utils'
 
 import type { Example, Scene } from "api";
 import type { SceneColumn } from 'views/scene'
 import type { SelectScenesProps } from './select'
 
-
 export type ExampleScenesProps = Pick<Example, 'caseId'> & { 
   onClose: () => void,
   onChangeScenes: (newSceneIds: SelectScenesProps['sceneIdents'], oldSceneIds: SelectScenesProps['sceneIdents']) => void
@@ -38,19 +38,21 @@ export const ExampleScenes = (props: ExampleScenesProps) => {
           ...getSceneActions(record, true),
           { 
             text: '删除', 
-            action: () => {
-              const newIdents = idents.map(ident => {
-                if (ident.type === record.type) {
-                  const sceneIdent = getSceneIdent(record)
-                  return {
-                    ...ident,
-                    numList: ident.numList.filter(num => num !== sceneIdent)
+            action: async () => {
+              if (await confirm('删除该场景,将同时从案件和融合模型中移除,确定要删除吗?')) {
+                const newIdents = idents.map(ident => {
+                  if (ident.type === record.type) {
+                    const sceneIdent = getSceneIdent(record)
+                    return {
+                      ...ident,
+                      numList: ident.numList.filter(num => num !== sceneIdent)
+                    }
+                  } else {
+                    return ident
                   }
-                } else {
-                  return ident
-                }
-              })
-              selectChange(newIdents)
+                })
+                selectChange(newIdents)
+              }
             }
           }
         ]

+ 1 - 1
src/views/scene/columns.tsx

@@ -14,7 +14,7 @@ import type { ColumnAction } from 'components'
 export type SceneColumn<T = Scene> = ColumnsType<T>[number]
 
 export const sceneTitleColumn: SceneColumn = {
-  title: '名称',
+  title: '标题',
   dataIndex: 'title',
   key: 'title',
 }