详细说明: - 基于文旅订单班框架复制创建food-order-demo项目 - 修改端口配置为4174避免冲突 - 更新LandingPage为青莳轻食主题(绿色健康风格) - 重新定义7个食品行业专业Agent: * 市场研究专家:轻食市场分析、客群画像 * 营养配方师:营养成分配比、低卡高蛋白设计 * 供应链管理专家:有机食材供应、溯源体系 * 品牌策划师:品牌定位、店铺空间布局 * 财务分析师:投资预算、ROI分析 * 运营管理专家:运营流程、品控标准 * 食品创业导师:中央协调、方案整合 - 创建专用启动脚本start.sh - 验证系统可正常运行在端口4174 - 实现代码复用率90%,符合预期目标 影响文件: web_frontend/food-order-demo/ 技术栈: React 18 + TypeScript + Tailwind CSS + Zustand
84 lines
2.4 KiB
JavaScript
84 lines
2.4 KiB
JavaScript
/*
|
|
** © 2020 by Philipp Dunkel, Ben Noordhuis, Elan Shankar, Paul Miller
|
|
** Licensed under MIT License.
|
|
*/
|
|
|
|
/* jshint node:true */
|
|
"use strict";
|
|
|
|
if (process.platform !== "darwin") {
|
|
throw new Error(`Module 'fsevents' is not compatible with platform '${process.platform}'`);
|
|
}
|
|
|
|
const Native = require("./fsevents.node");
|
|
const events = Native.constants;
|
|
|
|
function watch(path, since, handler) {
|
|
if (typeof path !== "string") {
|
|
throw new TypeError(`fsevents argument 1 must be a string and not a ${typeof path}`);
|
|
}
|
|
if ("function" === typeof since && "undefined" === typeof handler) {
|
|
handler = since;
|
|
since = Native.flags.SinceNow;
|
|
}
|
|
if (typeof since !== "number") {
|
|
throw new TypeError(`fsevents argument 2 must be a number and not a ${typeof since}`);
|
|
}
|
|
if (typeof handler !== "function") {
|
|
throw new TypeError(`fsevents argument 3 must be a function and not a ${typeof handler}`);
|
|
}
|
|
|
|
let instance = Native.start(Native.global, path, since, handler);
|
|
if (!instance) throw new Error(`could not watch: ${path}`);
|
|
return () => {
|
|
const result = instance ? Promise.resolve(instance).then(Native.stop) : Promise.resolve(undefined);
|
|
instance = undefined;
|
|
return result;
|
|
};
|
|
}
|
|
|
|
function getInfo(path, flags) {
|
|
return {
|
|
path,
|
|
flags,
|
|
event: getEventType(flags),
|
|
type: getFileType(flags),
|
|
changes: getFileChanges(flags),
|
|
};
|
|
}
|
|
|
|
function getFileType(flags) {
|
|
if (events.ItemIsFile & flags) return "file";
|
|
if (events.ItemIsDir & flags) return "directory";
|
|
if (events.MustScanSubDirs & flags) return "directory";
|
|
if (events.ItemIsSymlink & flags) return "symlink";
|
|
}
|
|
function anyIsTrue(obj) {
|
|
for (let key in obj) {
|
|
if (obj[key]) return true;
|
|
}
|
|
return false;
|
|
}
|
|
function getEventType(flags) {
|
|
if (events.ItemRemoved & flags) return "deleted";
|
|
if (events.ItemRenamed & flags) return "moved";
|
|
if (events.ItemCreated & flags) return "created";
|
|
if (events.ItemModified & flags) return "modified";
|
|
if (events.RootChanged & flags) return "root-changed";
|
|
if (events.ItemCloned & flags) return "cloned";
|
|
if (anyIsTrue(flags)) return "modified";
|
|
return "unknown";
|
|
}
|
|
function getFileChanges(flags) {
|
|
return {
|
|
inode: !!(events.ItemInodeMetaMod & flags),
|
|
finder: !!(events.ItemFinderInfoMod & flags),
|
|
access: !!(events.ItemChangeOwner & flags),
|
|
xattrs: !!(events.ItemXattrMod & flags),
|
|
};
|
|
}
|
|
|
|
exports.watch = watch;
|
|
exports.getInfo = getInfo;
|
|
exports.constants = events;
|