Просмотр исходного кода

feat: 添加项目配置文件和 JSON Schema,优化开发环境

XingHeYuZhuan 1 месяц назад
Родитель
Сommit
9a64f47739

+ 8 - 0
.gitignore

@@ -0,0 +1,8 @@
+.idea/*
+!.idea/jsonSchemas.xml
+.vscode/*
+!.vscode/extensions.json
+!.vscode/settings.json
+
+# 忽略适配占位符文件,防止开发者误提交测试代码
+resources/GLOBAL_TOOLS/test.js

+ 41 - 0
.idea/jsonSchemas.xml

@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="JsonSchemaMappingsProjectConfiguration">
+    <state>
+      <map>
+        <entry key="adapters.schema">
+          <value>
+            <SchemaInfo>
+              <option name="name" value="adapters.schema" />
+              <option name="relativePathToSchema" value="scripts/schemas/adapters.schema.json" />
+              <option name="patterns">
+                <list>
+                  <Item>
+                    <option name="pattern" value="true" />
+                    <option name="path" value="resources/**/adapters.yaml" />
+                    <option name="mappingKind" value="Pattern" />
+                  </Item>
+                </list>
+              </option>
+            </SchemaInfo>
+          </value>
+        </entry>
+        <entry key="root_index.schema">
+          <value>
+            <SchemaInfo>
+              <option name="name" value="root_index.schema" />
+              <option name="relativePathToSchema" value="scripts/schemas/root_index.schema.json" />
+              <option name="patterns">
+                <list>
+                  <Item>
+                    <option name="path" value="/index/root_index.yaml" />
+                  </Item>
+                </list>
+              </option>
+            </SchemaInfo>
+          </value>
+        </entry>
+      </map>
+    </state>
+  </component>
+</project>

+ 5 - 0
.vscode/extensions.json

@@ -0,0 +1,5 @@
+{
+  "recommendations": [
+    "redhat.vscode-yaml" 
+  ]
+}

+ 8 - 0
.vscode/settings.json

@@ -0,0 +1,8 @@
+{
+  "yaml.schemas": {
+    "scripts/schemas/root_index.schema.json": "index/root_index.yaml",
+    "scripts/schemas/adapters.schema.json": "resources/**/adapters.yaml"
+  },
+  "yaml.format.enable": true,
+  "yaml.validate": true
+}

+ 27 - 0
scripts/schemas/adapters.schema.json

@@ -0,0 +1,27 @@
+{
+  "$schema": "http://json-schema.org/draft-07/schema#",
+  "type": "object",
+  "required": ["adapters"],
+  "properties": {
+    "adapters": {
+      "type": "array",
+      "items": {
+        "type": "object",
+        "required": ["adapter_id", "adapter_name", "category", "asset_js_path", "maintainer", "description"],
+        "properties": {
+          "adapter_id": { "type": "string", "description": "唯一标识,建议格式:学校ID_序号" },
+          "adapter_name": { "type": "string", "description": "适配器中文名称" },
+          "category": {
+            "type": "string",
+            "enum": ["BACHELOR_AND_ASSOCIATE", "POSTGRADUATE", "GENERAL_TOOL"],
+            "description": "分类:本科/专科、研究生、通用工具"
+          },
+          "asset_js_path": { "type": "string", "description": "适配脚本相对路径(如 school.js)" },
+          "import_url": { "type": "string", "description": "系统登录URL(教务系统必填)" },
+          "maintainer": { "type": "string", "description": "维护者 GitHub 用户名或姓名" },
+          "description": { "type": "string", "description": "简要说明" }
+        }
+      }
+    }
+  }
+}

+ 20 - 0
scripts/schemas/root_index.schema.json

@@ -0,0 +1,20 @@
+{
+  "$schema": "http://json-schema.org/draft-07/schema#",
+  "type": "object",
+  "required": ["schools"],
+  "properties": {
+    "schools": {
+      "type": "array",
+      "items": {
+        "type": "object",
+        "required": ["id", "name", "initial", "resource_folder"],
+        "properties": {
+          "id": { "type": "string", "description": "唯一标识,学校保持全大写,建议使用唯一域名" },
+          "name": { "type": "string", "description": "学校或工具的中文全称" },
+          "initial": { "type": "string", "pattern": "^[A-Z]$", "description": "名称首字母(大写),用于排序" },
+          "resource_folder": { "type": "string", "description": "资源文件夹名称,建议与id一致" }
+        }
+      }
+    }
+  }
+}