feat: local Bootstrap Vue ECharts dashboards and universal genealogy write scope
This commit is contained in:
+5
-1
@@ -1,6 +1,6 @@
|
||||
# 赵府 Vue 前端
|
||||
|
||||
Vue 3 + Vite + Bootstrap 5。Python 服务提供 API 和本地静态资源;生产主机无需安装 Node。
|
||||
Vue 3 + Vite + Bootstrap 5 + Apache ECharts。Python 服务提供 API 和本地静态资源;生产主机无需安装 Node。
|
||||
|
||||
## 构建
|
||||
|
||||
@@ -19,12 +19,16 @@ pnpm --dir frontend build
|
||||
- `HomeExplorer`:账号独立的卡片布局、分页、排序及场所总拓扑。
|
||||
- `DeviceCollection`、`NetworkMap`:同一设备目录的卡片和拓扑视图。
|
||||
- `NetworkStatus`:授权设备的实时网络检查与后台入口,清理定时器并丢弃过期响应。
|
||||
- `LocalChart`、`HomeInsights`、`ScopeInsights`:本地 ECharts 场所及设备统计;按需加载,关闭页面释放实例,相同数据刷新不重排。手机首页默认收起详细统计。
|
||||
- `NetworkDiagram`:固定坐标网络图,支持平移、缩放和点击设备;下方详情提供键盘及读屏操作。平台总拓扑与设备拓扑只使用当前账号已授权数据,不虚构在线率或历史曲线。
|
||||
- `Workspace`、`RuntimeOverlays`:现有业务页面与表单模板。
|
||||
- `composables/bridge.js`、`web/vue-bridge.js`:Vue 与现有业务控制器的状态边界。
|
||||
- `compat/scripts.json`:旧业务控制器依赖顺序,按顺序加载。视频播放器、家谱、记事等复杂交互暂时保留原控制器;尚未全部迁为 Vue 状态管理。
|
||||
|
||||
Vue 管理家庭卡片、设备列表、网络拓扑的 DOM;旧控制器只发布数据,不再覆盖这些容器。表单及播放器的兼容容器由原控制器管理,Vue 不重建其内部节点,避免轮询时重建视频。`web/index.html` 已移除,模板以 Vue 组件为准。
|
||||
|
||||
ECharts 使用 npm 包按需打包饼图、柱图、关系图和 Canvas 渲染器。生产 `/ui/assets/` 内包含全部框架、样式和图表代码;没有远程 CDN、远程字体或地图服务依赖。外部媒体与设备后台链接仍按业务配置访问。原有播放器和家谱关系图保留现有控制器。许可证及 NOTICE 收录于 `THIRD-PARTY-LICENSES.txt`。
|
||||
|
||||
## 网络状态
|
||||
|
||||
`GET /api/devices/network?source=device|camera|recorder&id=...` 只允许当前家庭管理员与超级管理员检查本归属下的已登记设备。端口探测与 Tailscale 节点状态分别显示,30 秒缓存、并发限制;用户输入不能指定任意检查目标。只连接 TCP 端口,不修改设备、不发送登录密码。
|
||||
|
||||
@@ -44,3 +44,279 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
|
||||
echarts
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed 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.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
========================================================================
|
||||
Apache ECharts Subcomponents:
|
||||
|
||||
The Apache ECharts project contains subcomponents with separate copyright
|
||||
notices and license terms. Your use of the source code for these
|
||||
subcomponents is also subject to the terms and conditions of the following
|
||||
licenses.
|
||||
|
||||
BSD 3-Clause (d3.js):
|
||||
The following files embed [d3.js](https://github.com/d3/d3) BSD 3-Clause:
|
||||
`/src/chart/treemap/treemapLayout.ts`,
|
||||
`/src/chart/tree/layoutHelper.ts`,
|
||||
`/src/chart/graph/forceHelper.ts`,
|
||||
`/src/util/number.ts`
|
||||
See `/licenses/LICENSE-d3` for details of the license.
|
||||
|
||||
Apache ECharts
|
||||
Copyright 2017-2026 The Apache Software Foundation
|
||||
|
||||
This product includes software developed at
|
||||
The Apache Software Foundation (https://www.apache.org/).
|
||||
|
||||
zrender
|
||||
BSD 3-Clause License
|
||||
|
||||
Copyright (c) 2017, Baidu Inc.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
tslib
|
||||
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.
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "zhao-steward-ui",
|
||||
"private": true,
|
||||
"version": "0.1.42",
|
||||
"version": "0.1.43",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "vite build",
|
||||
@@ -9,6 +9,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"bootstrap": "5.3.8",
|
||||
"echarts": "6.1.0",
|
||||
"vue": "^3.5.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
Generated
+23
@@ -11,6 +11,9 @@ importers:
|
||||
bootstrap:
|
||||
specifier: 5.3.8
|
||||
version: 5.3.8(@popperjs/core@2.11.8)
|
||||
echarts:
|
||||
specifier: 6.1.0
|
||||
version: 6.1.0
|
||||
vue:
|
||||
specifier: ^3.5.0
|
||||
version: 3.5.43
|
||||
@@ -396,6 +399,9 @@ packages:
|
||||
csstype@3.2.3:
|
||||
resolution: {integrity: sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==}
|
||||
|
||||
echarts@6.1.0:
|
||||
resolution: {integrity: sha512-q0yaFPggC9FUdsWH4blavRWFmxdrIodbkoKNAjJudAI6CA9gNPxHtV2RcZNEepZVlk4yvBYkOkbk6HIVpIyHZA==}
|
||||
|
||||
entities@7.0.1:
|
||||
resolution: {integrity: sha512-TWrgLOFUQTH994YUyl1yT4uyavY5nNB5muff+RtWaqNVCAK408b5ZnnbNAUEWLTCpum9w6arT70i1XdQ4UeOPA==}
|
||||
engines: {node: '>=0.12'}
|
||||
@@ -454,6 +460,9 @@ packages:
|
||||
resolution: {integrity: sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==}
|
||||
engines: {node: '>=12.0.0'}
|
||||
|
||||
tslib@2.3.0:
|
||||
resolution: {integrity: sha512-N82ooyxVNm6h1riLCoyS9e3fuJ3AMG2zIZs2Gd1ATcSFjSA23Q0fzjjZeh0jbJvWVDZ0cJT8yaNNaaXHzueNjg==}
|
||||
|
||||
vite@7.3.6:
|
||||
resolution: {integrity: sha512-4XP60spRGjSZFf1qYH+dJIkK2znL3zQfl9KkOV9MkkRR/3Dls0dxaBsQPTloEc5BLXWPL9vsOxopxyKoMmDueg==}
|
||||
engines: {node: ^20.19.0 || >=22.12.0}
|
||||
@@ -502,6 +511,9 @@ packages:
|
||||
typescript:
|
||||
optional: true
|
||||
|
||||
zrender@6.1.0:
|
||||
resolution: {integrity: sha512-oEGMDB6pOP2S6OwRR4PdVv610zrjnA3Bh+JnSG12fYJlBKjtNAoEb5fSUoCOOINlH96I2fU38/A2UpRKs67xYQ==}
|
||||
|
||||
snapshots:
|
||||
|
||||
'@babel/helper-string-parser@7.29.7': {}
|
||||
@@ -747,6 +759,11 @@ snapshots:
|
||||
|
||||
csstype@3.2.3: {}
|
||||
|
||||
echarts@6.1.0:
|
||||
dependencies:
|
||||
tslib: 2.3.0
|
||||
zrender: 6.1.0
|
||||
|
||||
entities@7.0.1: {}
|
||||
|
||||
esbuild@0.28.2:
|
||||
@@ -842,6 +859,8 @@ snapshots:
|
||||
fdir: 6.5.0(picomatch@4.0.7)
|
||||
picomatch: 4.0.7
|
||||
|
||||
tslib@2.3.0: {}
|
||||
|
||||
vite@7.3.6:
|
||||
dependencies:
|
||||
esbuild: 0.28.2
|
||||
@@ -860,3 +879,7 @@ snapshots:
|
||||
'@vue/runtime-dom': 3.5.43
|
||||
'@vue/server-renderer': 3.5.43
|
||||
'@vue/shared': 3.5.43
|
||||
|
||||
zrender@6.1.0:
|
||||
dependencies:
|
||||
tslib: 2.3.0
|
||||
|
||||
@@ -15,6 +15,6 @@ export function enhance(root){
|
||||
export async function loadControllers(){
|
||||
enhance(document.getElementById('app'))
|
||||
new MutationObserver(records=>{for(const record of records)for(const node of record.addedNodes)enhance(node)}).observe(document.getElementById('app'),{childList:true,subtree:true})
|
||||
for(const path of [...scripts,'/vue-bridge.js'])await new Promise((resolve,reject)=>{const script=document.createElement('script');script.src=path+'?ui=0.1.42';script.onload=resolve;script.onerror=()=>reject(new Error('Could not load '+path));document.head.append(script)})
|
||||
for(const path of [...scripts,'/vue-bridge.js'])await new Promise((resolve,reject)=>{const script=document.createElement('script');script.src=path+'?ui=0.1.43';script.onload=resolve;script.onerror=()=>reject(new Error('Could not load '+path));document.head.append(script)})
|
||||
await window.ZhaoVue.boot()
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ import { computed, ref, watch } from "vue";
|
||||
import { snapshot, bridge, accessLabel } from "../composables/bridge.js";
|
||||
import AppIcon from "./AppIcon.vue";
|
||||
import HomeInsights from "./HomeInsights.vue";
|
||||
import LocalChart from "./LocalChart.vue";
|
||||
import { platformChart } from "../composables/charts.mjs";
|
||||
const draft = ref({
|
||||
revision: 0,
|
||||
columns: 2,
|
||||
@@ -369,6 +371,9 @@ async function enter(h, network = false) {
|
||||
<p class="description">
|
||||
平台与场所的管理关系;进入场所查看内部设备及网络。
|
||||
</p>
|
||||
<div v-if="homes.length" class="chart-network-surface mb-3">
|
||||
<LocalChart :option="platformChart(homes, snapshot.brandName || '赵府')" :active="snapshot.loggedIn && snapshot.page === 'households' && mode === 'topology'" :height="340" label="平台及已授权场所关系图;点击场所进入内部网络,下面也可通过卡片进入。" @select="id => enter({id}, true)" />
|
||||
</div>
|
||||
<div class="platform-place-grid">
|
||||
<button
|
||||
v-for="h in homes"
|
||||
|
||||
@@ -1,33 +1,33 @@
|
||||
<script setup>
|
||||
import { computed } from 'vue';
|
||||
import { computed, ref } from 'vue';
|
||||
import { snapshot } from '../composables/bridge.js';
|
||||
import { summarizeHomes } from '../composables/insights.mjs';
|
||||
import { distribution, bars } from '../composables/charts.mjs';
|
||||
import LocalChart from './LocalChart.vue';
|
||||
import AppIcon from './AppIcon.vue';
|
||||
const summary = computed(() => summarizeHomes(snapshot.value.state.households));
|
||||
const expanded = ref(false);
|
||||
const active = computed(() => snapshot.value.loggedIn && snapshot.value.page === 'households');
|
||||
const places = computed(() => (snapshot.value.state.households || []).map(h => ({ label: h.name, count: h.deviceCount || 0 })).sort((a,b) => b.count-a.count).slice(0, 8));
|
||||
</script>
|
||||
<template>
|
||||
<section class="home-insights" aria-label="已授权场所概览">
|
||||
<article class="insight-welcome">
|
||||
<section class="dashboard-grid row g-3 mb-4" :class="{'charts-expanded':expanded}" aria-label="已授权场所概览">
|
||||
<div class="col-12 col-xl-4"><article class="dashboard-welcome h-100">
|
||||
<span class="insight-kicker">一处相连 · 各有归属</span>
|
||||
<h2>家与日常,尽在掌握</h2>
|
||||
<p>从一个空间出发,照看设备,也珍藏生活。</p>
|
||||
<h2>家与日常,尽在掌握</h2><p>从一处灯火,连接生活的每个空间。</p>
|
||||
<div class="dashboard-totals"><div><strong>{{ summary.total }}</strong><span>家庭与场所</span></div><div><strong>{{ summary.devices }}</strong><span>已登记设备</span></div><div><strong>{{ summary.areas }}</strong><span>区域空间</span></div></div>
|
||||
<div class="insight-scope"><AppIcon name="shield" /> 仅汇总你有权访问的家庭与场所</div>
|
||||
</article>
|
||||
<article class="insight-number">
|
||||
<span class="insight-icon"><AppIcon name="devices" /></span>
|
||||
<span class="insight-label">已登记设备</span>
|
||||
<strong>{{ summary.devices }}<small>台</small></strong>
|
||||
<span class="insight-foot">分布在 {{ summary.areas }} 处区域</span>
|
||||
</article>
|
||||
<article class="insight-distribution">
|
||||
<div class="insight-donut">
|
||||
<svg viewBox="0 0 120 120" role="img" :aria-label="'场所分布:' + (summary.kinds.map(k => k.label + k.count + '个').join(',') || '暂无场所')">
|
||||
<circle class="donut-track" cx="60" cy="60" r="48" fill="none" stroke-width="10" />
|
||||
<circle v-for="kind in summary.kinds" :key="kind.key" cx="60" cy="60" r="48" fill="none" stroke-width="10" pathLength="100" :stroke="kind.color" :stroke-dasharray="`${kind.share} ${100 - kind.share}`" :stroke-dashoffset="-kind.offset" transform="rotate(-90 60 60)" />
|
||||
</svg>
|
||||
<div aria-hidden="true"><strong>{{ summary.total }}</strong><small>家庭与场所</small></div>
|
||||
</div>
|
||||
<div class="insight-legend"><h3>空间分布</h3><span v-for="kind in summary.kinds" :key="kind.key"><i :style="{ background: kind.color }"></i>{{ kind.label }}<b>{{ kind.count }}</b></span><span v-if="!summary.total">等待添加空间</span></div>
|
||||
</article>
|
||||
</article></div>
|
||||
<div class="col-12 d-md-none"><button class="btn btn-outline-secondary w-100" :aria-expanded="expanded" @click="expanded=!expanded">{{ expanded?'收起图表统计':'展开图表统计' }}</button></div>
|
||||
<div class="col-12 col-md-5 col-xl-3 dashboard-chart-column"><article class="chart-card h-100"><div class="chart-heading"><h3>空间分布</h3><span class="badge">{{ summary.total }} 处</span></div>
|
||||
<LocalChart v-if="summary.total" :option="distribution(summary.kinds)" :active="active" :height="160" :label="'场所分布:'+summary.kinds.map(k=>k.label+k.count+'个').join(',')" />
|
||||
<p v-else class="chart-empty">添加家庭或场所后显示分布</p>
|
||||
<div class="chart-legend"><span v-for="k in summary.kinds" :key="k.key"><i :style="{background:k.color}"></i>{{ k.label }} <b>{{ k.count }}</b></span></div>
|
||||
</article></div>
|
||||
<div class="col-12 col-md-7 col-xl-5 dashboard-chart-column"><article class="chart-card h-100"><div class="chart-heading"><h3>设备分布</h3><span class="small text-secondary">按场所 · 最多显示 8 处</span></div>
|
||||
<LocalChart v-if="places.length" :option="bars(places)" :active="active" :height="190" :label="'各场所已登记设备:'+places.map(x=>x.label+x.count+'台').join(',')" />
|
||||
<p v-else class="chart-empty">暂无已授权场所</p>
|
||||
<details v-if="places.length" class="chart-data"><summary>查看统计数字</summary><ul><li v-for="p in places" :key="p.label">{{ p.label }}:{{ p.count }} 台</li></ul></details>
|
||||
</article></div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
<script setup>
|
||||
import { ref, onMounted, onBeforeUnmount, watch } from 'vue';
|
||||
const props = defineProps({ option: { type: Object, required: true }, label: String, active: { type: Boolean, default: true }, height: { type: Number, default: 260 } });
|
||||
const emit = defineEmits(['select']);
|
||||
const host = ref(null), failed = ref(false);
|
||||
let chart, resizeObserver, themeObserver, frame, alive = true, loading = false, last = '', size = '';
|
||||
function dispose() { chart?.dispose(); chart = null; last = ''; size = ''; }
|
||||
function queue() { if (!frame && alive) frame = requestAnimationFrame(() => { frame = null; render(); }); }
|
||||
async function render() {
|
||||
if (!alive || !host.value || !props.active) { dispose(); return; }
|
||||
const width = Math.floor(host.value.clientWidth), height = Math.floor(host.value.clientHeight);
|
||||
if (!width || !height) return;
|
||||
if (!chart) {
|
||||
if (loading) return;
|
||||
loading = true;
|
||||
try {
|
||||
const runtime = await import('../composables/charts-runtime.js');
|
||||
if (!alive || !props.active || !host.value) return;
|
||||
chart = runtime.init(host.value, null, { renderer: 'canvas', devicePixelRatio: Math.min(window.devicePixelRatio || 1, 2) });
|
||||
chart.on('click', value => { if (value.data?.targetId) emit('select', value.data.targetId); });
|
||||
failed.value = false;
|
||||
} catch (error) { failed.value = true; console.error('Local chart unavailable', error); return; }
|
||||
finally { loading = false; }
|
||||
}
|
||||
const css = getComputedStyle(document.documentElement), ink = css.getPropertyValue('--ink').trim() || '#253b46', muted = css.getPropertyValue('--ui-muted').trim() || '#627485', line = css.getPropertyValue('--ui-line').trim() || '#e3e9ef';
|
||||
const fingerprint = JSON.stringify(props.option) + ink + muted + line;
|
||||
// Periodic status refreshes must not restart chart layout/animation.
|
||||
if (fingerprint !== last) {
|
||||
const option = { ...props.option, animation: false, backgroundColor: 'transparent', textStyle: { color: ink, fontFamily: 'system-ui, Microsoft YaHei, sans-serif' }, aria: { enabled: true, description: props.label }, tooltip: { trigger: 'item', renderMode: 'richText', confine: true, ...props.option.tooltip } };
|
||||
for (const axis of ['xAxis', 'yAxis']) if (option[axis]) option[axis] = { ...option[axis], axisLabel: { color: muted, ...option[axis].axisLabel }, splitLine: { lineStyle: { color: line } } };
|
||||
option.series = (option.series || []).map(series => ({ ...series, label: { color: ink, ...series.label } }));
|
||||
chart.setOption(option, { notMerge: true, lazyUpdate: false }); last = fingerprint;
|
||||
}
|
||||
const nextSize = width + ':' + height;
|
||||
if (nextSize !== size) { chart.resize({ width, height }); size = nextSize; }
|
||||
}
|
||||
watch(() => [props.option, props.active], queue, { deep: true, flush: 'post' });
|
||||
onMounted(() => {
|
||||
resizeObserver = new ResizeObserver(queue); resizeObserver.observe(host.value);
|
||||
themeObserver = new MutationObserver(queue); themeObserver.observe(document.documentElement, { attributes: true, attributeFilter: ['data-theme', 'data-density'] });
|
||||
queue();
|
||||
});
|
||||
onBeforeUnmount(() => { alive = false; cancelAnimationFrame(frame); resizeObserver?.disconnect(); themeObserver?.disconnect(); dispose(); });
|
||||
</script>
|
||||
<template>
|
||||
<div class="local-chart-wrap">
|
||||
<div ref="host" class="local-chart" role="img" :aria-label="label" :style="{ height: height + 'px' }"></div>
|
||||
<p v-if="failed" class="small text-secondary px-3" role="status">图表暂未加载,可查看下方数据。</p>
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,31 +1,18 @@
|
||||
<script setup>
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { deviceView, snapshot, bridge, accessLabel } from '../composables/bridge.js';
|
||||
import { layoutNetwork } from '../composables/insights.mjs';
|
||||
const zoom = ref(1);
|
||||
const graph = computed(() => layoutNetwork(deviceView.value.rows));
|
||||
watch(() => snapshot.value.session + ':' + snapshot.value.state.familyId, () => { zoom.value = 1; });
|
||||
const open = node => bridge().enterDevice(node.device.source, node.device.id, 'device');
|
||||
import { deviceView, snapshot, bridge } from '../composables/bridge.js';
|
||||
import { networkChart } from '../composables/charts.mjs';
|
||||
import LocalChart from './LocalChart.vue';
|
||||
const resetKey = ref(0);
|
||||
const option = computed(() => networkChart(deviceView.value.rows, bridge().location));
|
||||
const active = computed(() => snapshot.value.loggedIn && snapshot.value.page === 'objects' && deviceView.value.mode === 'topology');
|
||||
watch(() => snapshot.value.session + ':' + snapshot.value.state.familyId, () => resetKey.value++);
|
||||
function open(id) { const row = deviceView.value.rows.find(r => r.device.id === id); if (row) bridge().enterDevice(row.device.source, id, 'device'); }
|
||||
</script>
|
||||
<template>
|
||||
<div v-if="graph.nodes.length" class="network-diagram">
|
||||
<div class="diagram-toolbar">
|
||||
<div><span class="diagram-dot"></span><strong>设备连接图</strong><span class="small text-secondary">{{ graph.nodes.length }} 台设备 · {{ graph.edges.length }} 条已登记连接</span></div>
|
||||
<label>缩放<select v-model.number="zoom" class="form-select form-select-sm" aria-label="网络图缩放"><option :value="0.75">75%</option><option :value="1">100%</option><option :value="1.25">125%</option></select></label>
|
||||
</div>
|
||||
<div class="diagram-scroll" tabindex="0" role="region" aria-label="设备连接图,可滚动查看;点击设备打开档案">
|
||||
<svg :width="graph.width * zoom" :height="graph.height * zoom" :viewBox="`0 0 ${graph.width} ${graph.height}`" class="network-svg" role="group" aria-label="已登记的网络连接">
|
||||
<path v-for="edge in graph.edges" :key="edge.id" :d="edge.path" class="network-edge" fill="none" />
|
||||
<g v-for="node in graph.nodes" :key="node.device.id" :transform="`translate(${node.x},${node.y})`" class="diagram-node" role="button" tabindex="0" :aria-label="node.device.name + ',打开设备档案'" @click="open(node)" @keydown.enter.prevent="open(node)" @keydown.space.prevent="open(node)">
|
||||
<title>{{ node.device.name }} · {{ node.device.deviceType }} · {{ (node.device.networkHosts || []).join(' / ') || 'IP 待填写' }}</title>
|
||||
<rect width="244" height="88" rx="12" class="diagram-node-bg" />
|
||||
<rect x="12" y="16" width="4" height="54" rx="2" :fill="node.device.source === 'camera' ? '#5c83cb' : '#258b76'" />
|
||||
<text x="28" y="26" class="diagram-node-type">{{ node.device.deviceType }} · {{ accessLabel(node.device.networkAccess) }}</text>
|
||||
<text x="28" y="48" class="diagram-node-title">{{ node.device.name.length > 14 ? node.device.name.slice(0, 14) + '…' : node.device.name }}</text>
|
||||
<text x="28" y="70" class="diagram-node-ip">{{ (node.device.networkHosts || [])[0] || 'IP 待填写' }}</text>
|
||||
</g>
|
||||
</svg>
|
||||
</div>
|
||||
<p class="diagram-note">点击节点查看名称、位置与网络详情。未登记上级的设备独立显示。</p>
|
||||
<div v-if="deviceView.rows.length" class="network-diagram">
|
||||
<div class="diagram-toolbar"><div><span class="diagram-dot"></span><strong>设备连接图</strong><span class="small text-secondary">{{ deviceView.rows.length }} 台设备 · {{ option.series[0].links.length }} 条已登记连接</span></div><button class="btn btn-sm btn-outline-secondary" @click="resetKey++">重置视图</button></div>
|
||||
<div class="chart-network-surface"><LocalChart :key="resetKey" :option="option" :active="active" :height="400" label="已登记设备连接图,可拖动缩放;下方设备详情提供相同信息及操作。" @select="open" /></div>
|
||||
<p class="diagram-note">拖动平移、滚轮或双指缩放;点击节点打开档案。未登记上级的设备独立显示;接入方式不代表在线状态。</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,14 @@
|
||||
<script setup>
|
||||
import { computed } from 'vue';
|
||||
import { snapshot } from '../composables/bridge.js';
|
||||
import { summarizeDevices, bars, distribution, palette } from '../composables/charts.mjs';
|
||||
import LocalChart from './LocalChart.vue';
|
||||
const summary = computed(() => summarizeDevices(snapshot.value.state));
|
||||
const active = computed(() => snapshot.value.loggedIn && snapshot.value.page === 'overview');
|
||||
</script>
|
||||
<template>
|
||||
<section class="row g-3 mb-4" aria-label="当前场所设备统计" v-if="active && summary.total">
|
||||
<div class="col-12 col-lg-7"><article class="chart-card h-100"><div class="chart-heading"><h3>设备类型</h3><span class="small text-secondary">{{ summary.total }} 台已授权设备</span></div><LocalChart :option="bars(summary.types.slice(0,8))" :height="220" :label="'设备类型:'+summary.types.map(x=>x.label+x.count+'台').join(',')" /><details class="chart-data"><summary>查看全部类型</summary><ul><li v-for="x in summary.types" :key="x.label">{{ x.label }}:{{ x.count }} 台</li></ul></details></article></div>
|
||||
<div class="col-12 col-lg-5"><article class="chart-card h-100"><div class="chart-heading"><h3>网络接入</h3><span class="small text-secondary">来自设备档案</span></div><LocalChart :option="distribution(summary.networks)" :height="190" :label="'登记的网络接入方式:'+summary.networks.map(x=>x.label+x.count+'台').join(',')" /><div class="chart-legend"><span v-for="(x,i) in summary.networks" :key="x.label"><i :style="{background:palette[i]}"></i>{{ x.label }} <b>{{ x.count }}</b></span></div><p class="small text-secondary mt-2 mb-0">接入方式不代表设备在线状态。</p></article></div>
|
||||
</section>
|
||||
</template>
|
||||
@@ -3,6 +3,7 @@ import HomeExplorer from './HomeExplorer.vue'
|
||||
import DeviceCollection from './DeviceCollection.vue'
|
||||
import NetworkMap from './NetworkMap.vue'
|
||||
import DeviceNetworkPanel from './DeviceNetworkPanel.vue'
|
||||
import ScopeInsights from './ScopeInsights.vue'
|
||||
</script>
|
||||
<template>
|
||||
|
||||
@@ -29,7 +30,7 @@ import DeviceNetworkPanel from './DeviceNetworkPanel.vue'
|
||||
<form id="journal-filter" class="panel journal-filters"><label>查看方式<select id="journal-mode"><option value="feed">家庭/场所动态</option><option value="mine">我的个人阅历</option><option value="person">某个人的阅历</option></select></label><label id="journal-person-label" hidden>人物<select id="journal-person"></select></label><label>分类<select id="journal-category"><option value="">全部分类</option><option>日常</option><option>成长</option><option>家庭</option><option>旅行</option><option>工作</option><option>其他</option></select></label><label>关键词<input id="journal-search" type="search" maxlength="120" placeholder="在文字中查找"></label><label>开始日期<input id="journal-from" type="date"></label><label>结束日期<input id="journal-to" type="date"></label><button type="submit">查询阅历</button><button id="journal-filter-clear" type="button" class="quiet">清除筛选</button></form><p class="description">个人阅历保留同一条记事的文字、附件和互动;查看他人时只展示其分享给当前家庭/场所的内容。删除记事或移出附件列表不会删除网盘原文件。</p><div class="section-head"><p id="journal-query-status" role="status"></p><div><button id="journal-prev" class="quiet">上一页</button><button id="journal-next" class="quiet">下一页</button></div></div><div id="journal-list" class="journal-feed"></div>
|
||||
</section>
|
||||
|
||||
<section id="page-overview" class="page" hidden><div id="scope-overview"></div></section><section id="page-device" class="page" hidden><DeviceNetworkPanel /><div id="device-detail"></div></section><section id="page-heritage" class="page" hidden><div id="heritage-home"></div></section>
|
||||
<section id="page-overview" class="page" hidden><ScopeInsights /><div id="scope-overview"></div></section><section id="page-device" class="page" hidden><DeviceNetworkPanel /><div id="device-detail"></div></section><section id="page-heritage" class="page" hidden><div id="heritage-home"></div></section>
|
||||
<section id="page-live" class="page"><div class="section-head"><h2 id="live-heading">本场所监控墙</h2><div><label>清晰度 <select id="quality"><option value="hd">主码流</option><option value="compat">子码流</option></select></label></div></div><details class="live-help"><summary>画面与清晰度说明</summary><p id="wall-context" class="description">这里汇总当前场所内已授权的镜头;点击摄像头详情可进入单台设备。</p><p class="description" id="quality-note">主码流画面更清晰,最高 1920×1080;子码流更流畅,最高 768×432,适合网络较慢时使用。</p></details><div class="wall-toolbar"><label>分屏 <select id="wall-layout"><option value="auto">自适应</option><option value="1">1 画面</option><option value="2">2 画面</option><option value="4">4 画面</option><option value="6">6 画面</option><option value="9">9 画面</option><option value="16">16 画面</option></select></label><label class="check"><input id="wall-arrange" type="checkbox">调整顺序</label><div class="wall-paging"><button id="wall-prev" class="quiet" aria-label="上一组画面">‹</button><span id="wall-page"></span><button id="wall-next" class="quiet" aria-label="下一组画面">›</button></div><span id="wall-clock"></span><button id="wall-fullscreen">全屏监控</button></div><div id="live-grid" class="live-grid"></div><section id="ptz-panel" class="ptz-panel" hidden><div><strong id="ptz-title">云台</strong><p id="ptz-status" role="status"></p></div><div class="ptz-pad"><button data-ptz-action="up" aria-label="云台向上">↑</button><button data-ptz-action="left" aria-label="云台向左">←</button><button data-ptz-action="stop">停止</button><button data-ptz-action="right" aria-label="云台向右">→</button><button data-ptz-action="down" aria-label="云台向下">↓</button></div><div id="ptz-presets"><div class="section-head"><strong>常用位置 <small id="preset-count"></small></strong><button id="preset-reload" class="quiet">重新读取</button></div><p id="preset-status" role="status"></p><div id="preset-list"></div><p class="description">调整位置后可另存为新预置位。本版不覆盖已有位置,避免设备固件拒绝或误改。</p><form id="preset-form" hidden><label>当前位置名称<input id="preset-name" required maxlength="40" placeholder="例如:大门、院子"></label><button type="submit">保存当前位置</button></form><div id="preset-confirmation" hidden><p id="preset-confirm-text"></p><button id="preset-confirm-yes">确认</button><button id="preset-confirm-cancel" class="quiet">取消</button></div></div><button id="ptz-close" class="quiet">收起云台</button></section></section>
|
||||
<section id="page-playback" class="page" hidden>
|
||||
<div class="section-head"><h2>回到那一刻 <small>光阴</small></h2></div>
|
||||
@@ -48,7 +49,7 @@ import DeviceNetworkPanel from './DeviceNetworkPanel.vue'
|
||||
<section id="page-family" class="page" hidden>
|
||||
<div class="section-head"><h2>家族的来处与延续 <small>世系 · 传承</small></h2><div><button id="family-reload" class="quiet">重新载入</button><button id="family-export" class="quiet">导出家谱</button><button id="new-person">+ 录入人物</button></div></div>
|
||||
<p class="description">从祖辈到后辈,一张图看全家。点击人物查看档案,暖金色卡片是当前账号关联的本人。</p>
|
||||
<div class="panel family-toolbar"><label>关系参照人物<select id="family-reference"></select></label><label>查找人物<input id="family-search" type="search" placeholder="姓名、别名或籍贯"></label><button id="family-find" class="quiet" hidden>定位搜索结果</button><label class="check"><input id="family-archived" type="checkbox">显示归档人物</label><span id="family-count"></span></div>
|
||||
<p id="family-edit-note" class="alert alert-info" role="status"></p><div class="panel family-toolbar"><label>关系参照人物<select id="family-reference"></select></label><label>查找人物<input id="family-search" type="search" placeholder="姓名、别名或籍贯"></label><button id="family-find" class="quiet" hidden>定位搜索结果</button><label class="check"><input id="family-archived" type="checkbox">显示归档人物</label><span id="family-count"></span></div>
|
||||
<div id="family-error" class="form-error" role="status"></div>
|
||||
<div id="family-workspace" class="family-workspace">
|
||||
<section id="family-canvas-panel" class="family-canvas-panel" aria-label="全家关系图">
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
// Bundled locally by Vite. No remote scripts, fonts, maps or CDN fallback.
|
||||
import { init, use } from 'echarts/core';
|
||||
import { PieChart, BarChart, GraphChart } from 'echarts/charts';
|
||||
import { TooltipComponent, GridComponent, AriaComponent } from 'echarts/components';
|
||||
import { CanvasRenderer } from 'echarts/renderers';
|
||||
use([PieChart, BarChart, GraphChart, TooltipComponent, GridComponent, AriaComponent, CanvasRenderer]);
|
||||
export { init };
|
||||
@@ -0,0 +1,32 @@
|
||||
// These builders accept only the current server-authorized snapshot.
|
||||
export const palette = ['#268575', '#648bcc', '#c49b5b', '#8e82b5', '#899aa5'];
|
||||
const count = value => Math.max(0, Math.floor(Number(value) || 0));
|
||||
export function distribution(items = []) {
|
||||
return { series: [{ type: 'pie', radius: ['62%', '84%'], center: ['50%', '50%'], avoidLabelOverlap: true, label: { show: false }, emphasis: { scale: false }, data: items.map((item, i) => ({ name: item.label, value: count(item.count), itemStyle: { color: item.color || palette[i % palette.length], borderRadius: 4 } })) }] };
|
||||
}
|
||||
export function bars(items = []) {
|
||||
return { grid: { left: 12, right: 35, top: 10, bottom: 12, containLabel: true }, xAxis: { type: 'value', minInterval: 1, axisTick: { show: false } }, yAxis: { type: 'category', inverse: true, axisTick: { show: false }, axisLine: { show: false }, axisLabel: { width: 90, overflow: 'truncate' }, data: items.map(x => x.label) }, series: [{ type: 'bar', barMaxWidth: 20, label: { show: true, position: 'right' }, data: items.map((x, i) => ({ value: count(x.count), itemStyle: { color: x.color || palette[i % palette.length], borderRadius: [0, 5, 5, 0] } })) }] };
|
||||
}
|
||||
export function summarizeDevices(state = {}) {
|
||||
const all = [...(state.assets || []).map(x => ({ ...x, deviceType: '摄像机' })), ...(state.recorders || []).map(x => ({ ...x, deviceType: '录像机' })), ...(state.devices || [])];
|
||||
const byType = new Map(), byNetwork = new Map();
|
||||
const names = { lan: '局域网', tailscale: 'Tailscale', public: '公网', unknown: '待登记' };
|
||||
for (const device of all) {
|
||||
const type = device.deviceType || '其他', network = names[device.networkAccess] || names.unknown;
|
||||
byType.set(type, (byType.get(type) || 0) + 1); byNetwork.set(network, (byNetwork.get(network) || 0) + 1);
|
||||
}
|
||||
const list = map => [...map].map(([label, count]) => ({ label, count })).sort((a,b) => b.count-a.count || a.label.localeCompare(b.label));
|
||||
return { total: all.length, types: list(byType), networks: list(byNetwork) };
|
||||
}
|
||||
export function graphOption(nodes, edges) {
|
||||
return { tooltip: { formatter: item => item.dataType === 'edge' ? '已登记的上级连接' : item.data.detail || item.name }, series: [{ type: 'graph', layout: 'none', roam: true, draggable: false, scaleLimit: { min: .2, max: 4 }, symbol: 'roundRect', symbolSize: [145, 60], edgeSymbol: ['none', 'arrow'], edgeSymbolSize: 6, label: { show: true, fontSize: 11, width: 128, overflow: 'truncate', formatter: item => item.data.caption || item.name }, lineStyle: { color: '#8aa99f', width: 2, curveness: .08 }, emphasis: { focus: 'adjacency', lineStyle: { width: 3 } }, data: nodes, links: edges }] };
|
||||
}
|
||||
export function networkChart(rows = [], location = () => '') {
|
||||
const ids = new Map(rows.map(r => [r.device.id, r]));
|
||||
const nodes = rows.map((r, i) => ({ id: r.device.id, targetId: r.device.id, name: r.device.name, caption: r.device.name + '\n' + ((r.device.networkHosts || [])[0] || 'IP 待填写'), detail: [r.device.name, r.device.deviceType, location(r.device.siteId) || '位置待登记', (r.device.networkHosts || []).join(' / ') || 'IP 待填写', { lan: '局域网', tailscale: 'Tailscale', public: '公网' }[r.device.networkAccess] || '接入待确认'].join('\n'), x: Math.max(0, r.depth || 0) * 280, y: i * 105, itemStyle: { color: r.device.source === 'camera' ? '#e1ebfb' : '#dceddf', borderColor: r.device.source === 'camera' ? '#648bcc' : '#468b73', borderWidth: 1 }, label: { color: '#213f48' } }));
|
||||
const edges = rows.flatMap(r => { const parent = ids.get(r.device.uplinkId); return parent && parent.depth + 1 === r.depth ? [{ source: parent.device.id, target: r.device.id }] : []; });
|
||||
return graphOption(nodes, edges);
|
||||
}
|
||||
export function platformChart(homes = [], name = '赵府') {
|
||||
return graphOption([{ id: 'platform', name, x: 0, y: 0, symbolSize: [160, 65], itemStyle: { color: '#286d5d' }, label: { color: '#fff' } }, ...homes.map((h, i) => ({ id: 'home:' + h.id, targetId: h.id, name: h.name, caption: h.name + '\n' + count(h.deviceCount) + ' 台设备', detail: [h.name, {home:'家庭',office:'办公',factory:'工厂'}[h.kind || 'home'] || '场所', [h.province,h.city,h.district].filter(Boolean).join(' · '), count(h.deviceCount) + ' 台已授权设备'].filter(Boolean).join('\n'), x: 300, y: (i - (homes.length-1)/2) * 120, itemStyle: { color: '#e3efe8', borderColor: '#8ebaa6', borderWidth: 1 }, label: { color: '#213f48' } }))], homes.map(h => ({ source: 'platform', target: 'home:' + h.id })));
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/* Shared local Bootstrap presentation for desktop and phones. */
|
||||
:root { --ui-shadow: 0 4px 22px #223d500a; --bs-body-font-family: system-ui,"Microsoft YaHei",sans-serif; }
|
||||
html[data-theme="paper"] { --ui-bg: #f5f5f1; --ui-soft: #f4f6f2; }
|
||||
.dashboard-grid { margin-top: 4px; }
|
||||
.dashboard-grid > div, .row > div { min-width: 0; }
|
||||
.dashboard-welcome { position: relative; overflow: hidden; padding: 28px; border-radius: 16px; background: linear-gradient(140deg,#234a49,#2e7964); color:#fff; }
|
||||
.dashboard-welcome::after { content:''; position:absolute; right:-85px; top:-95px; width:260px; height:260px; border:40px solid #ffffff07; border-radius:50%; pointer-events:none; }
|
||||
.dashboard-welcome h2 { font-size:clamp(21px,2vw,26px)!important; color:#fff!important; margin:16px 0 8px; letter-spacing:.2px; }
|
||||
.dashboard-welcome > p { color:#d3e7df; font-size:12px; }
|
||||
.dashboard-totals { display:flex; gap:28px; margin:22px 0; }
|
||||
.dashboard-totals > div { display:flex; flex-direction:column; }
|
||||
.dashboard-totals strong { color:#fff; font-size:32px; font-weight:600; line-height:1.3; font-variant-numeric:tabular-nums; }
|
||||
.dashboard-totals span { color:#d3e7df; font-size:11px; margin-top:5px; }
|
||||
.chart-card { padding:22px; border:1px solid var(--ui-line); border-radius:16px; background:var(--ui-surface); box-shadow:var(--ui-shadow); min-width:0; }
|
||||
.chart-heading { display:flex; gap:12px; align-items:center; justify-content:space-between; flex-wrap:wrap; margin-bottom:10px; }
|
||||
.chart-heading h3 { font-size:15px!important; font-weight:650; margin:0; }
|
||||
.chart-heading .small { font-size:11px; }
|
||||
.chart-legend { display:flex; gap:10px 18px; flex-wrap:wrap; justify-content:center; padding-top:8px; }
|
||||
.chart-legend span { display:flex; align-items:center; gap:6px; font-size:12px; color:var(--ui-muted); }
|
||||
.chart-legend i { width:8px; height:8px; border-radius:3px; }
|
||||
.chart-legend b { color:var(--ink); font-variant-numeric:tabular-nums; }
|
||||
.chart-data { color:var(--ui-muted); font-size:11px; margin-top:8px; }
|
||||
.chart-data summary { cursor:pointer; padding:6px 0; }
|
||||
.chart-data ul { padding-left:20px; margin:8px 0 0; }
|
||||
.chart-empty { min-height:150px; display:grid; place-items:center; color:var(--ui-muted); margin:0; font-size:13px; }
|
||||
.local-chart-wrap,.local-chart { width:100%; min-width:0; }
|
||||
.chart-network-surface { background:var(--ui-soft); border-radius:12px; background-image:radial-gradient(var(--ui-line) 1px,transparent 1px); background-size:20px 20px; overflow:hidden; }
|
||||
.chart-network-surface .local-chart { touch-action:none; }
|
||||
.household-context { border-left:3px solid #488b76!important; }
|
||||
.section-head > div > .description { margin-top:7px; }
|
||||
.home-toolbar,.device-view-controls,.playback-controls { box-shadow:var(--ui-shadow); }
|
||||
.home-card .card-body { padding:22px; }
|
||||
.home-cover { height:200px; }
|
||||
.form-grid label { align-items:stretch; }
|
||||
dialog .dialog-heading { position:sticky; top:0; background:var(--ui-surface); z-index:2; padding-block:12px; }
|
||||
dialog .dialog-footer { padding-top:18px; border-top:1px solid var(--ui-line); }
|
||||
html[data-theme="ink"] .chart-card { color:var(--ink); }
|
||||
html[data-theme="ink"] .chart-heading .badge { background:#2c493e!important; color:#c2e9d7!important; }
|
||||
@media(max-width:767px) {
|
||||
.dashboard-grid:not(.charts-expanded) .dashboard-chart-column { display:none; }
|
||||
.dashboard-welcome { padding:22px; }
|
||||
.dashboard-welcome h2 { font-size:22px!important; }
|
||||
.dashboard-totals { justify-content:space-between; gap:14px; margin:18px 0 14px; }
|
||||
.dashboard-welcome .insight-scope { display:flex; font-size:10px; }
|
||||
.chart-card { padding:18px; }
|
||||
.dashboard-grid .chart-card { height:auto!important; }
|
||||
.chart-network-surface .local-chart { max-height:340px; }
|
||||
.diagram-toolbar { flex-wrap:wrap; }
|
||||
.diagram-toolbar .btn { min-height:40px; }
|
||||
.household-context { padding:14px!important; }
|
||||
.section-head { gap:12px; flex-wrap:wrap; }
|
||||
.dialog-footer button { flex:1; }
|
||||
.table-wrap { overscroll-behavior-x:contain; }
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import '../../web/chinese-theme.css'
|
||||
import 'bootstrap/dist/css/bootstrap.min.css'
|
||||
import './theme.css'
|
||||
import './bootstrap-polish.css'
|
||||
import './dashboard.css'
|
||||
import App from './App.vue'
|
||||
import './composables/bridge.js'
|
||||
createApp(App).mount('#app')
|
||||
|
||||
Reference in New Issue
Block a user