-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMDC.html
212 lines (190 loc) · 6.79 KB
/
CMDC.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
<!-- http://data.cma.cn/forecast/index.html?t=54511 -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/css/mdui.min.css" />
<link rel="stylesheet" href="./mdui.css" />
</head>
<body class="mdui-appbar-with-toolbar mdui-theme-accent-pink">
<div id="app">
<!-- mdui appbar+tabbar -->
<div class="mdui-appbar mdui-appbar-fixed mdui-color-white mdui-appbar-inset">
<div class="mdui-toolbar">
<a href="javascript:;" class="mdui-btn mdui-btn-icon" mdui-menu="{target: '#left-drawer'}">
<i class="mdui-icon material-icons">menu</i>
</a>
<a href="javascript:;" class="mdui-typo-headline mdui-hidden-xs">B天气</a>
<a href="javascript:;" class="mdui-typo-title">国家气象信息中心</a>
<div class="mdui-toolbar-spacer"></div>
<div class="mdui-chip" :style="{flexShrink:0}">
<span class="mdui-chip-title" :class="{needUpdate:refreshTime.needUpdate}"
id="refreshDisplay">{{refreshTime.display}}</span>
</div>
<a href="javascript:;" class="mdui-btn mdui-btn-icon">
<i class="mdui-icon material-icons" onclick="location.reload()">refresh</i>
</a>
<a href="javascript:;" class="mdui-btn mdui-btn-icon" mdui-menu="{target: '#exmenu'}">
<i class="mdui-icon material-icons">more_vert</i>
</a>
<ul class="mdui-menu" id="exmenu">
<li class="mdui-divider"></li>
<li class="mdui-menu-item" mdui-dialog="{target: '#settingsDialog'}">
<a href="javascript:;" class="mdui-ripple">
<i class=" mdui-menu-item-icon mdui-icon material-icons">settings</i>
设置
</a>
</li>
</ul>
<ul class="mdui-menu" id="left-drawer">
<li class="mdui-menu-item mdui-ripple">
<a class="mdui-menu-item-content" href="./BMS.html">
<i class="mdui-menu-item-icon mdui-icon material-icons">move_to_inbox</i>
北京气象台
</a>
</li>
<li class="mdui-menu-item mdui-ripple">
<a class="mdui-menu-item-content" href="./NMC.html">
<i class="mdui-menu-item-icon mdui-icon material-icons">move_to_inbox</i>
中央气象台
</a>
</li>
<li class="mdui-menu-item mdui-ripple">
<a class="mdui-menu-item-content" href="./CMA.html">
<i class="mdui-menu-item-icon mdui-icon material-icons">move_to_inbox</i>
中国气象局
</a>
</li>
<li class="mdui-menu-item mdui-ripple mdui-list-item-active">
<a class="mdui-menu-item-content" href="./CMDC.html">
<i class="mdui-menu-item-icon mdui-icon material-icons">move_to_inbox</i>
国家气象信息中心
</a>
</li>
<li class="mdui-menu-item mdui-ripple">
<a class="mdui-menu-item-content" href="./BM.html">
<i class="mdui-menu-item-icon mdui-icon material-icons">move_to_inbox</i>
北京气象
</a>
</li>
<li class="mdui-menu-item mdui-ripple">
<a class="mdui-menu-item-content" href="./weatherol.html">
<i class="mdui-menu-item-icon mdui-icon material-icons">move_to_inbox</i>
北京气象在线
</a>
</li>
<li class="mdui-divider"></li>
<li class="mdui-menu-item mdui-ripple">
<a class="mdui-menu-item-content" href="./12379.html">
<i class="mdui-menu-item-icon mdui-icon material-icons">move_to_inbox</i>
国家预警信息发布中心
</a>
</li>
</ul>
</div>
</div>
<div class="mdui-progress" v-if="isLoading">
<div class="mdui-progress-indeterminate"></div>
</div>
<!-- sidebar -->
<!-- 设置 -->
<div class="mdui-dialog" id="settingsDialog">
<div class="mdui-dialog-content">
<div class="mdui-dialog-title">设置</div>自动深色模式
<label class="mdui-switch mdui-float-right">
<input type="checkbox" v-model="isAutoDark" onclick="app.autoDark()" />
<i class="mdui-switch-icon"></i>
</label>
</div>
<div class="mdui-dialog-actions">
<button class="mdui-btn mdui-ripple" mdui-dialog-confirm>ok</button>
</div>
</div>
<div>
{{currentData}}
</div>
</div>
<script src=" https://unpkg.com/[email protected]/dist/js/mdui.min.js">
</script>
</body>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.js"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script>
const app = new Vue({
el: "#app",
data: {
refreshTime: {
display: "刚刚刷新",
min: 0,
secound: 0,
needUpdate: false,
startTime: 0,
},
isLoading: true,
isAutoDark: false,
warningList: [],
updateTime: "",
currentData: {},
},
async created() {
if (localStorage.isAutoDark == "true") {
this.isAutoDark = true;
document.body.classList.add("mdui-theme-layout-auto");
document.querySelector(".mdui-appbar").classList.add("autoDarkAppBar");
}
const currentRes = await axios.post("http://data.cma.cn/kbweb/home/live", { lat: 40.34, lon: 116.3667, type: "0", });
// const curretRes = await axios.post("http://data.cma.cn/weatherGis/web/weather/weatherFcst/getDayNigntData", { staIds: 54511 });
this.currentData = currentRes;
this.startTime = new Date().getTime();
document.addEventListener("visibilitychange", function () {
console.log(document.visibilityState, performance.now());
if (document.visibilityState == "visible") {
app.refreshTimeChange();
}
});
setInterval(() => {
this.refreshTimeChange();
}, 10000);
this.$nextTick(function () {
this.isLoading = false;
})
},
methods: {
refreshTimeChange() {
let timeTemp = (new Date().getTime() - this.startTime) / 1000;
console.log("11", timeTemp);
if (timeTemp > 10) {
app.refreshTime.display = "T+";
if (timeTemp / 60 > 30) {
app.refreshTime.display = "已过时"
app.refreshTime.needUpdate = true;
} else {
if (Math.floor(timeTemp / 60) > 0) {
app.refreshTime.display += Math.floor(timeTemp / 60) + "m";
}
app.refreshTime.display += Math.floor(timeTemp % 60) + "s";
}
}
},
autoDark() {
// setTimeout(() => {
// this.$nextTick(function () {
if (!this.isAutoDark) {
document.body.classList.add("mdui-theme-layout-auto");
document.querySelector(".mdui-appbar").classList.add("autoDarkAppBar");
localStorage.isAutoDark = true;
} else {
console.log(111);
document.body.classList.remove("mdui-theme-layout-auto");
document.querySelector(".mdui-appbar").classList.remove("autoDarkAppBar");
localStorage.isAutoDark = false;
}
// })
// }, 1000);
},
},
});
</script>
</html>