upload project source code
This commit is contained in:
54
后端源码/yifan.action-ai.cn/index/js/common.ySZAMJjg.js
Normal file
54
后端源码/yifan.action-ai.cn/index/js/common.ySZAMJjg.js
Normal file
@@ -0,0 +1,54 @@
|
||||
function greetings() {
|
||||
const currentDate = /* @__PURE__ */ new Date();
|
||||
const hours = currentDate.getHours();
|
||||
if (hours >= 6 && hours < 8) {
|
||||
return "晨起披衣出草堂,轩窗已自喜微凉🌅!";
|
||||
} else if (hours >= 8 && hours < 12) {
|
||||
return `上午好!`;
|
||||
} else if (hours >= 12 && hours < 14) {
|
||||
return `中午好!`;
|
||||
} else if (hours >= 14 && hours < 18) {
|
||||
return `下午好!`;
|
||||
} else if (hours >= 18 && hours < 24) {
|
||||
return `晚上好!`;
|
||||
} else {
|
||||
return "偷偷向银河要了一把碎星,只等你闭上眼睛撒入你的梦中,晚安🌛!";
|
||||
}
|
||||
}
|
||||
function listToTree(list) {
|
||||
const map = {};
|
||||
list.forEach((item) => {
|
||||
map[item.id] = { ...item };
|
||||
});
|
||||
const tree = [];
|
||||
list.forEach((item) => {
|
||||
const parentId = item.parent_id;
|
||||
if (parentId && map[parentId]) {
|
||||
if (!map[parentId].children) {
|
||||
map[parentId].children = [];
|
||||
}
|
||||
map[parentId].children.push(map[item.id]);
|
||||
} else if (parentId === null || parentId === void 0) {
|
||||
tree.push(map[item.id]);
|
||||
}
|
||||
});
|
||||
return tree;
|
||||
}
|
||||
function formatTree(nodes) {
|
||||
return nodes.map((node) => {
|
||||
const formattedNode = {
|
||||
value: node.id,
|
||||
label: node.name,
|
||||
disabled: node.status === false || String(node.status) === "false"
|
||||
};
|
||||
if (node.children && node.children.length > 0) {
|
||||
Object.assign(formattedNode, { children: formatTree(node.children) });
|
||||
}
|
||||
return formattedNode;
|
||||
});
|
||||
}
|
||||
export {
|
||||
formatTree as f,
|
||||
greetings as g,
|
||||
listToTree as l
|
||||
};
|
||||
Reference in New Issue
Block a user