-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.html
44 lines (39 loc) · 1.47 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
<title>弹弹绑定</title>
<div id="app"></div>
<style>
main{width:600px;margin:10px auto}
button{background:#333;color:#fff;border:0;padding:4px;}
input{width:60px;border:1px solid #eee;height:26px;margin:0 10px}
li{list-style:none;padding:10px;border-bottom:1px solid #eee;width: 100%;display:flex;justify-content:space-between;}
p{padding:0 10px}
</style>
<script type="module">
import {
html,
render,
signal,
} from "https://cdn.jsdelivr.net/npm/preact-htm-signals-standalone/dist/standalone.js";
const name = signal('');
const gv = signal(0)
const animes = signal([])
function onSearch(){
fetch(`https://danmu.deno.dev/danmu/list?gv=0&p=1&title=${name}`).then(res=>res.json()).then(data=>{
console.log(data.animes)
animes.value=data.animes
})
}
function onBind(did){
fetch(`https://danmu.deno.dev/danmu/bind?gv=${gv}&did=${did}`).then(res=>res.json()).then(data=>{
alert(data.msg)
})
}
function App() {
return html`
<main>
<input type="text" onInput=${(e)=>name.value=e.target.value} placeholder="例:博人传" style="width:200px"></input> <button onClick=${() => onSearch()}>搜索</button>
${animes.value.map(a=>html`<li>${a.animeTitle}<div>gv<input type="text" onInput=${(e)=>gv.value=e.target.value} placeholder="gv号"/> <button onClick=${() => onBind(a.animeId)}>绑定</button></div></li>`)}
</main>
`;
}
render(html`<${App} />`, document.getElementById("app"));
</script>