Ver código fonte

update WarnAlert

pull/1/head
lb 5 meses atrás
pai
commit
9894aeca50
4 arquivos alterados com 34 adições e 7 exclusões
  1. +20
    -0
      src/components/Common/WarnAlert/ListContainer.jsx
  2. +4
    -6
      src/components/Common/WarnAlert/index.jsx
  3. +9
    -1
      src/pages/Home/index.jsx
  4. +1
    -0
      src/store/features/alarmSlice.js

+ 20
- 0
src/components/Common/WarnAlert/ListContainer.jsx Ver arquivo

@@ -0,0 +1,20 @@
import WarnAlert from ".";
import { useSelector } from "react-redux";

function AlarmListContainer(props) {
const alarmList = useSelector((state) => state.alarm.list);
const posMap = {
A1_1_1: { x: 800, y: 200 },
};
return alarmList.map((alarm) => (
<WarnAlert
key={alarm.id}
title={alarm.title}
content={alarm.content}
x={posMap[alarm.title].x}
y={posMap[alarm.title].y}
/>
));
}

export default AlarmListContainer;

+ 4
- 6
src/components/Common/WarnAlert/index.jsx Ver arquivo

@@ -3,16 +3,14 @@ import "./warn-alert.css";
import AlertIcon from "./warn-icon.png";

function WarnAlert(props) {
const { x, y, title, content } = props;
return (
<div className="warn-alert">
<div className="warn-alert" style={{ top: `${y}px`, left: `${x}px` }}>
<h1 className="">
<img src={AlertIcon} width={24} alt="icon" />
{props.title || "test"}
{title || "test"}
</h1>
<p>
{props.content ||
"Lorem ipsum dolor sit amet consectetur."}
</p>
<p>{content || "Lorem ipsum dolor sit amet consectetur."}</p>
</div>
);
}


+ 9
- 1
src/pages/Home/index.jsx Ver arquivo

@@ -36,8 +36,16 @@ export default function Home({ active }) {

return (
<div className="Main">
<WarnAlert x={800} y={200} />
{active == "窑炉总览" && (
<div style={{ position: "fixed", top: "210px", left: "50%", transform: 'translateX(-40%)' }}>
<div
style={{
position: "fixed",
top: "210px",
left: "50%",
transform: "translateX(-40%)",
}}
>
<TimeFireDir />
</div>
)}


+ 1
- 0
src/store/features/alarmSlice.js Ver arquivo

@@ -9,6 +9,7 @@ const alarmSlice = createSlice({
initialState,
reducers: {
setList(state, action) {
// action.payload 是 { 'A1_1_1': 'detail' } 的结构
console.log("[alarm store] setting list ---> ", action);
state.list = action.payload;
},


Carregando…
Cancelar
Salvar