first commit

This commit is contained in:
dekun
2026-06-10 19:59:27 +08:00
commit d141623070
813 changed files with 61301 additions and 0 deletions
+74
View File
@@ -0,0 +1,74 @@
export function animateChildren(
container: Element,
duration: number = 300,
easing: string = "ease-out",
) {
interface ItemInfo {
element: Element;
x: number;
y: number;
width: number;
height: number;
}
function getItemInfos(container: Element): ItemInfo[] {
return Array.from(container.children).map((item) => {
const rect = item.getBoundingClientRect();
return {
element: item,
x: rect.left,
y: rect.top,
width: rect.width,
height: rect.height,
};
});
}
function animateItems(oldItems: ItemInfo[], newItems: ItemInfo[]) {
for (const newItem of newItems) {
if (newItem.element.className.includes("ignore-animate")) {
continue;
}
let oldItem = oldItems.find((e) => e.element == newItem.element);
if (!oldItem) {
oldItem = {
element: newItem.element,
x: newItem.x,
y: newItem.y,
height: newItem.height / 1.5,
width: newItem.width / 1.5,
};
}
const translateX = oldItem.x - newItem.x;
const translateY = oldItem.y - newItem.y;
const scaleX = oldItem.width / newItem.width;
const scaleY = oldItem.height / newItem.height;
newItem.element.animate(
[
{
transform: `translate(${translateX}px, ${translateY}px) scale(${scaleX}, ${scaleY})`,
},
{ transform: "none" },
],
{ duration: duration, easing: easing },
);
}
}
let oldItemInfos = getItemInfos(container);
const observer = new MutationObserver(function (
mutations: MutationRecord[],
observer: MutationObserver,
) {
const newItemInfos = getItemInfos(container);
if (oldItemInfos) {
animateItems(oldItemInfos, newItemInfos);
}
oldItemInfos = newItemInfos;
});
observer.observe(container, { childList: true });
return observer;
}
+2
View File
@@ -0,0 +1,2 @@
export const ERROR_PREFIX = "::error::";
export const VERSION = "1.0.0";
+41
View File
@@ -0,0 +1,41 @@
import fs from "fs/promises";
import path from "path";
const CONTENT_ROOT = path.join(process.cwd(), "content", "zhouyi", "docs");
export async function readGuaMarkdown(guaMark: string): Promise<string> {
const filePath = path.join(CONTENT_ROOT, guaMark, "index.md");
return fs.readFile(filePath, "utf-8");
}
export function extractZhangMingRen(guaDetail: string): string | undefined {
return guaDetail
.match(/(\*\*台灣張銘仁[\s\S]*?)(?=周易第\d+卦)/)?.[1]
?.replaceAll("\n\n", "\n");
}
export function extractChangeDetails(
guaDetail: string,
guaChange: string,
guaTitle: string,
): string[] {
const changeList: string[] = [];
if (guaChange === "无变爻") {
return changeList;
}
guaChange
.split(":")[1]
.trim()
.split(",")
.forEach((change) => {
const detail = guaDetail
.match(`(\\*\\*${change}變卦[\\s\\S]*?)(?=${guaTitle}|$)`)?.[1]
?.replaceAll("\n\n", "\n");
if (detail) {
changeList.push(detail.trim());
}
});
return changeList;
}
+10
View File
@@ -0,0 +1,10 @@
[
[2, 24, 7, 19, 15, 36, 46, 11],
[16, 51, 40, 54, 62, 55, 32, 34],
[8, 3, 29, 60, 39, 63, 48, 5],
[45, 17, 47, 58, 31, 49, 28, 43],
[23, 27, 4, 41, 52, 22, 18, 26],
[35, 21, 64, 38, 56, 30, 50, 14],
[20, 42, 59, 61, 53, 37, 57, 9],
[12, 25, 6, 10, 33, 13, 44, 1]
]
+66
View File
@@ -0,0 +1,66 @@
[
"乾",
"坤",
"屯",
"蒙",
"需",
"讼",
"师",
"比",
"小畜",
"履",
"泰",
"否",
"同人",
"大有",
"谦",
"豫",
"随",
"蛊",
"临",
"观",
"噬嗑",
"贲",
"剥",
"复",
"无妄",
"大畜",
"颐",
"大过",
"坎",
"离",
"咸",
"恒",
"遁",
"大壮",
"晋",
"明夷",
"家人",
"睽",
"蹇",
"解",
"损",
"益",
"夬",
"姤",
"萃",
"升",
"困",
"井",
"革",
"鼎",
"震",
"艮",
"渐",
"归妹",
"丰",
"旅",
"巽",
"兑",
"涣",
"节",
"中孚",
"小过",
"既济",
"未济"
]
+8
View File
@@ -0,0 +1,8 @@
[
"今天运势如何?",
"今天适合买彩票吗?",
"每日一卦",
"事业发展",
"感情状况",
"财运"
]
+6
View File
@@ -0,0 +1,6 @@
import { type ClassValue, clsx } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}