Эх сурвалжийг харах

feat: loading component style

touchitvoid 3 жил өмнө
parent
commit
44dd5bbb57

+ 17 - 11
.idea/workspace.xml

@@ -2,15 +2,10 @@
 <project version="4">
   <component name="ChangeListManager">
     <list default="true" id="e134edf7-cd39-4d8a-9fa6-b64c2a732b8a" name="Default Changelist" comment="">
-      <change afterPath="$PROJECT_DIR$/src/pages/hard/components/head-mast.tsx" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/src/pages/hard/hooks.ts" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/src/pages/hard/static/stripes.png" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/src/compontens/table/index.scss" beforeDir="false" afterPath="$PROJECT_DIR$/src/compontens/table/index.scss" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/src/compontens/table/index.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/compontens/table/index.tsx" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/src/contants.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/contants.ts" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/src/hooks/iot.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/hooks/iot.ts" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/src/pages/hard/components/3d-component.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/hard/components/3d-component.tsx" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/src/pages/hard/components/boxContainer/index.scss" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/hard/components/boxContainer/index.scss" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/src/pages/hard/hooks.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/hard/hooks.ts" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/src/pages/hard/index.scss" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/hard/index.scss" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/src/pages/hard/index.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/hard/index.tsx" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/src/pages/index/index.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/index/index.tsx" afterDir="false" />
@@ -32,13 +27,13 @@
     </file-type-list>
   </component>
   <component name="HighlightingSettingsPerFile">
-    <setting file="file://$PROJECT_DIR$/src/pages/hard/index.scss" root0="FORCE_HIGHLIGHTING" />
-    <setting file="file://$PROJECT_DIR$/src/pages/hard/components/3d-component.tsx" root0="FORCE_HIGHLIGHTING" />
-    <setting file="file://$PROJECT_DIR$/config/config.js" root0="FORCE_HIGHLIGHTING" />
     <setting file="file://$PROJECT_DIR$/src/index.tsx" root0="FORCE_HIGHLIGHTING" />
     <setting file="file://$PROJECT_DIR$/src/contants.ts" root0="FORCE_HIGHLIGHTING" />
     <setting file="file://$PROJECT_DIR$/src/utils/request.ts" root0="FORCE_HIGHLIGHTING" />
+    <setting file="file://$PROJECT_DIR$/config/config.js" root0="FORCE_HIGHLIGHTING" />
     <setting file="file://$PROJECT_DIR$/src/compontens/button/sendcode.tsx" root0="FORCE_HIGHLIGHTING" />
+    <setting file="file://$PROJECT_DIR$/src/pages/hard/index.scss" root0="FORCE_HIGHLIGHTING" />
+    <setting file="file://$PROJECT_DIR$/src/pages/hard/components/3d-component.tsx" root0="FORCE_HIGHLIGHTING" />
   </component>
   <component name="ProjectId" id="1uFad3rNCKxFq2iO5sZvT112jPT" />
   <component name="ProjectLevelVcsManager">
@@ -63,6 +58,8 @@
       <recent name="$PROJECT_DIR$/src/pages/head-mast" />
     </key>
     <key name="MoveFile.RECENT_KEYS">
+      <recent name="$PROJECT_DIR$/src/pages/hard/static" />
+      <recent name="$PROJECT_DIR$/src/pages/hard/components/boxContainer/static" />
       <recent name="$PROJECT_DIR$/src/assets/3d" />
       <recent name="$PROJECT_DIR$/src" />
       <recent name="$PROJECT_DIR$/src/pages/hard/components" />
@@ -96,7 +93,16 @@
       <workItem from="1625625423352" duration="4922000" />
       <workItem from="1625644149171" duration="1921000" />
       <workItem from="1625727905329" duration="22558000" />
-      <workItem from="1626052480143" duration="4167000" />
+      <workItem from="1626052480143" duration="5719000" />
+      <workItem from="1626062355736" duration="1053000" />
+      <workItem from="1626070560378" duration="1502000" />
+      <workItem from="1626142671663" duration="8474000" />
+      <workItem from="1626232872900" duration="7551000" />
+      <workItem from="1626312737875" duration="9610000" />
+      <workItem from="1626491883422" duration="73000" />
+      <workItem from="1626609758940" duration="2000" />
+      <workItem from="1626675361566" duration="5472000" />
+      <workItem from="1626749325308" duration="15512000" />
     </task>
     <servers />
   </component>

+ 26 - 38
src/pages/hard/components/3d-component.tsx

@@ -3,8 +3,8 @@ import * as THREE from "three"
 import FbxFile from '../../../assets/3d/head-mast.fbx'
 import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls'
 import { FBXLoader } from 'three/examples/jsm/loaders/FBXLoader'
-import { HEADMAST_TYPE } from '../../../contants'
 
+// 创建文字
 const createCanvasText = (text, color = '#ffffff') => {
   const canvas = document.createElement('canvas')
   const ctx: any = canvas.getContext('2d')
@@ -14,13 +14,10 @@ const createCanvasText = (text, color = '#ffffff') => {
   return canvas
 }
 
-const initThree:any = (spriteList: Array<any> = [], rootEle, setLoadProcess) => {
-  // const renderer = new THREE.WebGLRenderer({antialias: true, alpha: true});
+const initThree: any = (spriteList: Array<any> = [], rootEle, setLoadProcess) => {
   // 已经存在场景
   if (initThree.scene) {
-    initThree.scene.children = initThree.scene.children.filter(item => {
-      return ['AmbientLight', 'Group'].includes(item.type)
-    })
+    initThree.scene.children = initThree.scene.children.filter(item => ['AmbientLight', 'Group'].includes(item.type))
     // reload
     AddSpriteList(initThree.scene, spriteList)
     initThree.renderer.render(initThree.scene, initThree.camera);
@@ -32,31 +29,20 @@ const initThree:any = (spriteList: Array<any> = [], rootEle, setLoadProcess) =>
   initThree.renderer = new THREE.WebGLRenderer({antialias: true, alpha: true});
 
   const { scene, camera, renderer } = initThree
-  // const scene = new THREE.Scene()
-  // const camera = new THREE.PerspectiveCamera(50, rootEle.clientWidth / rootEle.clientHeight, 1, 2000)
-
-  // default xyz
+  // default camera position
   const [x, y, z] = [-200, -115, 320]
   camera.position.set(x, y, z)
-  // const helper = new THREE.CameraHelper( camera )
-  // scene.add( helper )
   // 迪迦
   const hemisphereLight = new THREE.AmbientLight(0xffffff, 1)
   // hemisphereLight.position.set(0, 50, 60);
   scene.add(hemisphereLight)
 
   renderer.setClearColor(0x000000, 0);
-  if (rootEle.childNodes[0]) {
-    rootEle.replaceChild(renderer.domElement, rootEle.childNodes[0])
-  } else {
-    rootEle.appendChild(renderer.domElement)
-  }
+  rootEle.appendChild(renderer.domElement)
   renderer.setSize(rootEle.clientWidth, rootEle.clientHeight);
-  // 加载fbx
+  // load fbx files
   const loader = new FBXLoader()
   loader.load(FbxFile, (fbx) => {
-    // const axesHelper = new THREE.AxesHelper( 200 );
-    // scene.add( axesHelper );
     fbx.scale.set(0.05, 0.05, 0.05)
     scene.add(fbx)
     renderer.render(scene, camera)
@@ -66,7 +52,6 @@ const initThree:any = (spriteList: Array<any> = [], rootEle, setLoadProcess) =>
     return setLoadProcess(process)
   })
   AddSpriteList(scene, spriteList)
-  // renderer.render(scene, camera)
   // add camera controller
   const controls = new OrbitControls(camera, renderer.domElement);
   controls.addEventListener("change", () => {
@@ -75,7 +60,7 @@ const initThree:any = (spriteList: Array<any> = [], rootEle, setLoadProcess) =>
 }
 
 const AddSpriteList = (scene, spriteList) => {
-  spriteList.forEach((info, index) => {
+  spriteList.forEach((info) => {
     const texture = new THREE.Texture(createCanvasText(info.text))
     texture.needsUpdate = true
     const spriteMaterial = new THREE.SpriteMaterial({map: texture})
@@ -98,9 +83,9 @@ interface ThreeComponentProps {
 }
 
 const ThreeComponent: React.FC<ThreeComponentProps> = (props) => {
-  const [modelPosition, setModelPosition] = React.useState({ x: -200,y: -115,z: 320 })
+  // 加载进度
   const [loadProcess, setLoadProcess] = React.useState(0)
-
+  // 渲染元素
   const rootEle:any = document.getElementById('three-box')
 
   React.useEffect(() => {
@@ -151,22 +136,25 @@ const ThreeComponent: React.FC<ThreeComponentProps> = (props) => {
     initThree(spriteList, rootEle, setLoadProcess)
   }, [props.baseData.base])
 
-  const LoadComponent = () => (
-    <div className='load-process'>
-      <div className='load-process-bar'>
-        <div className='bar' style={{
-          transform: `translate(${loadProcess}%, 0)`
-        }}/>
+  const LoadComponent = () => {
+    // 刻度
+    const sign = [5, 25, 50, 75, 100].find(p => p >= loadProcess)
+    return (
+      <div className='load-process'>
+        <div className='load-process-bar'>
+          <div className={`bar process-${sign}`} style={{
+            width: `${loadProcess}%`
+          }}/>
+        </div>
       </div>
-    </div>
+    )
+  }
+  return (
+    <React.Fragment>
+      { (loadProcess < 100) && LoadComponent() }
+      <div id="three-box"/>
+    </React.Fragment>
   )
-  return <React.Fragment>
-    { (loadProcess < 100) && LoadComponent() }
-    {/*<div>*/}
-    {/*  x: { modelPosition.x } y: { modelPosition.y } z: { modelPosition.z }*/}
-    {/*</div>*/}
-    <div id="three-box"/>
-  </React.Fragment>
 }
 
 export default ThreeComponent

+ 1 - 1
src/pages/hard/hooks.ts

@@ -45,7 +45,7 @@ export const useHeadMastHistory = () => {
         setState((preState) => {
           data.list = data.list.map(obj => {
             Object.keys(obj).map(key => {
-              obj[key] = obj[key] + HEADMAST_COMPANY[key]
+              obj[key] = obj[key] + (HEADMAST_COMPANY[key] || '')
             })
             return obj
           })

+ 50 - 13
src/pages/hard/index.scss

@@ -77,7 +77,7 @@
         flex:1;
         padding-left: 20px;
         box-sizing: border-box;
-        .hard-device-content{
+        .hard-device-content {
             width: 100%;
             height: 100%;
             background-image: url("./static/device-info-bg.png");
@@ -85,15 +85,14 @@
             background-repeat: no-repeat;
             background-position: left bottom;
             position: relative;
-            .hard-device-header{
+            .hard-device-header {
                 position: absolute;
                 left: 0;
                 top: 6px;
                 display: flex;
                 color: #ffffff;
-               
                 font-size: 14px;
-                &>div{
+                & > div {
                     background-image: url("./static/tab-unchecked.png");
                     background-size: 100% auto;
                     background-repeat: no-repeat;
@@ -103,7 +102,7 @@
                     line-height: 33px;
                     text-align: center;
                     cursor: pointer;
-                    &[data-checked="true"]{
+                    &[data-checked="true"] {
                         opacity: 1;
                         background-image: url("./static/tab-checked.png");
                     }
@@ -126,28 +125,31 @@
                     display: -webkit-flex;
                     position: absolute;
                     box-sizing: border-box;
-                    padding: 0 20px;
+                    padding: 0 14px;
                     .load-process-bar {
                       width: 100%;
-                      height: 32px;
-                      background-color: white;
+                      height: 26px;
+                      background: rgba(0, 0, 0, 0.25);
+                      border-radius: 6px;
+                      box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.25), 0 1px rgba(255, 255, 255, 0.08);
                       position: relative;
                       top: 180px;
                       display: -webkit-flex;
                       align-items: center;
                       overflow-x: hidden;
                       box-sizing: border-box;
+                      padding: 1px 8px 0 8px;
                       &::after {
                         content: 'LOADING FILES...';
-                        font-family: 'lcd';
-                        font-size: 17px;
+                        font-family: 'lcd', serif;
+                        font-size: 12px;
                         letter-spacing: 3px;
                         color: white;
                         width: 100%;
                         height: 100%;
                         display: -webkit-flex;
                         align-items: center;
-                        padding-bottom: 5px;
+                        padding-bottom: 2px;
                         box-sizing: border-box;
                         justify-content: center;
                         position: absolute;
@@ -159,11 +161,46 @@
                       .bar {
                         width: 100%;
                         height: calc(100% - 10px);
-                        background-color: #1BC794;
+                        background-color: #f63a0f;
                         position: relative;
-                        left: -100%;
+                        border-radius: inherit;
+                        //left: -100%;
                         transition: all 1s;
                         will-change: auto;
+                        &.process-5 {
+                          background-color: #f63a0f;
+                        }
+                        &.process-25 {
+                          background-color: #f27011;
+                        }
+                        &.process-50 {
+                          background-color: #f2b01e;
+                        }
+                        &.process-75 {
+                          background-color: #f2d31b;
+                        }
+                        &.process-100 {
+                          background-color: #86e01e;
+                        }
+                        &::before, &::after {
+                          content: '';
+                          position: absolute;
+                          top: 0;
+                          left: 0;
+                          right: 0;
+                          bottom: 0;
+                        }
+                        &::before {
+                          background: url("./static/stripes.png") 0 0 repeat;
+                        }
+                        &::after {
+                          bottom: 45%;
+                          border-radius: 4px;
+                          background-image: -webkit-linear-gradient(top, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.05));
+                          background-image: -moz-linear-gradient(top, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.05));
+                          background-image: -o-linear-gradient(top, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.05));
+                          background-image: linear-gradient(to bottom, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.05));
+                        }
                       }
                     }
                   }

+ 9 - 2
src/pages/hard/index.tsx

@@ -38,7 +38,7 @@ const hard: React.FC = (props) => {
   // 获取塔吊历史数据
   const { state: headMastHistory, request: getHeadMastHistory } = useHeadMastHistory()
 
-  const headMastColumns = [
+  const [headMastColumns, setHeadMastColumns] = React.useState([
     { title: '日期', dataIndex: 'date', datakey: 'date' },
     { title: HEADMAST_TYPE["angle"], dataIndex: 'angle', datakey: 'angle' },
     { title: HEADMAST_TYPE["back_turn"], dataIndex: 'back_turn', datakey: 'back_turn' },
@@ -47,7 +47,7 @@ const hard: React.FC = (props) => {
     { title: HEADMAST_TYPE["scope"], dataIndex: 'scope', datakey: 'scope' },
     { title: HEADMAST_TYPE["weight"], dataIndex: 'weight', datakey: 'weight' },
     { title: HEADMAST_TYPE["wind_speed"], dataIndex: 'wind_speed', datakey: 'wind_speed' }
-  ]
+  ])
 
   // 获取iot列表
 	useEffect(() => {
@@ -85,6 +85,13 @@ const hard: React.FC = (props) => {
   useEffect(() => {
     const checked: any = tabsState.list.find(item => item.checked)
     if (checked.key !== 'real') {
+      setHeadMastColumns((prevState => {
+        if (checked.key !== 'history') {
+          return [...prevState, { title: '报警原因', dataIndex: 'alarm_reason', datakey: 'alarm_reason' }]
+        }
+        prevState.pop()
+        return prevState
+      }))
       getHeadMastHistory({
         sn: state.checkedSn,
         is_alarm: checked.key !== 'history'

BIN
src/pages/hard/static/stripes.png


+ 2 - 2
src/pages/index/index.tsx

@@ -165,7 +165,7 @@ const Index: React.FC<RouteComponentProps> = ({ history }) => {
 											history.push('/person');
 										}}>
 										<span>更多</span>
-										<RightOutlined></RightOutlined>
+										<RightOutlined/>
 									</div>
 								}
 								className='attendance-box-wrapper'>
@@ -216,7 +216,7 @@ const Index: React.FC<RouteComponentProps> = ({ history }) => {
 											backgroundImage: `url("${
 												value.projectInfo.project_plan || emptyPlanImg
 											}")`,
-										}}></div>
+										}}/>
 								) : (
 									<div className='project-plan-imgError'></div>
 								)}