Skip to content

Commit 0e86acf

Browse files
committed
docs: eq report
1 parent b1e9016 commit 0e86acf

File tree

4 files changed

+56
-88
lines changed

4 files changed

+56
-88
lines changed

docs/api/api/earthquake.mdx

Lines changed: 35 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ import ApiFieldsTable from "@site/src/components/ApiFieldsTable";
1515

1616
:::
1717

18-
### 請求
19-
2018
<ApiEndpoint
2119
method="GET"
2220
baseUrls={[
@@ -28,91 +26,41 @@ import ApiFieldsTable from "@site/src/components/ApiFieldsTable";
2826
responses={{
2927
"200": {
3028
description: "成功",
31-
data: [
32-
{
33-
id: "CWA-EQ114000-2025-0829-100546",
34-
no: 114000,
35-
lat: 22.86,
36-
lon: 121.28,
37-
depth: 16.9,
38-
loc: "臺東縣政府東北方 17.5 公里 (位於臺東縣近海)",
39-
mag: 4,
40-
time: 1756433146000,
41-
list: {
42-
臺東縣: {
43-
int: 2,
44-
town: {
45-
東河: { lat: 22.97, lon: 121.3, int: 2 },
46-
鹿野: { lat: 22.91, lon: 121.13, int: 2 },
47-
臺東市: { lat: 22.75, lon: 121.16, int: 2 },
48-
卑南: { lat: 22.82, lon: 121.08, int: 2 },
49-
池上: { lat: 23.1, lon: 121.22, int: 2 },
50-
綠島: { lat: 22.67, lon: 121.47, int: 2 },
51-
成功: { lat: 23.1, lon: 121.37, int: 1 },
52-
海端: { lat: 23.15, lon: 121.21, int: 1 },
53-
太麻里: { lat: 22.6, lon: 120.96, int: 1 },
54-
蘭嶼: { lat: 22.04, lon: 121.56, int: 1 },
55-
},
56-
},
57-
花蓮縣: {
58-
int: 1,
59-
town: { 富里: { lat: 23.2, lon: 121.29, int: 1 } },
60-
},
61-
},
62-
},
63-
],
29+
data: `[
30+
{
31+
"id": "CWA-EQ114000-2025-0829-100546", // 事件編號
32+
"no": 114000, // 地震編號
33+
"lat": 22.86, // 震央緯度
34+
"lon": 121.28, // 震央經度
35+
"depth": 16.9, // 震源深度(公里)
36+
"loc": "臺東縣政府東北方 17.5 公里 (位於臺東縣近海)", // 位置描述
37+
"mag": 4, // 地震規模
38+
"time": 1756433146000, // 發震時間(毫秒)
39+
"list": { // 各地震度資料
40+
"臺東縣": {
41+
"int": 2, // 縣市最大震度 1 ~ 9 (對應 1 ~ 7 級)
42+
"town": { // 各鄉鎮震度
43+
"東河": { "lat": 22.97, "lon": 121.3, "int": 2 },
44+
"鹿野": { "lat": 22.91, "lon": 121.13, "int": 2 },
45+
"臺東市": { "lat": 22.75, "lon": 121.16, "int": 2 },
46+
"卑南": { "lat": 22.82, "lon": 121.08, "int": 2 },
47+
"池上": { "lat": 23.1, "lon": 121.22, "int": 2 },
48+
"綠島": { "lat": 22.67, "lon": 121.47, "int": 2 },
49+
"成功": { "lat": 23.1, "lon": 121.37, "int": 1 },
50+
"海端": { "lat": 23.15, "lon": 121.21, "int": 1 },
51+
"太麻里": { "lat": 22.6, "lon": 120.96, "int": 1 },
52+
"蘭嶼": { "lat": 22.04, "lon": 121.56, "int": 1 }
53+
}
54+
},
55+
"花蓮縣": {
56+
"int": 1,
57+
"town": {
58+
"富里": { "lat": 23.2, "lon": 121.29, "int": 1 }
59+
}
60+
}
61+
}
62+
}
63+
]`,
6464
},
6565
}}
6666
/>
67-
68-
### 說明
69-
70-
<ApiFieldsTable
71-
fields={[
72-
{
73-
name: "id",
74-
type: "String",
75-
description: "事件編號",
76-
},
77-
{
78-
name: "no",
79-
type: "Integer",
80-
description: "地震編號,小區域地震尾數為 000",
81-
},
82-
{
83-
name: "lat",
84-
type: "Float",
85-
description: "震央緯度座標,到小數點第 2 位",
86-
},
87-
{
88-
name: "lon",
89-
type: "Float",
90-
description: "震央經度座標,到小數點第 2 位",
91-
},
92-
{
93-
name: "depth",
94-
type: "Float",
95-
description: "震源深度,單位為公里",
96-
},
97-
{
98-
name: "loc",
99-
type: "String",
100-
description: "震央位置的文字描述",
101-
},
102-
{
103-
name: "mag",
104-
type: "Integer",
105-
description: "地震規模 (芮氏規模)",
106-
},
107-
{
108-
name: "time",
109-
type: "Long",
110-
description: "發震時間的 Unix timestamp (毫秒)",
111-
},
112-
{
113-
name: "list",
114-
type: "Object",
115-
description: "各縣市與鄉鎮市區的震度資料,包含震度與座標資訊",
116-
},
117-
]}
118-
/>

src/components/ApiEndpoint/index.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import styles from "./styles.module.css";
33

44
const highlightJSON = (jsonString: string) => {
55
return jsonString
6+
.replace(/(\/\/.*$)/gm, '<span class="json-comment">$1</span>')
67
.replace(/("[\w\s]*")\s*:/g, '<span class="json-key">$1</span>:')
78
.replace(/:\s*(".*?")/g, ': <span class="json-string">$1</span>')
89
.replace(/:\s*(\d+)/g, ': <span class="json-number">$1</span>')
@@ -216,7 +217,11 @@ export default function ApiEndpoint({
216217
<pre className={styles.codeBlock}>
217218
<code
218219
dangerouslySetInnerHTML={{
219-
__html: highlightJSON(JSON.stringify(responses[selectedStatus]?.data, null, 2))
220+
__html: highlightJSON(
221+
typeof responses[selectedStatus]?.data === 'string'
222+
? responses[selectedStatus]?.data
223+
: JSON.stringify(responses[selectedStatus]?.data, null, 2)
224+
)
220225
}}
221226
/>
222227
</pre>

src/components/ApiEndpoint/styles.module.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,11 @@
566566
font-weight: 700;
567567
}
568568

569+
.codeBlock :global(.json-comment) {
570+
color: #6a9955;
571+
font-style: italic;
572+
}
573+
569574
/* Light mode JSON highlighting */
570575
[data-theme='light'] .codeBlock {
571576
background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
@@ -603,6 +608,11 @@
603608
font-weight: 700;
604609
}
605610

611+
[data-theme='light'] .codeBlock :global(.json-comment) {
612+
color: #6a737d;
613+
font-style: italic;
614+
}
615+
606616
@media (max-width: 768px) {
607617
.codeBlock {
608618
padding: 1rem;

src/components/ApiFieldsTable/styles.module.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@
5656
.table td:nth-child(3) {
5757
width: auto !important;
5858
min-width: 0;
59+
white-space: normal;
60+
word-wrap: break-word;
5961
}
6062

6163
[data-theme='dark'] .table th {
@@ -101,6 +103,9 @@
101103
font-size: 0.875rem;
102104
font-weight: 500;
103105
color: var(--ifm-color-primary);
106+
white-space: nowrap;
107+
overflow: hidden;
108+
text-overflow: ellipsis;
104109
}
105110

106111
.required {

0 commit comments

Comments
 (0)