modules 添加web

This commit is contained in:
Xwite
2023-04-07 20:27:20 +08:00
parent 3447e46176
commit 57e2c3a418
88 changed files with 5784 additions and 0 deletions

View File

@@ -0,0 +1,70 @@
import body_0 from "../assets/imgs/themes/body_0.png";
import content_0 from "../assets/imgs/themes/content_0.png";
import popup_0 from "../assets/imgs/themes/popup_0.png";
import body_1 from "../assets/imgs/themes/body_1.png";
import content_1 from "../assets/imgs/themes/content_1.png";
import popup_1 from "../assets/imgs/themes/popup_1.png";
import body_2 from "../assets/imgs/themes/body_2.png";
import content_2 from "../assets/imgs/themes/content_2.png";
import popup_2 from "../assets/imgs/themes/popup_2.png";
import body_3 from "../assets/imgs/themes/body_3.png";
import content_3 from "../assets/imgs/themes/content_3.png";
import popup_3 from "../assets/imgs/themes/popup_3.png";
import body_5 from "../assets/imgs/themes/body_5.png";
import content_5 from "../assets/imgs/themes/content_5.png";
import popup_5 from "../assets/imgs/themes/popup_5.png";
import body_6 from "../assets/imgs/themes/body_6.png";
import content_6 from "../assets/imgs/themes/content_6.png";
import popup_6 from "../assets/imgs/themes/popup_6.png";
var settings = {
themes: [
{
body: "#ede7da url(" + body_0 + ") repeat",
content: "#ede7da url(" + content_0 + ") repeat",
popup: "#ede7da url(" + popup_0 + ") repeat",
},
{
body: "#ede7da url(" + body_1 + ") repeat",
content: "#ede7da url(" + content_1 + ") repeat",
popup: "#ede7da url(" + popup_1 + ") repeat",
},
{
body: "#ede7da url(" + body_2 + ") repeat",
content: "#ede7da url(" + content_2 + ") repeat",
popup: "#ede7da url(" + popup_2 + ") repeat",
},
{
body: "#ede7da url(" + body_3 + ") repeat",
content: "#ede7da url(" + content_3 + ") repeat",
popup: "#ede7da url(" + popup_3 + ") repeat",
},
{
body: "#ebcece repeat",
content: "#f5e4e4 repeat",
popup: "#faeceb repeat",
},
{
body: "#ede7da url(" + body_5 + ") repeat",
content: "#ede7da url(" + content_5 + ") repeat",
popup: "#ede7da url(" + popup_5 + ") repeat",
},
{
body: "#ede7da url(" + body_6 + ") repeat",
content: "#ede7da url(" + content_6 + ") repeat",
popup: "#ede7da url(" + popup_6 + ") repeat",
},
],
fonts: [
{
fontFamily:
"Microsoft YaHei, PingFangSC-Regular, HelveticaNeue-Light, Helvetica Neue Light, sans-serif",
},
{
fontFamily: "PingFangSC-Regular, -apple-system, Simsun",
},
{
fontFamily: "Kaiti",
},
],
};
export default settings;

View File

@@ -0,0 +1,186 @@
const easeInOutQuad = (t, b, c, d) => {
t /= d / 2;
if (t < 1) return (c / 2) * t * t + b;
t--;
return (-c / 2) * (t * (t - 2) - 1) + b;
};
const jumper = () => {
// private variable cache
// no variables are created during a jump, preventing memory leaks
let container; // container element to be scrolled (node)
let element; // element to scroll to (node)
let start; // where scroll starts (px)
let stop; // where scroll stops (px)
let offset; // adjustment from the stop position (px)
let easing; // easing function (function)
let a11y; // accessibility support flag (boolean)
let distance; // distance of scroll (px)
let duration; // scroll duration (ms)
let timeStart; // time scroll started (ms)
let timeElapsed; // time spent scrolling thus far (ms)
let next; // next scroll position (px)
let callback; // to call when done scrolling (function)
// scroll position helper
function location() {
let top = container.scrollTop || container.scrollY || container.pageYOffset;
top = typeof top === "undefined" ? 0 : top;
return top;
}
// element offset helper
function top(element) {
const elementTop = element.getBoundingClientRect().top;
const containerTop = container.getBoundingClientRect
? container.getBoundingClientRect().top
: 0;
return elementTop - containerTop + start;
}
// scrollTo helper
function scrollTo(top) {
container.scrollTo
? container.scrollTo(0, top) // window
: (container.scrollTop = top); // custom container
}
// rAF loop helper
function loop(timeCurrent) {
// store time scroll started, if not started already
if (!timeStart) {
timeStart = timeCurrent;
}
// determine time spent scrolling so far
timeElapsed = timeCurrent - timeStart;
// calculate next scroll position
next = easing(timeElapsed, start, distance, duration);
// scroll to it
scrollTo(next);
// check progress
timeElapsed < duration
? requestAnimationFrame(loop) // continue scroll loop
: done(); // scrolling is done
}
// scroll finished helper
function done() {
// account for rAF time rounding inaccuracies
scrollTo(start + distance);
// if scrolling to an element, and accessibility is enabled
if (element && a11y) {
// add tabindex indicating programmatic focus
element.setAttribute("tabindex", "-1");
// focus the element
element.focus();
}
// if it exists, fire the callback
if (typeof callback === "function") {
callback();
}
// reset time for next jump
timeStart = false;
}
// API
function jump(target, options = {}) {
// resolve options, or use defaults
duration = options.duration || 1000;
offset = options.offset || 0;
callback = options.callback; // "undefined" is a suitable default, and won't be called
easing = options.easing || easeInOutQuad;
a11y = options.a11y || false;
// resolve container
switch (typeof options.container) {
case "object":
// we assume container is an HTML element (Node)
container = options.container;
break;
case "string":
container = document.querySelector(options.container);
break;
default:
container = window;
}
// cache starting position
start = location();
// resolve target
switch (typeof target) {
// scroll from current position
case "number":
element = undefined; // no element to scroll to
a11y = false; // make sure accessibility is off
stop = start + target;
break;
// scroll to element (node)
// bounding rect is relative to the viewport
case "object":
element = target;
stop = top(element);
break;
// scroll to element (selector)
// bounding rect is relative to the viewport
case "string":
element = document.querySelector(target);
stop = top(element);
break;
}
// resolve scroll distance, accounting for offset
distance = stop - start + offset;
// resolve duration
switch (typeof options.duration) {
// number in ms
case "number":
duration = options.duration;
break;
// function passed the distance of the scroll
case "function":
duration = options.duration(distance);
break;
}
// start the loop
requestAnimationFrame(loop);
}
// expose only the jump method
return jump;
};
// export singleton
const singleton = jumper();
export default singleton;

View File

@@ -0,0 +1,49 @@
import { formatDate } from "@vueuse/shared";
export const isLegadoUrl = (/** @type {string} */ url) =>
/,\s*\s*\{/.test(url) ||
!(
url.startsWith("http") ||
url.startsWith("data:") ||
url.startsWith("blob:")
);
/**
* @param {string} src
*/
export function getImageFromLegado(src) {
//返回阅读代理的图片链接 已经代理的或者dataurl返回传入值
if (!isLegadoUrl(src)) {
return src;
}
return (
(import.meta.env.VITE_API || location.origin) +
"/image?path=" +
encodeURIComponent(src) +
"&url=" +
encodeURIComponent(sessionStorage.getItem("bookUrl")) +
"&width=" +
useBookStore().config.readWidth
);
}
// @ts-ignore
export const dateFormat = (/** @type {number} */ t) => {
let time = new Date().getTime();
let offset = Math.floor((time - t) / 1000);
let str = "";
if (offset <= 30) {
str = "刚刚";
} else if (offset < 60) {
str = offset + "秒前";
} else if (offset < 3600) {
str = Math.floor(offset / 60) + "分钟前";
} else if (offset < 86400) {
str = Math.floor(offset / 3600) + "小时前";
} else if (offset < 2592000) {
str = Math.floor(offset / 86400) + "天前";
} else {
str = formatDate(new Date(t), "YYYY-MM-DD");
}
return str;
};