增加新项目

This commit is contained in:
2025-03-16 23:01:07 +08:00
parent 3f86afc191
commit 353b15385f
49 changed files with 4407 additions and 2 deletions

View File

@@ -0,0 +1,106 @@
const footer = () => {
let currentHref = location.href
let html = `
<ul class="footer fixed flex jc-sb ai-c border-box border-top">
${config.footerArr.maps((v, i) => {
return `<li class="${location.href.includes(v.href) ? 'active' : ''}">
<a href="${v.href}">
<i class="iconfont ${v.icon}"></i>
<div>${v.title}</div>
</a>
</li>`
})}
</ul>
`
$("body").insertAdjacentHTML("beforeend", html)
}
const header = (right, center = "", left = `<i class="iconfont icon-fanhui"></i>`) => {
let html = `
<div class="header fixed flex ai-c jc-sb p18 border-box border-bottom">
${left}
<div class="header_title ellipsis">${center}</div>
${right}
</div>
`
$("body").insertAdjacentHTML("afterbegin", html)
_(".header .icon-fanhui").click(v => {
history.back()
})
}
const item = (father, data) => {
(typeof father == "string" ? $(father) : father).insertAdjacentHTML("beforeend",data.maps(v => {
return `
<li>
<a href="./info.html?id=${v.id}&time=${v.time}&view=${v.view}">
<img src="${v.thumbnail}" alt="">
<div class="desc">
<div class="name ellipsis">${v.title}</div>
<div class="time flex ai-c jc-sb">
<div class="text">${v.time}</div>
<div class="view flex ai-c">
<i class="iconfont icon-liulan"></i>
<span>${v.view}W+</span>
</div>
</div>
</div>
</a>
</li>
`
}))
}
const query = name =>{
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null)return decodeURIComponent(r[2]); return null;
}
const stripIndents = (template, ...expressions) => {
let result = template.reduce((prev, next, i) => {
let expression = expressions[i - 1];
return prev + expression + next;
});
result = result.replace(/\n[^\S\n]*/g, '\n');
result = result.trim();
return result;
}
const innerMaps = (father, data, callback) => {
$(father).insertAdjacentHTML("afterbegin", data.maps((v,i) => {
return callback(v,i)
}))
}
const $ = className => {
return document.querySelector(className)
}
const _ = className => {
return document.querySelectorAll(className)
}
// prototype 原型
// js给我们提供的一个方法通过这个方法作为入口
// 我们可以直接对js进行修改
Array.prototype.maps = function (callback) {
let result = []
for (let i = 0; i < this.length; i++) {
result.push(callback(this[i], i, this))
}
return result.toString().replaceAll(",", "")
}
NodeList.prototype.click = function (callback) {
this.forEach((v,i) => v.onclick = () => callback(v,i))
}
NodeList.prototype.scroll = function (callback) {
this.forEach((v,i) => v.onscroll = () => callback(v,i))
}

View File

@@ -0,0 +1,10 @@
(function (w, d) {
function setSize() {
var screenWidth = d.documentElement.clientWidth;
var currentFontSize = screenWidth * 100 / 750;
d.documentElement.style.fontSize = currentFontSize + 'px';
}
w.addEventListener('resize', setSize);
w.addEventListener('pageShow', setSize)
w.addEventListener('DOMContentLoaded', setSize)
})(window, document)