first commit

This commit is contained in:
编码猿
2024-09-27 02:06:13 +08:00
commit 852d94fbb9
36760 changed files with 3274413 additions and 0 deletions

View File

@@ -0,0 +1,125 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
ul{
display: flex;
flex-wrap: wrap;
list-style: none;
}
ul li{
width: 20%;
}
</style>
</head>
<body>
<ul>
</ul>
<button>点击</button><div style="display: none;">没了</div>
</body>
<script src="./js/index.js"></script>
<script>
let page =1, max=0;
eee();
function eee() {
//promise
let index = async () => {
let se = await http.get({
url: "http://127.0.0.1:3000/api/json/classList",
data: {
id : 253,
page
}
})
console.log(se)
max=se.result.total_page
se.result.data.forEach(v => {
$("ul").innerHTML+= `
<li>
<a target="_blank" href="./index2.html?id=${v.id}&total=${v.total}"">
<img src="${v.preview}" alt="">
<div>${v.title}</div>
</a>
</li>`
});
}
index();
$("button").onclick=()=>{
page+=1
if(page==max){
$("div").style.display="block"
}else{
index();
}
}
//callback 获取异步返回值
// http.get({
// url: "http://127.0.0.1:3000/api/json/index",
// success:(e)=>{
// console.log(e)
// e.result.list.forEach(v => {
// $(".qwe").innerHTML +=`<img src="${v.img_src}" alt="">`
// });
// },
// error:(er)=>{
// }
// })
// let xhr = new XMLHttpRequest();
// xhr.open("GET", "http://127.0.0.1:3000/api/json/index")
// xhr.setRequestHeader()
// xhr.timeout()
// xhr.send()
// xhr.onreadystatechange = () => {
// if (xhr.readyState == "4") {
// if (xhr.status == "200") {
// }
// }
// }
}
function $(name) {
return document.querySelector(name);
}
function _(name) {
return document.querySelectorAll(name);
}
</script>
</html>

View File

@@ -0,0 +1,72 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
body {
height: 100vh;
}
div {
height: 100%;
}
div img {
width: 100%;
height: 100%;
object-fit: cover;
}
</style>
</head>
<body>
<div></div>
</body>
<script src="./js/index.js"></script>
<script>
let ttt = () => {
let index = async () => {
let se = await http.get({
url: "http://127.0.0.1:3000/api/json/info",
data: {
id: query("id"),
quantity: query("total")
}
})
console.log(se)
let dd=0
setInterval(() => {
if(dd<se.result.length){
$("div").innerHTML += `
<img src="${se.result[dd]}" alt="">`
dd+=1
}
}, 2000)
}
index()
}
ttt();
function query(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if (r != null)
return unescape(r[2]);
return null;
}
function $(className) {
return document.querySelector(className);
}
</script>
</html>

View File

@@ -0,0 +1,132 @@
class html {
//默认head
timeout=10000
Headermr={
'Content-Type': 'application/json;charset=utf-8'
}
constructor() {
//创建 XMLHttpRequest 对象
this.xhr = new XMLHttpRequest()
}
/*html.get({
url() -- 请求的地址
method: -- 请求的类型
data{ -- 数据 get 传输方式是在地址后拼接传输的 post 是在 send()里面传输的
id="1"
text="好的"
}
timeout: -- 网络请求超时间
header:{} -- 请求头
})*/
//promise
get(par) {
return new Promise((success,error)=>{
this.timeoutm(par)
let urldata = "" //创建一个变量储存数据 用来拼接
//遍历data
for (const key in par.data) {
urldata += `&${key}=${par.data[key]}` //进行拼接
}
urldata = urldata.replace("&", ""); //将第一个开头的&替换成空
//创建一个新的HTTP请求,并指定该请求的方法、URL及验证信息
this.xhr.open("GET", `${par.url}?${urldata}`)
console.log("GET", `${par.url}?${urldata}`)
this.xhr.timeout=this.timeout;
this.RequestHeader(par.Header)
//将请求发送出去
this.xhr.send()
//回调函数对不同状态进行处理
this.statechange(success, error)
})
}
//callback
/*get传值方法
get(par) {
this.timeoutm(par)
let urldata = "" //创建一个变量储存数据 用来拼接
//遍历data
for (const key in par.data) {
urldata = `&${key}=${par.data[key]}` //进行拼接
}
urldata = urldata.replace("&", ""); //将第一个开头的&替换成空
//创建一个新的HTTP请求,并指定该请求的方法、URL及验证信息
this.xhr.open("GET", `${par.url}?${urldata}`)
this.xhr.timeout=this.timeout;
this.RequestHeader(par.Header)
//将请求发送出去
this.xhr.send()
//回调函数对不同状态进行处理
this.statechange(par.success, par.error)
}
//post传值方法
post(par) {
this.timeout(par)
//创建一个新的HTTP请求,并指定该请求的方法、URL及验证信息
this.xhr.open("POST", `${par.url}`)
this.RequestHeader(par.Header)
//将请求发送出去
this.xhr.send(JSON.stringify(par.data))
//回调函数对不同状态进行处理
this.statechange(par.success, par.error)
}*/
//回调函数
statechange(success, error) {
this.xhr.onreadystatechange = () => {
if (this.xhr.readyState == "4") {
if (this.xhr.status == "200") {
let data=JSON.parse(this.xhr.response)
success(data)
}else{
error(this.xhr)
}
}
}
}
//多个请求头遍历
RequestHeader(Header={}){
Object.assign(Header,this.Headermr)
for (const key in Header) {
this.xhr.setRequestHeader(key,Header[key]);
}
}
timeoutm(par){
this.timeout=par.timeout||this.timeout;
}
}
var http = new html()
/*
let xhr = new XMLHttpRequest();
xhr.open("GET", "http://127.0.0.1:3000/api/json/index")
xhr.setRequestHeader()
xhr.timeout()
xhr.send()
xhr.onreadystatechange = () => {
if (xhr.readyState == "4") {
if (xhr.status == "200") {
}
}
} */