mirror of
https://github.com/xiaozhou233/RiverWaterQualityMonitoring.git
synced 2026-12-05 13:05:53 +08:00
控制面板更新 HTML+JS切换为Vite+ React + Tailwind CSS
This commit is contained in:
1 parent
4b06470590
commit
fe0b92e4b4
28 files changed
+5230
-955
No files matched your search
@@ -0,0 +1,24 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
lerna-debug.log*
|
||||
|
||||
node_modules
|
||||
dist
|
||||
dist-ssr
|
||||
*.local
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
.idea
|
||||
.DS_Store
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
@@ -0,0 +1,75 @@
|
||||
# React + TypeScript + Vite
|
||||
|
||||
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
|
||||
|
||||
Currently, two official plugins are available:
|
||||
|
||||
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Oxc](https://oxc.rs)
|
||||
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/)
|
||||
|
||||
## React Compiler
|
||||
|
||||
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
|
||||
|
||||
## Expanding the ESLint configuration
|
||||
|
||||
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
|
||||
|
||||
```js
|
||||
export default defineConfig([
|
||||
globalIgnores(['dist']),
|
||||
{
|
||||
files: ['**/*.{ts,tsx}'],
|
||||
extends: [
|
||||
// Other configs...
|
||||
|
||||
// Remove tseslint.configs.recommended and replace with this
|
||||
tseslint.configs.recommendedTypeChecked,
|
||||
// Alternatively, use this for stricter rules
|
||||
tseslint.configs.strictTypeChecked,
|
||||
// Optionally, add this for stylistic rules
|
||||
tseslint.configs.stylisticTypeChecked,
|
||||
|
||||
// Other configs...
|
||||
],
|
||||
languageOptions: {
|
||||
parserOptions: {
|
||||
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
||||
tsconfigRootDir: import.meta.dirname,
|
||||
},
|
||||
// other options...
|
||||
},
|
||||
},
|
||||
])
|
||||
|
||||
```
|
||||
|
||||
You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
|
||||
|
||||
```js
|
||||
// eslint.config.js
|
||||
import reactX from 'eslint-plugin-react-x'
|
||||
import reactDom from 'eslint-plugin-react-dom'
|
||||
|
||||
export default defineConfig([
|
||||
globalIgnores(['dist']),
|
||||
{
|
||||
files: ['**/*.{ts,tsx}'],
|
||||
extends: [
|
||||
// Other configs...
|
||||
// Enable lint rules for React
|
||||
reactX.configs['recommended-typescript'],
|
||||
// Enable lint rules for React DOM
|
||||
reactDom.configs.recommended,
|
||||
],
|
||||
languageOptions: {
|
||||
parserOptions: {
|
||||
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
||||
tsconfigRootDir: import.meta.dirname,
|
||||
},
|
||||
// other options...
|
||||
},
|
||||
},
|
||||
])
|
||||
|
||||
```
|
||||
@@ -1,277 +0,0 @@
|
||||
const API_BASE = "https://api.xiaozhou233.cn";
|
||||
const DATA_API = API_BASE + "/data/integration";
|
||||
|
||||
let phChart = null;
|
||||
let tdsChart = null;
|
||||
let turbidityChart = null;
|
||||
|
||||
/* ===========================
|
||||
Create Chart
|
||||
=========================== */
|
||||
|
||||
function createChart(chart, title, color) {
|
||||
|
||||
chart.setOption({
|
||||
|
||||
animation: true,
|
||||
|
||||
tooltip: {
|
||||
trigger: "axis"
|
||||
},
|
||||
|
||||
grid: {
|
||||
left: 55,
|
||||
right: 25,
|
||||
top: 30,
|
||||
bottom: 40
|
||||
},
|
||||
|
||||
xAxis: {
|
||||
type: "category",
|
||||
boundaryGap: false,
|
||||
data: [],
|
||||
axisLabel: {
|
||||
color: "#666"
|
||||
}
|
||||
},
|
||||
|
||||
yAxis: {
|
||||
type: "value",
|
||||
scale: true,
|
||||
axisLabel: {
|
||||
color: "#666"
|
||||
},
|
||||
splitLine: {
|
||||
lineStyle: {
|
||||
color: "#e6e6e6"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
series: [{
|
||||
|
||||
name: title,
|
||||
type: "line",
|
||||
smooth: true,
|
||||
symbol: "none",
|
||||
|
||||
lineStyle: {
|
||||
width: 3,
|
||||
color: color
|
||||
},
|
||||
|
||||
areaStyle: {
|
||||
opacity: 0.15,
|
||||
color: color
|
||||
},
|
||||
|
||||
data: []
|
||||
|
||||
}]
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/* ===========================
|
||||
Init Charts
|
||||
=========================== */
|
||||
|
||||
function initCharts() {
|
||||
|
||||
phChart = echarts.init(document.getElementById("phChart"));
|
||||
tdsChart = echarts.init(document.getElementById("tdsChart"));
|
||||
turbidityChart = echarts.init(document.getElementById("turbidityChart"));
|
||||
|
||||
createChart(phChart, "pH", "#2196f3");
|
||||
createChart(tdsChart, "TDS", "#4caf50");
|
||||
createChart(turbidityChart, "浊度", "#ff9800");
|
||||
|
||||
}
|
||||
|
||||
/* ===========================
|
||||
Update Card
|
||||
=========================== */
|
||||
|
||||
function setItem(name, data) {
|
||||
|
||||
document.getElementById(name + "-value").innerHTML =
|
||||
Number(data.value).toFixed(2);
|
||||
|
||||
document.getElementById(name + "-level").innerHTML =
|
||||
"等级:" + data.level;
|
||||
|
||||
document.getElementById(name + "-score").innerHTML =
|
||||
"评分:" + data.score;
|
||||
|
||||
}
|
||||
|
||||
/* ===========================
|
||||
Load Data
|
||||
=========================== */
|
||||
|
||||
async function loadData() {
|
||||
|
||||
try {
|
||||
|
||||
const res = await fetch(DATA_API);
|
||||
|
||||
const result = await res.json();
|
||||
|
||||
if (result.code !== 200) {
|
||||
|
||||
console.error(result.message);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
/* ===========================
|
||||
Score
|
||||
=========================== */
|
||||
|
||||
const score = result.score;
|
||||
|
||||
document.getElementById("score").innerHTML =
|
||||
score.score;
|
||||
|
||||
document.getElementById("level").innerHTML =
|
||||
score.level;
|
||||
|
||||
document.getElementById("time").innerHTML =
|
||||
result.time.substring(11, 19);
|
||||
|
||||
const abnormal =
|
||||
document.getElementById("abnormal");
|
||||
|
||||
abnormal.innerHTML =
|
||||
score.abnormal ? "异常" : "正常";
|
||||
|
||||
abnormal.className =
|
||||
"card-value " +
|
||||
(score.abnormal ? "abnormal" : "normal");
|
||||
|
||||
setItem("ph", score.ph);
|
||||
setItem("tds", score.tds);
|
||||
setItem("turbidity", score.turbidity);
|
||||
|
||||
/* ===========================
|
||||
History
|
||||
=========================== */
|
||||
|
||||
const history = result.data.slice(-100);
|
||||
|
||||
const time = history.map(item =>
|
||||
item.time.substring(11, 19));
|
||||
|
||||
phChart.setOption({
|
||||
|
||||
xAxis: {
|
||||
data: time
|
||||
},
|
||||
|
||||
series: [{
|
||||
|
||||
data: history.map(item => item.ph)
|
||||
|
||||
}]
|
||||
|
||||
});
|
||||
|
||||
tdsChart.setOption({
|
||||
|
||||
xAxis: {
|
||||
data: time
|
||||
},
|
||||
|
||||
series: [{
|
||||
|
||||
data: history.map(item => item.tds)
|
||||
|
||||
}]
|
||||
|
||||
});
|
||||
|
||||
turbidityChart.setOption({
|
||||
|
||||
xAxis: {
|
||||
data: time
|
||||
},
|
||||
|
||||
series: [{
|
||||
|
||||
data: history.map(item => item.turbidity)
|
||||
|
||||
}]
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
catch (e) {
|
||||
|
||||
console.error("Load Data Error:", e);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* ===========================
|
||||
Clock
|
||||
=========================== */
|
||||
|
||||
function updateClock() {
|
||||
|
||||
document.getElementById("clock").innerHTML =
|
||||
new Date().toLocaleString("zh-CN");
|
||||
|
||||
}
|
||||
|
||||
/* ===========================
|
||||
Resize
|
||||
=========================== */
|
||||
|
||||
window.addEventListener("resize", () => {
|
||||
|
||||
requestAnimationFrame(() => {
|
||||
|
||||
if (phChart)
|
||||
phChart.resize();
|
||||
|
||||
if (tdsChart)
|
||||
tdsChart.resize();
|
||||
|
||||
if (turbidityChart)
|
||||
turbidityChart.resize();
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
/* ===========================
|
||||
Start
|
||||
=========================== */
|
||||
|
||||
window.addEventListener("load", async () => {
|
||||
|
||||
initCharts();
|
||||
|
||||
requestAnimationFrame(() => {
|
||||
|
||||
phChart.resize();
|
||||
tdsChart.resize();
|
||||
turbidityChart.resize();
|
||||
|
||||
});
|
||||
|
||||
updateClock();
|
||||
|
||||
await loadData();
|
||||
|
||||
setInterval(updateClock, 1000);
|
||||
|
||||
setInterval(async () => {
|
||||
|
||||
await loadData();
|
||||
|
||||
}, 3000);
|
||||
|
||||
});
|
||||
Vendored
-45
@@ -1,45 +0,0 @@
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).echarts={})}(this,(function(t){"use strict";
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
PERFORMANCE OF THIS SOFTWARE.
|
||||
***************************************************************************** */var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},e(t,n)};function n(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function i(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}var i=function(){this.firefox=!1,this.ie=!1,this.edge=!1,this.newEdge=!1,this.weChat=!1},r=new function(){this.browser=new i,this.node=!1,this.wxa=!1,this.worker=!1,this.svgSupported=!1,this.touchEventsSupported=!1,this.pointerEventsSupported=!1,this.domSupported=!1,this.transformSupported=!1,this.transform3dSupported=!1,this.hasGlobalWindow="undefined"!=typeof window};"object"==typeof wx&&"function"==typeof wx.getSystemInfoSync?(r.wxa=!0,r.touchEventsSupported=!0):"undefined"==typeof document&&"undefined"!=typeof self?r.worker=!0:!r.hasGlobalWindow||"Deno"in window?(r.node=!0,r.svgSupported=!0):function(t,e){var n=e.browser,i=t.match(/Firefox\/([\d.]+)/),r=t.match(/MSIE\s([\d.]+)/)||t.match(/Trident\/.+?rv:(([\d.]+))/),o=t.match(/Edge?\/([\d.]+)/),a=/micromessenger/i.test(t);i&&(n.firefox=!0,n.version=i[1]);r&&(n.ie=!0,n.version=r[1]);o&&(n.edge=!0,n.version=o[1],n.newEdge=+o[1].split(".")[0]>18);a&&(n.weChat=!0);e.svgSupported="undefined"!=typeof SVGRect,e.touchEventsSupported="ontouchstart"in window&&!n.ie&&!n.edge,e.pointerEventsSupported="onpointerdown"in window&&(n.edge||n.ie&&+n.version>=11),e.domSupported="undefined"!=typeof document;var s=document.documentElement.style;e.transform3dSupported=(n.ie&&"transition"in s||n.edge||"WebKitCSSMatrix"in window&&"m11"in new WebKitCSSMatrix||"MozPerspective"in s)&&!("OTransition"in s),e.transformSupported=e.transform3dSupported||n.ie&&+n.version>=9}(navigator.userAgent,r);var o="sans-serif",a="12px "+o;var s,l,u=function(t){var e={};if("undefined"==typeof JSON)return e;for(var n=0;n<t.length;n++){var i=String.fromCharCode(n+32),r=(t.charCodeAt(n)-20)/100;e[i]=r}return e}("007LLmW'55;N0500LLLLLLLLLL00NNNLzWW\\\\WQb\\0FWLg\\bWb\\WQ\\WrWWQ000CL5LLFLL0LL**F*gLLLL5F0LF\\FFF5.5N"),h={createCanvas:function(){return"undefined"!=typeof document&&document.createElement("canvas")},measureText:function(t,e){if(!s){var n=h.createCanvas();s=n&&n.getContext("2d")}if(s)return l!==e&&(l=s.font=e||a),s.measureText(t);t=t||"";var i=/((?:\d+)?\.?\d*)px/.exec(e=e||a),r=i&&+i[1]||12,o=0;if(e.indexOf("mono")>=0)o=r*t.length;else for(var c=0;c<t.length;c++){var p=u[t[c]];o+=null==p?r:p*r}return{width:o}},loadImage:function(t,e,n){var i=new Image;return i.onload=e,i.onerror=n,i.src=t,i}};function c(t){for(var e in h)t[e]&&(h[e]=t[e])}var p=V(["Function","RegExp","Date","Error","CanvasGradient","CanvasPattern","Image","Canvas"],(function(t,e){return t["[object "+e+"]"]=!0,t}),{}),d=V(["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64"],(function(t,e){return t["[object "+e+"Array]"]=!0,t}),{}),f=Object.prototype.toString,g=Array.prototype,y=g.forEach,v=g.filter,m=g.slice,x=g.map,_=function(){}.constructor,b=_?_.prototype:null,w="__proto__",S=2311;function M(){return S++}function I(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];"undefined"!=typeof console&&console.error.apply(console,t)}function T(t){if(null==t||"object"!=typeof t)return t;var e=t,n=f.call(t);if("[object Array]"===n){if(!pt(t)){e=[];for(var i=0,r=t.length;i<r;i++)e[i]=T(t[i])}}else if(d[n]){if(!pt(t)){var o=t.constructor;if(o.from)e=o.from(t);else{e=new o(t.length);for(i=0,r=t.length;i<r;i++)e[i]=t[i]}}}else if(!p[n]&&!pt(t)&&!J(t))for(var a in e={},t)t.hasOwnProperty(a)&&a!==w&&(e[a]=T(t[a]));return e}function C(t,e,n){if(!q(e)||!q(t))return n?T(e):t;for(var i in e)if(e.hasOwnProperty(i)&&i!==w){var r=t[i],o=e[i];!q(o)||!q(r)||Y(o)||Y(r)||J(o)||J(r)||K(o)||K(r)||pt(o)||pt(r)?!n&&i in t||(t[i]=T(e[i])):C(r,o,n)}return t}function D(t,e){for(var n=t[0],i=1,r=t.length;i<r;i++)n=C(n,t[i],e);return n}function A(t,e){if(Object.assign)Object.assign(t,e);else for(var n in e)e.hasOwnProperty(n)&&n!==w&&(t[n]=e[n]);return t}function k(t,e,n){for(var i=G(e),r=0,o=i.length;r<o;r++){var a=i[r];(n?null!=e[a]:null==t[a])&&(t[a]=e[a])}return t}var L=h.createCanvas;function P(t,e){if(t){if(t.indexOf)return t.indexOf(e);for(var n=0,i=t.length;n<i;n++)if(t[n]===e)return n}return-1}function O(t,e){var n=t.prototype;function i(){}for(var r in i.prototype=e.prototype,t.prototype=new i,n)n.hasOwnProperty(r)&&(t.prototype[r]=n[r]);t.prototype.constructor=t,t.superClass=e}function R(t,e,n){if(t="prototype"in t?t.prototype:t,e="prototype"in e?e.prototype:e,Object.getOwnPropertyNames)for(var i=Object.getOwnPropertyNames(e),r=0;r<i.length;r++){var o=i[r];"constructor"!==o&&(n?null!=e[o]:null==t[o])&&(t[o]=e[o])}else k(t,e,n)}function N(t){return!!t&&("string"!=typeof t&&"numbeLine truncated
|
||||
/*!
|
||||
* ZRender, a high performance 2d drawing library.
|
||||
*
|
||||
* Copyright (c) 2013, Baidu Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* LICENSE
|
||||
* https://github.com/ecomfe/zrender/blob/master/LICENSE.txt
|
||||
*/
|
||||
var Fr={},Gr={};var Wr,Hr=function(){function t(t,e,n){var i=this;this._sleepAfterStill=10,this._stillFrameAccum=0,this._needsRefresh=!0,this._needsRefreshHover=!0,this._darkMode=!1,n=n||{},this.dom=e,this.id=t;var o=new rn,a=n.renderer||"canvas";Fr[a]||(a=G(Fr)[0]),n.useDirtyRect=null!=n.useDirtyRect&&n.useDirtyRect;var s=new Fr[a](e,o,n,t),l=n.ssr||s.ssrOnly;this.storage=o,this.painter=s;var u,h=r.node||r.worker||l?null:new or(s.getViewportRoot(),s.root),c=n.useCoarsePointer;(null==c||"auto"===c?r.touchEventsSupported:!!c)&&(u=rt(n.pointerSize,44)),this.handler=new Ye(o,s,h,s.root,u),this.animation=new Wi({stage:{update:l?null:function(){return i._flush(!0)}}}),l||this.animation.start()}return t.prototype.add=function(t){!this._disposed&&t&&(this.storage.addRoot(t),t.addSelfToZr(this),this.refresh())},t.prototype.remove=function(t){!this._disposed&&t&&(this.storage.delRoot(t),t.removeSelfFromZr(this),this.refresh())},t.prototype.configLayer=function(t,e){this._disposed||(this.painter.configLayer&&this.painter.configLayer(t,e),this.refresh())},t.prototype.setBackgroundColor=function(t){this._disposed||(this.painter.setBackgroundColor&&this.painter.setBackgroundColor(t),this.refresh(),this._backgroundColor=t,this._darkMode=function(t){if(!t)return!1;if("string"==typeof t)return oi(t,1)<.4;if(t.colorStops){for(var e=t.colorStops,n=0,i=e.length,r=0;r<i;r++)n+=oi(e[r].color,1);return(n/=i)<.4}return!1}(t))},t.prototype.getBackgroundColor=function(){return this._backgroundColor},t.prototype.setDarkMode=function(t){this._darkMode=t},t.prototype.isDarkMode=function(){return this._darkMode},t.prototype.refreshImmediately=function(t){this._disposed||(t||this.animation.update(!0),this._needsRefresh=!1,this.painter.refresh(),this._needsRefresh=!1)},t.prototype.refresh=function(){this._disposed||(this._needsRefresh=!0,this.animation.start())},t.prototype.flush=function(){this._disposed||this._flush(!1)},t.prototype._flush=function(t){var e,n=Bi();this._needsRefresh&&(e=!0,this.refreshImmediately(t)),this._needsRefreshHover&&(e=!0,this.refreshHoverImmediately());var i=Bi();e?(this._stillFrameAccum=0,this.trigger("rendered",{elapsedTime:i-n})):this._sleepAfterStill>0&&(this._stillFrameAccum++,this._stillFrameAccum>this._sleepAfterStill&&this.animation.stop())},t.prototype.setSleepAfterStill=function(t){this._sleepAfterStill=t},t.prototype.wakeUp=function(){this._disposed||(this.animation.start(),this._stillFrameAccum=0)},t.prototype.refreshHover=function(){this._needsRefreshHover=!0},t.prototype.refreshHoverImmediately=function(){this._disposed||(this._needsRefreshHover=!1,this.painter.refreshHover&&"canvas"===this.painter.getType()&&this.painter.refreshHover())},t.prototype.resize=function(t){this._disposed||(t=t||{},this.painter.resize(t.width,t.height),this.handler.resize())},t.prototype.clearAnimation=function(){this._disposed||this.animation.clear()},t.prototype.getWidth=function(){if(!this._disposed)return this.painter.getWidth()},t.prototype.getHeight=function(){if(!this._disposed)return this.painter.getHeight()},t.prototype.setCursorStyle=function(t){this._disposed||this.handler.setCursorStyle(t)},t.prototype.findHover=function(t,e){if(!this._disposed)return this.handler.findHover(t,e)},t.prototype.on=function(t,e,n){return this._disposed||this.handler.on(t,e,n),this},t.prototype.off=function(t,e){this._disposed||this.handler.off(t,e)},t.prototype.trigger=function(t,e){this._disposed||this.handler.trigger(t,e)},t.prototype.clear=function(){if(!this._disposed){for(var t=this.storage.getRoots(),e=0;e<t.length;e++)t[e]instanceof Br&&t[e].removeSelfFromZr(this);this.storage.delAllRoots(),this.painter.clear()}},t.prototype.dispose=function(){var t;this._disposed||(this.animation.stop(),this.clear(),this.storage.dispose(),this.painter.dispose(),this.handler.dispose(),this.animation=this.storage=this.painter=this.handler=null,this._disposed=!0,t=this.id,delete Gr[t])},t}();function Yr(t,e){var n=new Hr(M(),t,e);return Gr[n.id]=n,n}function Xr(t,e){Fr[t]=e}function Ur(t){if("function"==typeof Wr)return Wr(t)}function Zr(t){Wr=t}var jr=Object.freeze({__proto__:null,init:Yr,dispose:function(t){t.dispose()},disposeAll:function(){for(var t in Gr)Gr.hasOwnProperty(t)&&Gr[t].dispose();Gr={}},getInstance:function(t){return Gr[t]},registerPainter:Xr,getElementSSRData:Ur,registerSSRDataGetter:Zr,version:"5.6.1"}),qr=1e-4;function Kr(t,e,n,i){var r=e[0],o=e[1],a=n[0],s=n[1],l=o-r,u=s-a;if(0===l)return 0===u?a:(a+s)/2;if(i)if(l>0){if(t<=r)return a;if(t>=o)return s}else{if(t>=r)return a;if(t<=o)return s}else{if(t===r)return a;if(t===o)return s}return(t-r)/l*u+a}function $r(t,e){switch(t){case"center":case"middle":t="50%";break;case"left":case"top":t="0%";break;case"right":case"bottom":t="100%"}return U(t)?(n=t,n.replace(/^\s+|\s+$/g,"")).match(/%$/)?parseFloat(t)/100*e:parseFloat(t):null==t?NaN:+t;var n}function Jr(t,e,n){return null==e&&(e=10),e=Math.min(Math.max(0,e),20),t=(+t).toFixed(e),n?t:+t}function Qr(t){return t.sort((funLine truncated
|
||||
@@ -0,0 +1,22 @@
|
||||
import js from '@eslint/js'
|
||||
import globals from 'globals'
|
||||
import reactHooks from 'eslint-plugin-react-hooks'
|
||||
import reactRefresh from 'eslint-plugin-react-refresh'
|
||||
import tseslint from 'typescript-eslint'
|
||||
import { defineConfig, globalIgnores } from 'eslint/config'
|
||||
|
||||
export default defineConfig([
|
||||
globalIgnores(['dist']),
|
||||
{
|
||||
files: ['**/*.{ts,tsx}'],
|
||||
extends: [
|
||||
js.configs.recommended,
|
||||
tseslint.configs.recommended,
|
||||
reactHooks.configs.flat.recommended,
|
||||
reactRefresh.configs.vite,
|
||||
],
|
||||
languageOptions: {
|
||||
globals: globals.browser,
|
||||
},
|
||||
},
|
||||
])
|
||||
+7
-230
@@ -1,236 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>智慧河流水质监测系统</title>
|
||||
|
||||
<script src="echarts.min.js"></script>
|
||||
|
||||
<link rel="stylesheet" href="style.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<!-- ================= Banner ================= -->
|
||||
|
||||
<header class="banner">
|
||||
|
||||
<div class="banner-left">
|
||||
<div class="banner-title">
|
||||
智慧河流水质监测系统
|
||||
</div>
|
||||
|
||||
<div class="banner-subtitle">
|
||||
Smart River Water Quality Monitoring System
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="banner-right">
|
||||
|
||||
<div class="clock-title">
|
||||
当前时间
|
||||
</div>
|
||||
|
||||
<div id="clock" class="clock">
|
||||
--
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</header>
|
||||
|
||||
<!-- ================= Main ================= -->
|
||||
|
||||
<main class="container">
|
||||
|
||||
<!-- ================= Summary ================= -->
|
||||
|
||||
<section class="cards">
|
||||
|
||||
<div class="card">
|
||||
|
||||
<div class="card-title">
|
||||
综合评分
|
||||
</div>
|
||||
|
||||
<div id="score" class="card-value black">
|
||||
--
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
|
||||
<div class="card-title">
|
||||
综合等级
|
||||
</div>
|
||||
|
||||
<div id="level" class="card-value black">
|
||||
--
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
|
||||
<div class="card-title">
|
||||
系统状态
|
||||
</div>
|
||||
|
||||
<div id="abnormal" class="card-value">
|
||||
--
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
|
||||
<div class="card-title">
|
||||
数据更新时间
|
||||
</div>
|
||||
|
||||
<div id="time" class="card-value black">
|
||||
--
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
<!-- ================= Items ================= -->
|
||||
|
||||
<section class="items">
|
||||
|
||||
<div class="item">
|
||||
|
||||
<div class="item-header">
|
||||
|
||||
<div class="item-name">
|
||||
pH
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="ph-value" class="value">
|
||||
--
|
||||
</div>
|
||||
|
||||
<div id="ph-level" class="level">
|
||||
--
|
||||
</div>
|
||||
|
||||
<div id="ph-score" class="score">
|
||||
--
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="item">
|
||||
|
||||
<div class="item-header">
|
||||
|
||||
<div class="item-name">
|
||||
TDS(溶解性总固体)
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="tds-value" class="value">
|
||||
--
|
||||
</div>
|
||||
|
||||
<div id="tds-level" class="level">
|
||||
--
|
||||
</div>
|
||||
|
||||
<div id="tds-score" class="score">
|
||||
--
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="item">
|
||||
|
||||
<div class="item-header">
|
||||
|
||||
<div class="item-name">
|
||||
浊度
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="turbidity-value" class="value">
|
||||
--
|
||||
</div>
|
||||
|
||||
<div id="turbidity-level" class="level">
|
||||
--
|
||||
</div>
|
||||
|
||||
<div id="turbidity-score" class="score">
|
||||
--
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
<!-- ================= Charts ================= -->
|
||||
|
||||
<section class="chart-grid">
|
||||
|
||||
<div class="chart">
|
||||
|
||||
<div class="chart-title">
|
||||
pH 变化趋势
|
||||
</div>
|
||||
|
||||
<div class="chart-body">
|
||||
<div id="phChart"></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="chart">
|
||||
|
||||
<div class="chart-title">
|
||||
TDS(溶解性总固体)变化趋势
|
||||
</div>
|
||||
|
||||
<div class="chart-body">
|
||||
<div id="tdsChart"></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="chart">
|
||||
|
||||
<div class="chart-title">
|
||||
浊度变化趋势
|
||||
</div>
|
||||
|
||||
<div class="chart-body">
|
||||
<div id="turbidityChart"></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
</main>
|
||||
|
||||
<!-- ================= Footer ================= -->
|
||||
|
||||
<footer class="footer">
|
||||
|
||||
智慧河流水质监测平台 © 2026
|
||||
|
||||
</footer>
|
||||
|
||||
<script src="dashboard.js"></script>
|
||||
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/src/main.tsx"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Generated
+3892
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"name": "water-admin",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "tsc -b && vite build",
|
||||
"lint": "eslint .",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"@mantine/core": "^9.4.1",
|
||||
"@mantine/form": "^9.4.1",
|
||||
"@mantine/hooks": "^9.4.1",
|
||||
"@mantine/notifications": "^9.4.1",
|
||||
"@mantinex/mantine-logo": "^2.0.0",
|
||||
"@tabler/icons-react": "^3.44.0",
|
||||
"@tailwindcss/vite": "^4.3.2",
|
||||
"axios": "^1.18.1",
|
||||
"echarts": "^6.1.0",
|
||||
"echarts-for-react": "^3.0.6",
|
||||
"react": "^19.2.7",
|
||||
"react-dom": "^19.2.7",
|
||||
"react-router-dom": "^7.18.1",
|
||||
"tailwindcss": "^4.3.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^10.0.1",
|
||||
"@types/node": "^24.13.2",
|
||||
"@types/react": "^19.2.17",
|
||||
"@types/react-dom": "^19.2.3",
|
||||
"@vitejs/plugin-react": "^6.0.3",
|
||||
"eslint": "^10.6.0",
|
||||
"eslint-plugin-react-hooks": "^7.1.1",
|
||||
"eslint-plugin-react-refresh": "^0.5.3",
|
||||
"globals": "^17.7.0",
|
||||
"postcss": "^8.5.16",
|
||||
"typescript": "~6.0.2",
|
||||
"typescript-eslint": "^8.62.0",
|
||||
"vite": "^8.1.1"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import Dashboard from './pages/Dashboard';
|
||||
|
||||
function App() {
|
||||
return (
|
||||
<Dashboard />
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
export default App;
|
||||
@@ -0,0 +1,25 @@
|
||||
import type { WaterData } from "../types/water.ts";
|
||||
|
||||
|
||||
const API =
|
||||
"https://api.xiaozhou233.cn/data/integration";
|
||||
|
||||
|
||||
export async function getWaterData()
|
||||
: Promise<WaterData> {
|
||||
|
||||
try {
|
||||
const res = await fetch(API);
|
||||
|
||||
if (!res.ok) {
|
||||
throw new Error(`HTTP Error: ${res.status}`);
|
||||
}
|
||||
|
||||
const data = await res.json();
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error("Failed to fetch water data:", error);
|
||||
throw error;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,326 @@
|
||||
.page {
|
||||
width: 100%;
|
||||
height: 100vh;
|
||||
background: #eef3f8;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
font-family: "Microsoft YaHei", Arial, sans-serif;
|
||||
}
|
||||
|
||||
.banner {
|
||||
height: 11vh;
|
||||
min-height: 90px;
|
||||
background: linear-gradient(90deg, #1565c0, #2196f3);
|
||||
color: white;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 0 2vw;
|
||||
box-shadow: 0 3px 12px rgba(0, 0, 0, .18);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: clamp(30px, 2vw, 52px);
|
||||
font-weight: bold;
|
||||
letter-spacing: 2px;
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
margin-top: .5vh;
|
||||
opacity: .9;
|
||||
font-size: clamp(14px, .9vw, 22px);
|
||||
}
|
||||
|
||||
.clockBox {
|
||||
text-align: right;
|
||||
font-size: clamp(16px, 1vw, 24px);
|
||||
}
|
||||
|
||||
.clock {
|
||||
margin-top: .6vh;
|
||||
font-size: clamp(28px, 2vw, 46px);
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.container {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.2vh;
|
||||
padding: 1.2vh 1.2vw;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.cards {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
gap: 1vw;
|
||||
}
|
||||
|
||||
.card {
|
||||
background: white;
|
||||
border-radius: 16px;
|
||||
padding: 1.2vw;
|
||||
box-shadow: 0 4px 10px rgba(0, 0, 0, .08);
|
||||
}
|
||||
|
||||
.card p {
|
||||
color: #666;
|
||||
font-size: clamp(18px, 1vw, 28px);
|
||||
}
|
||||
|
||||
.card strong {
|
||||
display: block;
|
||||
margin-top: 1vh;
|
||||
font-size: clamp(36px, 2.3vw, 64px);
|
||||
font-weight: bold;
|
||||
color: #111;
|
||||
}
|
||||
|
||||
.normal {
|
||||
color: #2ecc71 !important;
|
||||
}
|
||||
|
||||
.abnormal {
|
||||
color: #e74c3c !important;
|
||||
}
|
||||
|
||||
.items {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
gap: 1vw;
|
||||
}
|
||||
|
||||
.item {
|
||||
background: white;
|
||||
border-radius: 16px;
|
||||
padding: 1.2vw;
|
||||
text-align: center;
|
||||
box-shadow: 0 4px 10px rgba(0, 0, 0, .08);
|
||||
}
|
||||
|
||||
.item h3 {
|
||||
font-size: clamp(22px, 1.3vw, 36px);
|
||||
}
|
||||
|
||||
.value {
|
||||
margin-top: 1vh;
|
||||
color: #1976d2;
|
||||
font-size: clamp(48px, 3vw, 84px);
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.score {
|
||||
margin-top: .5vh;
|
||||
color: #666;
|
||||
font-size: clamp(18px, 1vw, 26px);
|
||||
}
|
||||
|
||||
.chartGrid {
|
||||
flex: 1;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
gap: 1vw;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.chart {
|
||||
background: white;
|
||||
border-radius: 16px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 0;
|
||||
box-shadow: 0 4px 10px rgba(0, 0, 0, .08);
|
||||
}
|
||||
|
||||
.chart h3 {
|
||||
padding: 16px 20px;
|
||||
border-bottom: 1px solid #e6e6e6;
|
||||
font-size: clamp(22px, 1.3vw, 34px);
|
||||
color: #333;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.chartBody {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
.footer {
|
||||
height: 3.5vh;
|
||||
min-height: 28px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
color: #666;
|
||||
background: white;
|
||||
border-top: 1px solid #ddd;
|
||||
}
|
||||
|
||||
@media(max-width:1100px) {
|
||||
.cards {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
|
||||
.items {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
|
||||
.chartGrid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.page {
|
||||
overflow: auto;
|
||||
}
|
||||
}
|
||||
|
||||
@media(max-width:768px) {
|
||||
.page {
|
||||
height: auto;
|
||||
min-height: 100vh;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
.banner {
|
||||
height: auto;
|
||||
min-height: 70px;
|
||||
padding: 12px 16px;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: clamp(24px, 5vw, 32px);
|
||||
letter-spacing: 1px;
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
margin-top: 4px;
|
||||
font-size: clamp(12px, 3.5vw, 16px);
|
||||
}
|
||||
|
||||
.clockBox {
|
||||
font-size: clamp(12px, 3vw, 16px);
|
||||
}
|
||||
|
||||
.clock {
|
||||
margin-top: 2px;
|
||||
font-size: clamp(20px, 4vw, 28px);
|
||||
}
|
||||
|
||||
.container {
|
||||
gap: 12px;
|
||||
padding: 12px 12px;
|
||||
}
|
||||
|
||||
.cards {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.card {
|
||||
padding: 12px;
|
||||
border-radius: 12px;
|
||||
}
|
||||
|
||||
.card p {
|
||||
font-size: clamp(14px, 3.5vw, 18px);
|
||||
}
|
||||
|
||||
.card strong {
|
||||
margin-top: 8px;
|
||||
font-size: clamp(24px, 5vw, 36px);
|
||||
}
|
||||
|
||||
.items {
|
||||
grid-template-columns: 1fr;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.item {
|
||||
padding: 12px;
|
||||
border-radius: 12px;
|
||||
}
|
||||
|
||||
.item h3 {
|
||||
font-size: clamp(16px, 4vw, 22px);
|
||||
}
|
||||
|
||||
.value {
|
||||
margin-top: 8px;
|
||||
font-size: clamp(32px, 7vw, 56px);
|
||||
}
|
||||
|
||||
.score {
|
||||
margin-top: 4px;
|
||||
font-size: clamp(12px, 3vw, 16px);
|
||||
}
|
||||
|
||||
.chartGrid {
|
||||
grid-template-columns: 1fr;
|
||||
gap: 10px;
|
||||
flex: none;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.chart {
|
||||
min-height: 300px;
|
||||
border-radius: 12px;
|
||||
}
|
||||
|
||||
.chart h3 {
|
||||
padding: 12px 16px;
|
||||
font-size: clamp(14px, 4vw, 18px);
|
||||
}
|
||||
|
||||
.chartBody {
|
||||
padding: 8px;
|
||||
height: 250px;
|
||||
}
|
||||
|
||||
.footer {
|
||||
height: auto;
|
||||
min-height: 40px;
|
||||
padding: 12px;
|
||||
font-size: clamp(12px, 3vw, 14px);
|
||||
}
|
||||
}
|
||||
|
||||
@media(max-width:480px) {
|
||||
.cards {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.banner {
|
||||
padding: 10px 12px;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: clamp(20px, 5vw, 26px);
|
||||
}
|
||||
|
||||
.container {
|
||||
padding: 10px 10px;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.card {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.card p {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.card strong {
|
||||
font-size: clamp(20px, 5vw, 28px);
|
||||
}
|
||||
|
||||
.chartBody {
|
||||
height: 200px;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import type { ReactNode } from "react";
|
||||
import classes from "../assets/Dashboard.module.css";
|
||||
|
||||
|
||||
export function Banner({ menuButton }: { menuButton?: ReactNode }){
|
||||
const [time,setTime] = useState("");
|
||||
useEffect(()=>{
|
||||
const timer=setInterval(()=>{
|
||||
setTime(
|
||||
new Date()
|
||||
.toLocaleString("zh-CN")
|
||||
);
|
||||
},1000);
|
||||
return ()=>clearInterval(timer);
|
||||
},[]);
|
||||
return (
|
||||
<header className={classes.banner}>
|
||||
<div>
|
||||
<div className={classes.title}>
|
||||
智慧河流水质监测系统
|
||||
</div>
|
||||
<div className={classes.subtitle}>
|
||||
Smart River Water Quality Monitoring System
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: '16px' }}>
|
||||
|
||||
<div className={classes.clockBox}>
|
||||
<div>
|
||||
当前时间
|
||||
</div>
|
||||
<div className={classes.clock}>
|
||||
{time}
|
||||
</div>
|
||||
</div>
|
||||
{menuButton && (
|
||||
<div>
|
||||
{menuButton}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</header>
|
||||
);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
.navbar {
|
||||
width: 260px;
|
||||
height: 100vh;
|
||||
padding: 16px;
|
||||
background-color: var(--mantine-color-body);
|
||||
border-right: 1px solid var(--mantine-color-gray-3);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
|
||||
.header {
|
||||
height: 70px;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
|
||||
.logo {
|
||||
width: 42px;
|
||||
height: 42px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
border-radius: 12px;
|
||||
}
|
||||
|
||||
|
||||
.menu {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
|
||||
.link {
|
||||
|
||||
width: 100%;
|
||||
height: 44px;
|
||||
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
gap: 12px;
|
||||
|
||||
padding: 0 14px;
|
||||
|
||||
border-radius: 10px;
|
||||
|
||||
border: none;
|
||||
|
||||
background: transparent;
|
||||
|
||||
color: var(--mantine-color-gray-7);
|
||||
|
||||
cursor: pointer;
|
||||
|
||||
font-size: 15px;
|
||||
|
||||
}
|
||||
|
||||
|
||||
.link:hover {
|
||||
|
||||
background-color: var(--mantine-color-gray-1);
|
||||
|
||||
}
|
||||
|
||||
|
||||
.link[data-active] {
|
||||
|
||||
background-color: var(--mantine-color-blue-light);
|
||||
|
||||
color: var(--mantine-color-blue-filled);
|
||||
|
||||
}
|
||||
|
||||
|
||||
.linkIcon {
|
||||
|
||||
flex-shrink: 0;
|
||||
|
||||
}
|
||||
|
||||
.navbarMain {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
/* Mobile responsive */
|
||||
@media (max-width: 768px) {
|
||||
.navbar {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
padding: 12px;
|
||||
border-right: none;
|
||||
border-bottom: 1px solid var(--mantine-color-gray-3);
|
||||
}
|
||||
|
||||
.header {
|
||||
height: auto;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.logo {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
}
|
||||
|
||||
.menu {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
gap: 4px;
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.link {
|
||||
height: 40px;
|
||||
padding: 0 10px;
|
||||
font-size: 12px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
.navbar {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.header {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.menu {
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.link {
|
||||
height: 36px;
|
||||
padding: 0 8px;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.linkIcon {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
import {
|
||||
IconDashboard,
|
||||
IconChartLine,
|
||||
IconDatabase,
|
||||
IconDevices,
|
||||
IconSettings,
|
||||
IconDroplet
|
||||
} from '@tabler/icons-react';
|
||||
|
||||
import { Group, Text } from '@mantine/core';
|
||||
import { useNavigate, useLocation } from 'react-router-dom';
|
||||
|
||||
import classes from './Navbar.module.css';
|
||||
|
||||
|
||||
const data = [
|
||||
|
||||
{
|
||||
label:'控制面板',
|
||||
path:'/',
|
||||
icon:IconDashboard,
|
||||
},
|
||||
|
||||
{
|
||||
label:'实时监测',
|
||||
path:'/monitor',
|
||||
icon:IconChartLine,
|
||||
},
|
||||
|
||||
{
|
||||
label:'历史数据',
|
||||
path:'/history',
|
||||
icon:IconDatabase,
|
||||
},
|
||||
|
||||
{
|
||||
label:'设备管理',
|
||||
path:'/device',
|
||||
icon:IconDevices,
|
||||
},
|
||||
|
||||
{
|
||||
label:'系统设置',
|
||||
path:'/settings',
|
||||
icon:IconSettings,
|
||||
},
|
||||
|
||||
];
|
||||
|
||||
|
||||
|
||||
export function Navbar({
|
||||
onClose
|
||||
}:{
|
||||
onClose?:()=>void;
|
||||
}){
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
|
||||
const links = data.map((item)=>(
|
||||
<button
|
||||
className={classes.link}
|
||||
data-active={
|
||||
location.pathname === item.path || undefined
|
||||
}
|
||||
key={item.label}
|
||||
onClick={()=>{
|
||||
navigate(item.path);
|
||||
onClose?.();
|
||||
}}
|
||||
|
||||
>
|
||||
<item.icon
|
||||
className={classes.linkIcon}
|
||||
stroke={1.8}
|
||||
size={22}
|
||||
/>
|
||||
<span>
|
||||
{item.label}
|
||||
</span>
|
||||
</button>
|
||||
|
||||
));
|
||||
|
||||
return (
|
||||
<nav className={classes.navbar}>
|
||||
<div className={classes.navbarMain}>
|
||||
<Group className={classes.header}>
|
||||
<div className={classes.logo}>
|
||||
<IconDroplet size={32}/>
|
||||
</div>
|
||||
<div>
|
||||
<Text fw={700}>
|
||||
智慧河流水质监测系统
|
||||
</Text>
|
||||
<Text size="xs" c="dimmed">
|
||||
Water Quality Monitor
|
||||
</Text>
|
||||
</div>
|
||||
</Group>
|
||||
<div className={classes.menu}>
|
||||
{links}
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
import type { WaterData } from "../types/water";
|
||||
import classes from "../assets/Dashboard.module.css";
|
||||
|
||||
interface Props {
|
||||
data: WaterData;
|
||||
}
|
||||
|
||||
export function SummaryCards({ data }: Props) {
|
||||
const score = data.score;
|
||||
|
||||
return (
|
||||
<section className={classes.cards}>
|
||||
<div className={classes.card}>
|
||||
<p>综合评分</p>
|
||||
<strong>{score.score}</strong>
|
||||
</div>
|
||||
|
||||
<div className={classes.card}>
|
||||
<p>综合等级</p>
|
||||
<strong>{score.level}</strong>
|
||||
</div>
|
||||
|
||||
<div className={classes.card}>
|
||||
<p>系统状态</p>
|
||||
<strong
|
||||
className={
|
||||
score.abnormal
|
||||
? classes.abnormal
|
||||
: classes.normal
|
||||
}
|
||||
>
|
||||
{score.abnormal ? "异常" : "正常"}
|
||||
</strong>
|
||||
</div>
|
||||
|
||||
<div className={classes.card}>
|
||||
<p>数据更新时间</p>
|
||||
<strong>
|
||||
{data.time.substring(11, 19)}
|
||||
</strong>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
import { useEffect, useRef } from "react";
|
||||
import * as echarts from "echarts";
|
||||
import classes from "../assets/Dashboard.module.css";
|
||||
|
||||
interface Props {
|
||||
title: string;
|
||||
data: number[];
|
||||
time: string[];
|
||||
min?: number;
|
||||
max?: number;
|
||||
}
|
||||
|
||||
export function WaterChart({
|
||||
title,
|
||||
data,
|
||||
time,
|
||||
min,
|
||||
max
|
||||
}: Props) {
|
||||
const chartRef = useRef<HTMLDivElement>(null);
|
||||
const chartInstance = useRef<echarts.ECharts | null>(null);
|
||||
|
||||
const getGridConfig = () => {
|
||||
const width = window.innerWidth;
|
||||
|
||||
if (width < 480) {
|
||||
return { left: 40, right: 10, top: 20, bottom: 25 };
|
||||
}
|
||||
|
||||
if (width < 768) {
|
||||
return { left: 45, right: 15, top: 25, bottom: 30 };
|
||||
}
|
||||
|
||||
return { left: 50, right: 20, top: 30, bottom: 35 };
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (!chartRef.current) return;
|
||||
|
||||
chartInstance.current = echarts.init(chartRef.current);
|
||||
|
||||
chartInstance.current.setOption({
|
||||
animation: true,
|
||||
tooltip: {
|
||||
trigger: "axis"
|
||||
},
|
||||
grid: getGridConfig(),
|
||||
xAxis: {
|
||||
type: "category",
|
||||
boundaryGap: false,
|
||||
data: []
|
||||
},
|
||||
yAxis: {
|
||||
type: "value",
|
||||
min,
|
||||
max,
|
||||
splitNumber: 7,
|
||||
splitLine: {
|
||||
lineStyle: {
|
||||
color: "#eee"
|
||||
}
|
||||
}
|
||||
},
|
||||
series: [
|
||||
{
|
||||
type: "line",
|
||||
smooth: true,
|
||||
symbol: "none",
|
||||
lineStyle: {
|
||||
width: 3
|
||||
},
|
||||
areaStyle: {
|
||||
opacity: 0.25
|
||||
},
|
||||
data: []
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
const resize = () => {
|
||||
chartInstance.current?.resize();
|
||||
};
|
||||
|
||||
window.addEventListener("resize", resize);
|
||||
|
||||
return () => {
|
||||
window.removeEventListener("resize", resize);
|
||||
chartInstance.current?.dispose();
|
||||
};
|
||||
}, [min, max]);
|
||||
|
||||
useEffect(() => {
|
||||
chartInstance.current?.setOption({
|
||||
xAxis: {
|
||||
data: time
|
||||
},
|
||||
series: [
|
||||
{
|
||||
data
|
||||
}
|
||||
]
|
||||
});
|
||||
}, [data, time]);
|
||||
|
||||
return (
|
||||
<div className={classes.chart}>
|
||||
<h3>{title}</h3>
|
||||
<div
|
||||
ref={chartRef}
|
||||
className={classes.chartBody}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
import type { WaterScore } from "../types/water";
|
||||
import classes from "../assets/Dashboard.module.css";
|
||||
|
||||
export function WaterItems({ data }: { data: WaterScore }) {
|
||||
const list = [
|
||||
{
|
||||
name: "pH",
|
||||
data: data.ph
|
||||
},
|
||||
{
|
||||
name: "TDS(溶解性总固体)",
|
||||
data: data.tds
|
||||
},
|
||||
{
|
||||
name: "浊度",
|
||||
data: data.turbidity
|
||||
}
|
||||
];
|
||||
|
||||
return (
|
||||
<section className={classes.items}>
|
||||
{list.map((item) => (
|
||||
<div
|
||||
className={classes.item}
|
||||
key={item.name}
|
||||
>
|
||||
<h3>{item.name}</h3>
|
||||
|
||||
<div className={classes.value}>
|
||||
{item.data.value.toFixed(2)}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
等级:{item.data.level}
|
||||
</div>
|
||||
|
||||
<div className={classes.score}>
|
||||
评分:{item.data.score}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
|
||||
import { getWaterData } from "../api/water";
|
||||
import type { WaterData } from "../types/water";
|
||||
|
||||
export function useWaterData(pollingInterval = 3000) {
|
||||
const [data, setData] = useState<WaterData | null>(null);
|
||||
const [error, setError] = useState("");
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
|
||||
const load = useCallback(async () => {
|
||||
try {
|
||||
setError("");
|
||||
setIsLoading(true);
|
||||
const result = await getWaterData();
|
||||
setData(result);
|
||||
} catch (err) {
|
||||
const message = err instanceof Error ? err.message : "Unknown error";
|
||||
setError(`加载数据失败: ${message}`);
|
||||
console.error(err);
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const timer = window.setInterval(() => {
|
||||
void load();
|
||||
}, pollingInterval);
|
||||
|
||||
const timeoutId = window.setTimeout(() => {
|
||||
void load();
|
||||
}, 0);
|
||||
|
||||
return () => {
|
||||
window.clearInterval(timer);
|
||||
window.clearTimeout(timeoutId);
|
||||
};
|
||||
}, [load, pollingInterval]);
|
||||
|
||||
return {
|
||||
data,
|
||||
error,
|
||||
isLoading,
|
||||
refetch: load,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
@import "tailwindcss";
|
||||
@@ -0,0 +1,22 @@
|
||||
import React from 'react'
|
||||
import ReactDOM from 'react-dom/client'
|
||||
import { BrowserRouter } from 'react-router-dom'
|
||||
|
||||
import { MantineProvider } from '@mantine/core'
|
||||
import '@mantine/core/styles.css'
|
||||
|
||||
import App from './App.tsx'
|
||||
import './index.css'
|
||||
|
||||
|
||||
ReactDOM.createRoot(
|
||||
document.getElementById('root')!
|
||||
).render(
|
||||
<React.StrictMode>
|
||||
<MantineProvider>
|
||||
<BrowserRouter>
|
||||
<App />
|
||||
</BrowserRouter>
|
||||
</MantineProvider>
|
||||
</React.StrictMode>
|
||||
)
|
||||
@@ -0,0 +1,116 @@
|
||||
import { IconMenu2 } from "@tabler/icons-react";
|
||||
import { ActionIcon } from "@mantine/core";
|
||||
import { useMediaQuery } from "@mantine/hooks";
|
||||
|
||||
import { Banner } from "../components/Banner";
|
||||
import { SummaryCards } from "../components/SummaryCards";
|
||||
import { WaterItems } from "../components/WaterItems";
|
||||
import { WaterChart } from "../components/WaterChart";
|
||||
import { useWaterData } from "../hooks/useWaterData";
|
||||
import classes from "../assets/Dashboard.module.css";
|
||||
|
||||
const chartConfigs = [
|
||||
{
|
||||
title: "pH变化趋势",
|
||||
key: "ph" as const,
|
||||
min: 0,
|
||||
max: 14,
|
||||
},
|
||||
{
|
||||
title: "TDS变化趋势",
|
||||
key: "tds" as const,
|
||||
min: 0,
|
||||
max: 100,
|
||||
},
|
||||
{
|
||||
title: "浊度变化趋势",
|
||||
key: "turbidity" as const,
|
||||
min: 0,
|
||||
max: 1000,
|
||||
},
|
||||
];
|
||||
|
||||
export default function Dashboard({
|
||||
onMenuClick,
|
||||
}: {
|
||||
onMenuClick?: () => void;
|
||||
mobileNavOpen?: boolean;
|
||||
}) {
|
||||
const isMobile = useMediaQuery("(max-width: 768px)");
|
||||
const { data, error, isLoading, refetch } = useWaterData();
|
||||
|
||||
if (!data) {
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
height: "100vh",
|
||||
flexDirection: "column",
|
||||
gap: "16px",
|
||||
}}
|
||||
>
|
||||
{error ? (
|
||||
<>
|
||||
<div style={{ color: "red", fontSize: "16px" }}>{error}</div>
|
||||
<button
|
||||
onClick={() => void refetch()}
|
||||
style={{
|
||||
padding: "8px 16px",
|
||||
backgroundColor: "#1976d2",
|
||||
color: "white",
|
||||
border: "none",
|
||||
borderRadius: "4px",
|
||||
cursor: "pointer",
|
||||
}}
|
||||
>
|
||||
重试
|
||||
</button>
|
||||
</>
|
||||
) : (
|
||||
<div>{isLoading ? "加载中..." : "暂无数据"}</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const history = data.data.slice(-100);
|
||||
const time = history.map((item) => item.time.substring(11, 19));
|
||||
|
||||
return (
|
||||
<div className={classes.page}>
|
||||
<Banner
|
||||
menuButton={
|
||||
isMobile ? (
|
||||
<ActionIcon
|
||||
variant="light"
|
||||
onClick={onMenuClick}
|
||||
aria-label="Toggle navigation"
|
||||
>
|
||||
<IconMenu2 size={20} />
|
||||
</ActionIcon>
|
||||
) : null
|
||||
}
|
||||
/>
|
||||
|
||||
<main className={classes.container}>
|
||||
<SummaryCards data={data} />
|
||||
<WaterItems data={data.score} />
|
||||
|
||||
<section className={classes.chartGrid}>
|
||||
{chartConfigs.map((config) => (
|
||||
<WaterChart
|
||||
key={config.title}
|
||||
title={config.title}
|
||||
time={time}
|
||||
data={history.map((item) => item[config.key])}
|
||||
min={config.min}
|
||||
max={config.max}
|
||||
/>
|
||||
))}
|
||||
</section>
|
||||
</main>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
export interface WaterItem {
|
||||
value: number;
|
||||
level: string;
|
||||
score: number;
|
||||
}
|
||||
|
||||
export interface WaterScore {
|
||||
score: number;
|
||||
level: string;
|
||||
abnormal: boolean;
|
||||
|
||||
ph: WaterItem;
|
||||
tds: WaterItem;
|
||||
turbidity: WaterItem;
|
||||
}
|
||||
|
||||
export interface WaterData {
|
||||
|
||||
code: number;
|
||||
|
||||
time: string;
|
||||
|
||||
score: WaterScore;
|
||||
|
||||
data: Array<{
|
||||
time: string;
|
||||
ph: number;
|
||||
tds: number;
|
||||
turbidity: number;
|
||||
}>;
|
||||
}
|
||||
@@ -1,403 +0,0 @@
|
||||
/* ===========================
|
||||
Global
|
||||
=========================== */
|
||||
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
font-family: "Microsoft YaHei", Arial, sans-serif;
|
||||
}
|
||||
|
||||
html,
|
||||
body {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
background: #eef3f8;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
/* ===========================
|
||||
Banner
|
||||
=========================== */
|
||||
|
||||
.banner {
|
||||
|
||||
height: 11vh;
|
||||
|
||||
min-height: 90px;
|
||||
|
||||
background: linear-gradient(90deg, #1565c0, #2196f3);
|
||||
|
||||
color: white;
|
||||
|
||||
display: flex;
|
||||
|
||||
justify-content: space-between;
|
||||
|
||||
align-items: center;
|
||||
|
||||
padding: 0 2vw;
|
||||
|
||||
box-shadow: 0 3px 12px rgba(0, 0, 0, .18);
|
||||
|
||||
flex-shrink: 0;
|
||||
|
||||
}
|
||||
|
||||
.banner-title {
|
||||
|
||||
font-size: clamp(30px, 2vw, 52px);
|
||||
|
||||
font-weight: bold;
|
||||
|
||||
letter-spacing: 2px;
|
||||
|
||||
}
|
||||
|
||||
.banner-subtitle {
|
||||
|
||||
margin-top: .5vh;
|
||||
|
||||
opacity: .9;
|
||||
|
||||
font-size: clamp(14px, .9vw, 22px);
|
||||
|
||||
}
|
||||
|
||||
.banner-right {
|
||||
|
||||
text-align: right;
|
||||
|
||||
}
|
||||
|
||||
.clock-title {
|
||||
|
||||
font-size: clamp(16px, 1vw, 24px);
|
||||
|
||||
}
|
||||
|
||||
.clock {
|
||||
|
||||
margin-top: .6vh;
|
||||
|
||||
font-size: clamp(28px, 2vw, 46px);
|
||||
|
||||
font-weight: bold;
|
||||
|
||||
}
|
||||
|
||||
/* ===========================
|
||||
Main
|
||||
=========================== */
|
||||
|
||||
.container {
|
||||
|
||||
flex: 1;
|
||||
|
||||
display: flex;
|
||||
|
||||
flex-direction: column;
|
||||
|
||||
gap: 1.2vh;
|
||||
|
||||
padding: 1.2vh 1.2vw;
|
||||
|
||||
min-height: 0;
|
||||
|
||||
}
|
||||
|
||||
/* ===========================
|
||||
Summary Cards
|
||||
=========================== */
|
||||
|
||||
.cards {
|
||||
|
||||
display: grid;
|
||||
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
|
||||
gap: 1vw;
|
||||
|
||||
}
|
||||
|
||||
.card {
|
||||
|
||||
background: white;
|
||||
|
||||
border-radius: 16px;
|
||||
|
||||
padding: 1.2vw;
|
||||
|
||||
box-shadow: 0 4px 10px rgba(0, 0, 0, .08);
|
||||
|
||||
}
|
||||
|
||||
.card-title {
|
||||
|
||||
color: #666;
|
||||
|
||||
font-size: clamp(18px, 1vw, 28px);
|
||||
|
||||
}
|
||||
|
||||
.card-value {
|
||||
|
||||
margin-top: 1vh;
|
||||
|
||||
font-size: clamp(36px, 2.3vw, 64px);
|
||||
|
||||
font-weight: bold;
|
||||
|
||||
}
|
||||
|
||||
.black {
|
||||
|
||||
color: #111;
|
||||
|
||||
}
|
||||
|
||||
.normal {
|
||||
|
||||
color: #2ecc71;
|
||||
|
||||
}
|
||||
|
||||
.abnormal {
|
||||
|
||||
color: #e74c3c;
|
||||
|
||||
}
|
||||
|
||||
.update-time {
|
||||
|
||||
margin-top: 1vh;
|
||||
|
||||
font-size: clamp(18px, 1.1vw, 30px);
|
||||
|
||||
color: #333;
|
||||
|
||||
}
|
||||
|
||||
/* ===========================
|
||||
Items
|
||||
=========================== */
|
||||
|
||||
.items {
|
||||
|
||||
display: grid;
|
||||
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
|
||||
gap: 1vw;
|
||||
|
||||
}
|
||||
|
||||
.item {
|
||||
|
||||
background: white;
|
||||
|
||||
border-radius: 16px;
|
||||
|
||||
padding: 1.2vw;
|
||||
|
||||
text-align: center;
|
||||
|
||||
box-shadow: 0 4px 10px rgba(0, 0, 0, .08);
|
||||
|
||||
}
|
||||
|
||||
.item-name {
|
||||
|
||||
font-size: clamp(22px, 1.3vw, 36px);
|
||||
|
||||
font-weight: bold;
|
||||
|
||||
}
|
||||
|
||||
.value {
|
||||
|
||||
margin-top: 1vh;
|
||||
|
||||
color: #1976d2;
|
||||
|
||||
font-size: clamp(48px, 3vw, 84px);
|
||||
|
||||
font-weight: bold;
|
||||
|
||||
}
|
||||
|
||||
.level {
|
||||
|
||||
margin-top: 1vh;
|
||||
|
||||
font-size: clamp(22px, 1.2vw, 30px);
|
||||
|
||||
}
|
||||
|
||||
.score {
|
||||
|
||||
margin-top: .5vh;
|
||||
|
||||
color: #666;
|
||||
|
||||
font-size: clamp(18px, 1vw, 26px);
|
||||
|
||||
}
|
||||
|
||||
/* ===========================
|
||||
Charts
|
||||
=========================== */
|
||||
|
||||
.chart-grid {
|
||||
|
||||
flex: 1;
|
||||
|
||||
display: grid;
|
||||
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
|
||||
gap: 1vw;
|
||||
|
||||
min-height: 0;
|
||||
|
||||
}
|
||||
|
||||
.chart {
|
||||
|
||||
background: white;
|
||||
|
||||
border-radius: 16px;
|
||||
|
||||
display: flex;
|
||||
|
||||
flex-direction: column;
|
||||
|
||||
box-shadow: 0 4px 10px rgba(0, 0, 0, .08);
|
||||
|
||||
min-height: 0;
|
||||
|
||||
}
|
||||
|
||||
.chart-title {
|
||||
|
||||
padding: 16px 20px;
|
||||
|
||||
border-bottom: 1px solid #e6e6e6;
|
||||
|
||||
font-size: clamp(22px, 1.3vw, 34px);
|
||||
|
||||
font-weight: bold;
|
||||
|
||||
color: #333;
|
||||
|
||||
flex-shrink: 0;
|
||||
|
||||
}
|
||||
|
||||
.chart-body {
|
||||
|
||||
flex: 1;
|
||||
|
||||
min-height: 0;
|
||||
|
||||
padding: 12px;
|
||||
|
||||
}
|
||||
|
||||
#phChart,
|
||||
#tdsChart,
|
||||
#turbidityChart {
|
||||
|
||||
width: 100%;
|
||||
|
||||
height: 100%;
|
||||
|
||||
}
|
||||
|
||||
/* ===========================
|
||||
Footer
|
||||
=========================== */
|
||||
|
||||
.footer {
|
||||
|
||||
height: 3.5vh;
|
||||
|
||||
min-height: 28px;
|
||||
|
||||
display: flex;
|
||||
|
||||
justify-content: center;
|
||||
|
||||
align-items: center;
|
||||
|
||||
color: #666;
|
||||
|
||||
font-size: clamp(12px, .8vw, 18px);
|
||||
|
||||
background: white;
|
||||
|
||||
border-top: 1px solid #ddd;
|
||||
|
||||
flex-shrink: 0;
|
||||
|
||||
}
|
||||
|
||||
/* ===========================
|
||||
Responsive
|
||||
=========================== */
|
||||
|
||||
@media (max-width: 1400px) {
|
||||
|
||||
.cards {
|
||||
|
||||
gap: .8vw;
|
||||
|
||||
}
|
||||
|
||||
.items {
|
||||
|
||||
gap: .8vw;
|
||||
|
||||
}
|
||||
|
||||
.chart-grid {
|
||||
|
||||
gap: .8vw;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@media (max-width: 1100px) {
|
||||
|
||||
.cards {
|
||||
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
|
||||
}
|
||||
|
||||
.items {
|
||||
|
||||
grid-template-columns: 1fr;
|
||||
|
||||
}
|
||||
|
||||
.chart-grid {
|
||||
|
||||
grid-template-columns: 1fr;
|
||||
|
||||
}
|
||||
|
||||
body {
|
||||
|
||||
overflow: auto;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
/** @type {import('tailwindcss').Config} */
|
||||
export default {
|
||||
content: [
|
||||
"./index.html",
|
||||
"./src/**/*.{js,ts,jsx,tsx}",
|
||||
],
|
||||
theme: {
|
||||
extend: {},
|
||||
},
|
||||
plugins: [],
|
||||
};
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
||||
"target": "es2023",
|
||||
"lib": ["ES2023", "DOM"],
|
||||
"module": "esnext",
|
||||
"types": ["vite/client"],
|
||||
"allowArbitraryExtensions": true,
|
||||
"skipLibCheck": true,
|
||||
|
||||
/* Bundler mode */
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
"moduleDetection": "force",
|
||||
"noEmit": true,
|
||||
"jsx": "react-jsx",
|
||||
|
||||
/* Linting */
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"erasableSyntaxOnly": true,
|
||||
"noFallthroughCasesInSwitch": true
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"files": [],
|
||||
"references": [
|
||||
{ "path": "./tsconfig.app.json" },
|
||||
{ "path": "./tsconfig.node.json" }
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
||||
"target": "es2023",
|
||||
"lib": ["ES2023"],
|
||||
"types": ["node"],
|
||||
"skipLibCheck": true,
|
||||
|
||||
/* Bundler mode */
|
||||
"module": "nodenext",
|
||||
"allowImportingTsExtensions": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
"moduleDetection": "force",
|
||||
"noEmit": true,
|
||||
|
||||
/* Linting */
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"erasableSyntaxOnly": true,
|
||||
"noFallthroughCasesInSwitch": true
|
||||
},
|
||||
"include": ["vite.config.ts"]
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import react from '@vitejs/plugin-react'
|
||||
import tailwindcss from "@tailwindcss/vite";
|
||||
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
react(),
|
||||
tailwindcss()
|
||||
],
|
||||
})
|
||||
Reference in new issue
Block a user