Commit aabb7008 by liimin

.env.local

1 parent 96e83e18
# 高德地图 JS API 2.0 凭证(用户提供 2026-10-13)
# Key + 安全密钥均已填。2021-12-02 后申请的 key 必须配 securityJsCode,否则底图/热力白屏
VITE_AMAP_KEY=11b1dc16a79ade95fa0ef28246f4d518
VITE_AMAP_SECURITY_CODE=fc17677e508becf6ceb8aad81d442015
VITE_AMAP_DEBUG=true
node_modules/ node_modules/
dist/ dist/
dist-ssr/ dist-ssr/
*.local
.env.local
.env.*.local
# 预处理产物:可由 pnpm data:build 从 data/raw/*.csv 完整重建,不入库 # 预处理产物:可由 pnpm data:build 从 data/raw/*.csv 完整重建,不入库
public/data/ public/data/
......
...@@ -1192,24 +1192,17 @@ export function MapStage() { ...@@ -1192,24 +1192,17 @@ export function MapStage() {
<div className="hm-map__canvas" ref={containerRef} /> <div className="hm-map__canvas" ref={containerRef} />
{/* 图例只有一张:聚焦期间讲的是那一屏的口径(见 SpotlightKey), {/* 图例只有一张:聚焦期间讲的是那一屏的口径(见 SpotlightKey),
平时讲的是热力方格的口径。两张同时挂着等于同一块深浅有两种说法 */} 平时讲的是热力方格的口径。两张同时挂着等于同一块深浅有两种说法。
{mapReady && 它自己能收成左下那枚小牌(口径见下面的 MapLegend)。 */}
(spotlight ? ( {mapReady && (
<SpotlightKey view={spotlight} cellM={spotCellM} /> <MapLegend
) : ( spotlight={spotlight}
layerVisible.cluster && cellM={spotCellM}
!focusQuiet && ( legendHint={legendHint}
<div className="hm-map__legend"> clusterVisible={layerVisible.cluster}
<div className="hm-map__legend-title">案件密度</div> focusQuiet={focusQuiet}
<div className="hm-map__legend-bar" /> />
<div className="hm-map__legend-scale"> )}
<span>低</span>
<span>高</span>
</div>
{legendHint && <div className="hm-map__legend-hint">{legendHint}</div>}
</div>
)
))}
<div className="hm-map__toolbar"> <div className="hm-map__toolbar">
{/* 聚焦期间这块换成「看的是哪几张榜 + 怎么退出」:命中 / 点位 / 耗时那三个读数讲的是 {/* 聚焦期间这块换成「看的是哪几张榜 + 怎么退出」:命中 / 点位 / 耗时那三个读数讲的是
......
import { CollapseButton } from '@hm/ui';
import { fmtInt } from '@/utils/format'; import { fmtInt } from '@/utils/format';
import type { SpotlightView } from '@/store/useHeatmapStore'; import type { SpotlightView } from '@/store/useHeatmapStore';
...@@ -14,13 +15,29 @@ import type { SpotlightView } from '@/store/useHeatmapStore'; ...@@ -14,13 +15,29 @@ import type { SpotlightView } from '@/store/useHeatmapStore';
* 复用 `.hm-map__legend` 那套玻璃样式与让位规则(清单通栏、右栏展开时它自己挪列或收起, * 复用 `.hm-map__legend` 那套玻璃样式与让位规则(清单通栏、右栏展开时它自己挪列或收起,
* 见 design.css):宽度仍然按 206 那一套算,不因为换了内容就把浮层让位阈值全部重核一遍。 * 见 design.css):宽度仍然按 206 那一套算,不因为换了内容就把浮层让位阈值全部重核一遍。
*/ */
export function SpotlightKey({ view, cellM }: { view: SpotlightView; cellM: number }) { export function SpotlightKey({
view,
cellM,
onCollapse,
}: {
view: SpotlightView;
cellM: number;
/** 收整张图例,让它不再压着屏上那一块(收成左下那枚小牌,见 MapStage 的 MapLegend) */
onCollapse: () => void;
}) {
const { kind, units } = view; const { kind, units } = view;
const shape = shapeNote(kind, cellM); const shape = shapeNote(kind, cellM);
return ( return (
<div className="hm-map__legend"> <div className="hm-map__legend">
<div className="hm-map__legend-title">{RAMP_TITLE[kind]}</div> <div className="hm-map__legend-head">
<div className="hm-map__legend-title">{RAMP_TITLE[kind]}</div>
<CollapseButton
onClick={onCollapse}
dir="down"
hint="收起这块说明,让出左下角的地图;点左下那枚小牌重新展开"
/>
</div>
{/* 位置那一档不涂色阶:一处就是一处,没有「比邻格浓多少」可读,画一条色阶进去就是骗人 */} {/* 位置那一档不涂色阶:一处就是一处,没有「比邻格浓多少」可读,画一条色阶进去就是骗人 */}
{kind !== 'places' && ( {kind !== 'places' && (
<> <>
...@@ -51,6 +68,16 @@ const RAMP_TITLE: Record<SpotlightView['kind'], string> = { ...@@ -51,6 +68,16 @@ const RAMP_TITLE: Record<SpotlightView['kind'], string> = {
places: '反复出险的位置', places: '反复出险的位置',
}; };
/**
* 图例收成左下那枚小牌时念的字。
*
* 取自同一张 RAMP_TITLE:牌子与展开态讲的是同一件事,两处各写一句迟早会出现
* 「牌上写着案件密度、摊开来标题是每平方公里案件数」这种对不上的说法。
*/
export function spotlightKeyTitle(kind: SpotlightView['kind']): string {
return RAMP_TITLE[kind];
}
const RAMP_NOTE: Record<SpotlightView['kind'], string> = { const RAMP_NOTE: Record<SpotlightView['kind'], string> = {
// 整片涂起数是典型误读:面积最大的那个区一定最深,而那只代表案件总数多。 // 整片涂起数是典型误读:面积最大的那个区一定最深,而那只代表案件总数多。
// 所以这里把两件事分开说,牌子仍然念总数(榜上就是这么排的) // 所以这里把两件事分开说,牌子仍然念总数(榜上就是这么排的)
......
...@@ -188,6 +188,116 @@ body { ...@@ -188,6 +188,116 @@ body {
color: var(--hm-text-3); color: var(--hm-text-3);
} }
/*
* 「收起」那颗:面板标题行、地图图例、抽屉标题行共用一颗。
*
* 为什么给它实底和描边,而不是沿用右上角那颗淡色小叉:这一颗要解决的正是
* 「这块玻璃挡住了地图,我得先把它挪开」,而淡色小叉在整页毛玻璃上几乎看不出能按。
* 两个字 + 一截朝向箭头,收向哪一侧由箭头说;复开的地方写在悬浮里,
* 因为收起之后找不到回来的路,等于没人敢按第一下。
* flex-shrink 归零:面板标题行挤的时候(黑点清单那行还有口径读数)先压字号,
* 不许把出口压没。
*/
.hm-collapse {
display: inline-flex;
align-items: center;
gap: 5px;
flex: 0 0 auto;
padding: 3px 9px;
font: inherit;
font-size: 11px;
line-height: 1.4;
color: var(--hm-text-2);
background: var(--hm-glass-side-strong);
border: 1px solid var(--hm-glass-border);
border-radius: 999px;
white-space: nowrap;
cursor: pointer;
transition:
color 0.15s ease,
background 0.15s ease,
border-color 0.15s ease;
}
.hm-collapse:hover {
color: var(--hm-primary);
background: var(--hm-glass-side-strong);
}
.hm-collapse:focus-visible {
outline: 2px solid var(--hm-accent-cyan);
outline-offset: 2px;
}
/* 一截朝右的尖角(border 两笔 + 旋转),方向由 --left/--right/--down 三个修饰符改 */
.hm-collapse__chev {
width: 5px;
height: 5px;
border-right: 1.5px solid currentColor;
border-bottom: 1.5px solid currentColor;
transform: rotate(-45deg);
}
.hm-collapse--right .hm-collapse__chev {
transform: rotate(-45deg);
}
.hm-collapse--left .hm-collapse__chev {
transform: rotate(135deg);
}
.hm-collapse--down .hm-collapse__chev {
transform: rotate(45deg);
}
/* 收起来的图例变回左下一枚小牌:留着色阶一小截,让人认出收起的就是这一条 */
.hm-map__legend-chip {
position: absolute;
left: calc(var(--hm-rail-gap) + 2px);
bottom: var(--hm-rail-gap);
z-index: 12;
display: inline-flex;
align-items: center;
gap: 7px;
padding: 5px 10px;
font: inherit;
font-size: 11px;
color: var(--hm-text-2);
background: var(--hm-glass-side);
border: 1px solid var(--hm-glass-border);
border-radius: 999px;
box-shadow: var(--hm-glass-shadow);
backdrop-filter: var(--hm-glass-blur);
-webkit-backdrop-filter: var(--hm-glass-blur);
cursor: pointer;
/* 与整张图例同速同规则:清单通栏拉开时照样往右挪一列,见下面 .hm-body.is-dock-open */
transition:
left 0.22s cubic-bezier(0.22, 1, 0.36, 1),
bottom 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}
.hm-map__legend-chip:hover {
color: var(--hm-primary);
background: var(--hm-glass-side-strong);
}
.hm-map__legend-chip:focus-visible {
outline: 2px solid var(--hm-accent-cyan);
outline-offset: 2px;
}
.hm-map__legend-chip-ramp {
width: 26px;
height: 5px;
border-radius: 3px;
background: linear-gradient(90deg, #2b4ac7 0%, #18a8ff 22%, #7ade3c 52%, #ffce00 68%, #ff2a2a 92%);
}
/* 尖角朝上:这一枚是「往上摊开」,和收起那颗朝下正好成一对 */
.hm-map__legend-chip .hm-collapse__chev {
transform: rotate(-135deg);
}
.hm-panel__body { .hm-panel__body {
padding: 14px; padding: 14px;
} }
...@@ -1437,6 +1547,60 @@ body { ...@@ -1437,6 +1547,60 @@ body {
min-height: 0; min-height: 0;
} }
/*
* 清单收起来之后贴在屏幕左缘的那条把手。
*
* 它只在「本该有清单、却被它那颗收起收了」的时候出现(见 OperationRail 的条件),
* 平时不往屏上加一颗没用的东西。位置钉在竖向中间:清单通栏本来就吃满整屏,
* 回来时从同一头滑出最合手,也不会和左下的密度图例抢地方。
*/
.hm-dock-handle {
position: absolute;
left: var(--hm-rail-gap);
top: 50%;
transform: translateY(-50%);
z-index: 16;
display: inline-flex;
align-items: center;
gap: 7px;
padding: 8px 11px;
font: inherit;
font-size: 12px;
color: var(--hm-text-2);
background: var(--hm-glass-side);
border: 1px solid var(--hm-glass-border);
border-radius: var(--hm-radius);
box-shadow: var(--hm-glass-shadow);
backdrop-filter: var(--hm-glass-blur);
-webkit-backdrop-filter: var(--hm-glass-blur);
white-space: nowrap;
cursor: pointer;
transition:
color 0.15s ease,
background 0.15s ease,
transform 0.18s ease;
}
.hm-dock-handle:hover {
color: var(--hm-primary);
background: var(--hm-glass-side-strong);
transform: translate(2px, -50%);
}
.hm-dock-handle:focus-visible {
outline: 2px solid var(--hm-accent-cyan);
outline-offset: 2px;
}
/* 尖角朝右:这一按是把清单从左边往屏内拉出来 */
.hm-dock-handle__chev {
width: 5px;
height: 5px;
border-right: 1.5px solid currentColor;
border-bottom: 1.5px solid currentColor;
transform: rotate(-45deg);
}
/* 栏内子项默认不许被压扁 ——「内容不见了却没有滚动条」的根因。 /* 栏内子项默认不许被压扁 ——「内容不见了却没有滚动条」的根因。
* *
* flex 项的 flex-shrink 默认是 1:空间不够时浏览器选择把面板压矮, * flex 项的 flex-shrink 默认是 1:空间不够时浏览器选择把面板压矮,
...@@ -1507,6 +1671,16 @@ body { ...@@ -1507,6 +1671,16 @@ body {
bottom 0.22s cubic-bezier(0.22, 1, 0.36, 1); bottom 0.22s cubic-bezier(0.22, 1, 0.36, 1);
} }
/* 标题行左右分栏:左边讲口径,右边那颗收整张图例。
图例总宽仍按 206 那一套算(色阶 168 与说明 180 谁长听谁的),
这一行最宽只到 180 出头,不会因为多了一颗按钮就把下面的让位阈值重核一遍。 */
.hm-map__legend-head {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
}
.hm-map__legend-title { .hm-map__legend-title {
font-size: 11px; font-size: 11px;
font-weight: 600; font-weight: 600;
...@@ -1553,9 +1727,13 @@ body { ...@@ -1553,9 +1727,13 @@ body {
* 「贴着清单右缘流式跟随」,因为那样图例会在拖动窗口的过程里一路横着追清单, * 「贴着清单右缘流式跟随」,因为那样图例会在拖动窗口的过程里一路横着追清单,
* 而它需要的只是「别压在清单身上」,不是「跟着清单走」。 * 而它需要的只是「别压在清单身上」,不是「跟着清单走」。
* 图例恒定 206 宽 → 右缘落在 610,下面两条阈值都由这个 610 推出来。 * 图例恒定 206 宽 → 右缘落在 610,下面两条阈值都由这个 610 推出来。
*
* 每一段都同时写给整张图例和收成小牌的那一枚:它们是同一块东西的两种形态,
* 只让位给展开态的话,收起之后小牌还压在清单底下 —— 而收起本来就是为了让开位置。
*/ */
@media (min-width: 1081px) { @media (min-width: 1081px) {
.hm-body.is-dock-open .hm-map__legend { .hm-body.is-dock-open .hm-map__legend,
.hm-body.is-dock-open .hm-map__legend-chip {
left: calc(var(--hm-rail-gap) * 2 + var(--hm-dock-w)); left: calc(var(--hm-rail-gap) * 2 + var(--hm-dock-w));
} }
} }
...@@ -1568,7 +1746,8 @@ body { ...@@ -1568,7 +1746,8 @@ body {
* 口径说明,同样内容在右栏里也写着,收掉不丢信息。 * 口径说明,同样内容在右栏里也写着,收掉不丢信息。
* 833 以下不用处理:清单本来就显示不出来(见文末 max-width:832 的退路)。 */ * 833 以下不用处理:清单本来就显示不出来(见文末 max-width:832 的退路)。 */
@media (min-width: 833px) and (max-width: 1080px) { @media (min-width: 833px) and (max-width: 1080px) {
.hm-body.is-dock-open .hm-map__legend { .hm-body.is-dock-open .hm-map__legend,
.hm-body.is-dock-open .hm-map__legend-chip {
display: none; display: none;
} }
} }
...@@ -1582,7 +1761,8 @@ body { ...@@ -1582,7 +1761,8 @@ body {
* 这里是「抬一行」而不是「收起一个」:两个都只是浮层,谁也没有非占住底缘不可, * 这里是「抬一行」而不是「收起一个」:两个都只是浮层,谁也没有非占住底缘不可,
* 分行就能都留着 —— 比让图例或读数凭空消失诚实。 */ * 分行就能都留着 —— 比让图例或读数凭空消失诚实。 */
@media (min-width: 1141px) and (max-width: 1380px) { @media (min-width: 1141px) and (max-width: 1380px) {
.hm-body.is-dock-open .hm-map__legend { .hm-body.is-dock-open .hm-map__legend,
.hm-body.is-dock-open .hm-map__legend-chip {
bottom: calc(var(--hm-rail-gap) + var(--hm-chip-h) + 8px); bottom: calc(var(--hm-rail-gap) + var(--hm-chip-h) + 8px);
} }
} }
...@@ -1765,7 +1945,8 @@ body { ...@@ -1765,7 +1945,8 @@ body {
* 关掉页签它们就回来,比留一个摸不着的按钮诚实。阈值留到 760 取整。 */ * 关掉页签它们就回来,比留一个摸不着的按钮诚实。阈值留到 760 取整。 */
@media (max-width: 760px) { @media (max-width: 760px) {
.hm-body.is-rail-open .hm-map__toolbar, .hm-body.is-rail-open .hm-map__toolbar,
.hm-body.is-rail-open .hm-map__legend { .hm-body.is-rail-open .hm-map__legend,
.hm-body.is-rail-open .hm-map__legend-chip {
display: none; display: none;
} }
} }
......
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import * as XLSX from 'xlsx';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const ROOT = path.resolve(__dirname);
const xlsxPath = 'C:/Users/Limin/Desktop/深圳车险出险位置-9月.xlsx';
const wb = XLSX.readFile(xlsxPath);
console.log('SHEETS:', JSON.stringify(wb.SheetNames));
const ws = wb.Sheets[wb.SheetNames[0]];
const rows = XLSX.utils.sheet_to_json(ws, { defval: null });
console.log('ROW_COUNT:', rows.length);
console.log('HEADERS:', JSON.stringify(Object.keys(rows[0] || {})));
console.log('SAMPLE_3:', JSON.stringify(rows.slice(0, 3), null, 1));
// 顺带看一眼 data/raw 现状
const rawDir = path.join(ROOT, 'data/raw');
console.log('RAW_DIR_EXISTS:', fs.existsSync(rawDir));
if (fs.existsSync(rawDir)) {
console.log('RAW_DIR_FILES:', JSON.stringify(fs.readdirSync(rawDir)));
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!