-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
232 lines (206 loc) · 6.45 KB
/
index.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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
<!DOCTYPE html>
<html>
<head>
<title>b言b语</title>
<link rel="shortcut icon" href="./favicon.ico" />
<link type="text/css" rel="stylesheet" href="https://at.alicdn.com/t/font_1755564_z4mhxbw13mq.css"></link>
<link href="https://fonts.loli.net/css?family=Noto+Serif+SC:200,300,900&display=swap&subset=chinese-simplified" rel="stylesheet">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<meta name="description" content="">
<meta name="keywords" content="" />
<meta name="author" content="daibor" />
<meta charset="utf-8" />
<meta name="robots" content="index,follow" />
<meta name="google" content="index,follow" />
<meta name="googlebot" content="index,follow" />
<meta name="verify" content="index,follow" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
</head>
<body>
<header id="header">
<h1>b言b语</h1>
</header>
<main id="app">
<aside>
<p id="describe">
<p>Hello!</p>
<p> *This is my zine.I write about "shit" I care about.😏</p>
<p align="right">My。<a href="https://chenyyds.com">Blog</a>
</p>
</aside>
<p class="tip">现在总共 b 了 {{count}} 条</p>
<section class="item" v-for="item in contents" v-cloak>
<p v-html='item.attributes.content'></p>
<time v-bind:datetime="item.attributes.time">{{item.attributes.time}}</time>
</section>
<div class="load-ctn">
<button class="load-btn" v-on:click="loadMore" v-if="contents" v-cloak>再翻翻</button>
<p class="tip" v-else>别急,加载呢</p>
</div>
</main>
<footer>
<p class="center-text">Copyright © 2020 ChenYYDS,All Rights Reserved</p>
</footer>
</body>
<script src="https://cdn.bootcss.com/vue/2.6.11/vue.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/av-min.js"></script>
<script type="text/javascript">
var {
Query
} = AV;
AV.init({
appId: "9vImXsUw8JRfBOQbgjlkIleo-9Nh9j0Va", //你的 leancloud 应用 id (设置-应用keys-AppID)
appKey: "0hCBkt5fdUyjxUR8uJlB6dzL", //你的 leancloud 应用 AppKey (设置-应用keys-AppKey)
serverURLs: 'https://server.chenplus.com'
});
var query = new AV.Query('content');
var app = new Vue({
el: '#app',
data: {
page: 0,
count: 0,
contents: []
},
methods: {
loadMore: function(event) {
getData(++this.page);
}
}
})
function urlToLink(str) {
var re = /(http|ftp|https):\/\/[\w-]+(.[\w-]+)+([\w-.,@?^=%&:/~+#]*[\w-\@?^=%&/~+#])?/g;;
str = str.replace(re, function(website) {
return "<a href='" + website + "' target='_blank'> <i class='iconfont icon-lianjie-copy'></i>链接 </a>";
});
return str;
}
function getData(page = 0) {
query.descending('createdAt').skip(page * 20).limit(20).find().then(function(results) {
if (results.length == 0) {
alert('之前没 b 过了')
} else {
let resC = results;
reqData = false;
resC.forEach((i) => {
let dateTmp = new Date(i.createdAt);
i.attributes.time = `${dateTmp.getFullYear()}-${(dateTmp.getMonth() + 1) < 10 ? ('0' + (dateTmp.getMonth()+1)) : dateTmp.getMonth()+1}-${(dateTmp.getDate() + 1) < 10 ? ('0' + dateTmp.getDate()) : dateTmp.getDate()} ${(dateTmp.getHours() + 1) <= 10 ? ('0' + dateTmp.getHours()) : dateTmp.getHours()}:${(dateTmp.getMinutes() + 1) <= 10 ? ('0' + dateTmp.getMinutes()) : dateTmp.getMinutes()}`;
i.attributes.content = "<span>" + urlToLink(i.attributes.content) + "</span>";
app.contents.push(i);
})
}
}, function(error) {});
}
getData(0);
query.count().then(function(count) {
app.count = count;
}, function(error) {});
</script>
<style type="text/css">
@media (prefers-color-scheme: dark) {
/* 夜间模式 */
body {
background-color: black;
color: white;
}
body .item {
border-top: 6px solid #888888;
background-color: rgb(21, 32, 43);
color: #ccc;
}
body time {
color: #aaa;
}
h1 {
color: #ffffff;
}
aside {
color: #ccc;
}
body .load-btn {
background-color: #000;
color: #ddd;
}
body .load-btn:hover:active {
background: #1DA1F2;
color: #fff;
}
}
[v-cloak] {
display: none;
}
html {
font-size: 20px;
}
body,
button {
font-family: 'Noto Serif SC', -apple-system,BlinkMacSystemFont,Roboto,Segoe UI,Helvetica,Arial,serif;
}
aside {
font-weight: 300;
font-style: normal;
line-height: 1.8rem;
}
#app,
header,
footer {
box-sizing: border-box;
width: 100%;
max-width: 500px;
margin: 0 auto;
padding: 0 20px;
}
h1 {
font-weight: 900;
}
footer {
font-size: 0.8rem;
clear: both;
}
.tip {
color: #999;
}
.item {
font-weight: 300;
font-style: normal;
line-height: 1.8rem;
background: #fff;
padding: 10px 20px;
border-radius: 5px;
box-shadow: 0 1px 6px rgba(32, 33, 36, 0.28);
margin-top: 20px;
border-top: 6px solid;
text-align: justify;
}
.item a {
text-decoration: none;
color: #5dafd5;
}
time {
font-weight: 200;
color: #bbb;
}
.center-text {
text-align: center;
}
.load-ctn {
width: 100%;
}
.load-btn {
border: 2px solid #666;
width: 130px;
outline: none;
font-size: 20px;
border-radius: 100px;
margin: 30px auto;
color: #666;
line-height: 30px;
float: right;
background: #fff;
}
.load-btn:hover:active {
background: #666;
color: #fff;
}
</style>
</html>