主要功能: - 修改RequirementModal支持12个订单班选择 - 添加OrderClassIconMap图标映射组件 - Store中添加selectedOrderClass状态管理 - WorkflowPage支持传递orderClass参数 - web_result添加URL参数切换功能 - 创建order-class-handler.js动态处理页面主题 技术改进: - 创建软链接关联订单班数据目录 - 生成wenlu.json和food.json数据结构 - 删除重复的web_result目录 - 添加测试页面test-order-class.html 影响范围: - 展会策划系统现支持12个订单班 - 结果展示页面自动适配不同订单班主题 - 用户可选择不同行业生成对应方案 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
112 lines
2.7 KiB
JavaScript
112 lines
2.7 KiB
JavaScript
/**
|
|
* @fileoverview Shared functions to work with configs.
|
|
* @author Nicholas C. Zakas
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Functions
|
|
//-----------------------------------------------------------------------------
|
|
|
|
/**
|
|
* Parses a ruleId into its plugin and rule parts.
|
|
* @param {string} ruleId The rule ID to parse.
|
|
* @returns {{pluginName:string,ruleName:string}} The plugin and rule
|
|
* parts of the ruleId;
|
|
*/
|
|
function parseRuleId(ruleId) {
|
|
let pluginName, ruleName;
|
|
|
|
// distinguish between core rules and plugin rules
|
|
if (ruleId.includes("/")) {
|
|
|
|
// mimic scoped npm packages
|
|
if (ruleId.startsWith("@")) {
|
|
pluginName = ruleId.slice(0, ruleId.lastIndexOf("/"));
|
|
} else {
|
|
pluginName = ruleId.slice(0, ruleId.indexOf("/"));
|
|
}
|
|
|
|
ruleName = ruleId.slice(pluginName.length + 1);
|
|
} else {
|
|
pluginName = "@";
|
|
ruleName = ruleId;
|
|
}
|
|
|
|
return {
|
|
pluginName,
|
|
ruleName
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Retrieves a rule instance from a given config based on the ruleId.
|
|
* @param {string} ruleId The rule ID to look for.
|
|
* @param {FlatConfig} config The config to search.
|
|
* @returns {import("../shared/types").Rule|undefined} The rule if found
|
|
* or undefined if not.
|
|
*/
|
|
function getRuleFromConfig(ruleId, config) {
|
|
|
|
const { pluginName, ruleName } = parseRuleId(ruleId);
|
|
|
|
const plugin = config.plugins && config.plugins[pluginName];
|
|
let rule = plugin && plugin.rules && plugin.rules[ruleName];
|
|
|
|
|
|
// normalize function rules into objects
|
|
if (rule && typeof rule === "function") {
|
|
rule = {
|
|
create: rule
|
|
};
|
|
}
|
|
|
|
return rule;
|
|
}
|
|
|
|
/**
|
|
* Gets a complete options schema for a rule.
|
|
* @param {{create: Function, schema: (Array|null)}} rule A new-style rule object
|
|
* @returns {Object} JSON Schema for the rule's options.
|
|
*/
|
|
function getRuleOptionsSchema(rule) {
|
|
|
|
if (!rule) {
|
|
return null;
|
|
}
|
|
|
|
const schema = rule.schema || rule.meta && rule.meta.schema;
|
|
|
|
if (Array.isArray(schema)) {
|
|
if (schema.length) {
|
|
return {
|
|
type: "array",
|
|
items: schema,
|
|
minItems: 0,
|
|
maxItems: schema.length
|
|
};
|
|
}
|
|
return {
|
|
type: "array",
|
|
minItems: 0,
|
|
maxItems: 0
|
|
};
|
|
|
|
}
|
|
|
|
// Given a full schema, leave it alone
|
|
return schema || null;
|
|
}
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
// Exports
|
|
//-----------------------------------------------------------------------------
|
|
|
|
module.exports = {
|
|
parseRuleId,
|
|
getRuleFromConfig,
|
|
getRuleOptionsSchema
|
|
};
|