-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
208 lines (203 loc) · 11.6 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
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>网站导航</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://unpkg.com/vue"></script>
<script src="//unpkg.com/spacingjs" defer></script>
</head>
<body>
<div id="app" class="antialiased">
<div id="background" class="w-screen h-screen bg-fixed bg-cover bg-center"
v-bind:style="{'background-image': 'url(' + backgroundImage + ')'}">
<div id="background-mask" class="w-full h-full backdrop-blur">
<div class="w-full h-full flex flex-col gap-10">
<!-- Header -->
<div id="header" class="w-full h-24 px-8 flex justify-end">
<button v-if="locked" class="text-5xl transition ease-in-out hover:scale-125"
v-on:click="locked=false">
🔒
</button>
<button v-else class="text-5xl transition ease-in-out hover:scale-125" v-on:click="locked=true">
🔓
</button>
<button class="text-5xl transition ease-in-out hover:scale-125" v-on:click="refreshBackground">
👋
</button>
<button class="text-5xl transition ease-in-out hover:scale-125">
⚙️
</button>
</div>
<!-- Content -->
<div id="content" class="container mx-auto grow">
<!-- Poker Table -->
<div id="poker-table" class="flex flex-wrap gap-6">
<div id="poker-card"
class="w-56 h-80 rounded-2xl bg-white bg-cover bg-center transition ease-in-out hover:scale-105 hover:shadow-2xl hover:shadow-slate-500/50"
v-for="(site, index) in sites" :key="index"
v-bind:style="{'background-image': 'url('+site.cover+')'}">
<button class="w-full h-full flex flex-col" v-on:click="open(site.url)">
<div id="pocker-card-header" class="w-full h-1/5 flex justify-end">
<div v-if="!locked" class="px-6 py-5 text-white text-2xl font-semibold"
v-on:click.stop="remove(index)">✕</div>
</div>
<div id="pocker-card-mask" class="w-full h-2/5">
</div>
<div id="pocker-content"
class="w-full h-2/5 px-4 py-8 rounded-b-2xl bg-white/10 backdrop-blur flex flex-col gap-4 items-end justify-end text-white">
<p class="h-1/3 text-lg">{{site.title}}</p>
<p class="h-1/3 text-sm text-ellipsis">{{site.description}}</p>
</div>
</button>
</div>
<!-- Add Button -->
<div id="add-button"
class="w-56 h-80 flex justify-center items-center rounded-2xl bg-white/30 transition ease-in-out hover:shadow-2xl hover:shadow-slate-500/50 hover:scale-105"
v-on:click="displayAddForm">
<div class="text-white/50 text-9xl">+</div>
</div>
</div>
<!-- Add Form Dialog-->
<div v-if="showAddForm" id="add-form-mask"
class="fixed top-0 left-0 w-screen h-screen flex justify-center items-center bg-black/70"
v-on:click.self="showAddForm=false">
<!-- Add Form Container -->
<div class="h-80 max-w-6xl max-h-max bg-white flex gap-2 scale-150 bg-transparent">
<!-- Add Demo -->
<div id="add-card-demo"
class="w-56 shrink-0 origin-center rounded-2xl bg-white bg-cover bg-center bg-transparent transition ease-in-out hover:shadow-2xl hover:shadow-slate-500/50"
v-bind:style="{'background-image': 'url('+addCardFormData.cover+')'}">
<button class="fixed top-2 right-2 text-2xl transition ease-in-out hover:scale-125"
v-on:click="refreshDemoCardBackground">
👋
</button>
<button class="w-full h-full flex flex-col">
<div id="add-card-demo-header" class="w-full h-1/5 flex justify-end">
<div v-if="!locked" class="px-6 py-5 text-white text-2xl font-semibold">✕
</div>
</div>
<div id="add-card-dmo-mask" class="w-full h-2/5">
</div>
<div id="add-card-dmo-content"
class="w-full h-2/5 px-4 py-8 rounded-b-2xl bg-white/10 backdrop-blur flex flex-col gap-4 items-end justify-end text-white">
<p class="h-1/3 text-lg">{{addCardFormData.title}}</p>
<p class="h-1/3 text-sm text-ellipsis">{{addCardFormData.description}}</p>
</div>
</button>
</div>
<!-- Add Form -->
<div id="add-form"
class="w-full h-full grow pl-10 pr-20 py-12 flex flex-col gap-6 font-semibold bg-white rounded-2xl shadow-2xl shadow-white/50">
<div class="flex gap-4">
<label for="title" class="p-2 text-gray-600">标题:</label>
<div class="rounded-lg transition ease-in-out hover:shadow-lg">
<input v-model="addCardFormData.title" id="title"
class="p-2 rounded-lg border border-gray-300 text-lg" type="text"
name="title" placeholder="给标签起一个名字" />
</div>
</div>
<div class="flex gap-4">
<label for="url" class="p-2 text-gray-600">网址:</label>
<div class="rounded-lg transition ease-in-out hover:shadow-lg">
<input v-model="addCardFormData.url" id="url"
class="p-2 rounded-lg border border-gray-300 text-lg" type="text"
name="url" placeholder="请输入地址栏里的地址" />
</div>
</div>
<div class="flex gap-4">
<label for="description" class="p-2 text-gray-600">描述:</label>
<div class="rounded-lg transition ease-in-out hover:shadow-lg">
<input v-model="addCardFormData.description" id="description"
class="p-2 rounded-lg border border-gray-300 text-lg" type="text"
name="description" placeholder="请简要描述这个网页" />
</div>
</div>
<div class="w-full px-8">
<button
class="w-full bg-indigo-400 hover:bg-indigo-500 hover:shadow-lg p-2 rounded-lg text-white transition ease-in-out hover:scale-105"
v-on:click="add">添加</button>
</div>
</div>
</div>
</div>
</div>
<!-- Footer -->
<div id="footer" class="container mx-auto py-20">
<div class="text-right text-white">
Copyright © 2022 Mr.Char All rights reserved.
</div>
</div>
</div>
</div>
</div>
</div>
<script>
const App = {
data() {
return {
randomPhotoUrl: "",
backgroundImage: "",
locked: true,
sites: [],
showAddForm: false,
addCardFormData: {
title: "",
url: "",
description: "",
cover: ""
}
}
},
methods: {
async loadConfig() {
let sites = localStorage.getItem('sites')
this.sites = sites ? JSON.parse(sites) : []
let backgroundImage = localStorage.getItem('backgroundImage') || await this.getRandomPhoto()
this.setBackgroundImage(backgroundImage)
},
async getRandomPhoto() {
this.randomPhotoUrl = (await fetch("https://source.unsplash.com/random")).url
return this.randomPhotoUrl
},
refreshBackground() {
this.getRandomPhoto().then(url => { this.setBackgroundImage(url) })
},
open(url) {
window.open(url, '_blank')
},
refreshDemoCardBackground() {
this.getRandomPhoto().then((url) => { this.addCardFormData.cover = url })
},
displayAddForm() {
this.showAddForm = true
this.refreshDemoCardBackground()
},
add() {
this.sites.push(this.addCardFormData)
localStorage.setItem('sites', JSON.stringify(this.sites));
this.addCardFormData = {
title: "",
url: "",
description: "",
cover: ""
}
this.showAddForm = false
},
remove(index) {
this.sites.splice(index, 1)
localStorage.setItem('sites', JSON.stringify(this.sites));
},
setBackgroundImage(url) {
this.backgroundImage = url
localStorage.setItem('backgroundImage', url)
}
},
beforeMount() {
this.loadConfig()
},
}
Vue.createApp(App).mount("#app")
</script>
</body>
</html>