m8-mcp-server 1.0.4 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +184 -14
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +1 -1
- package/dist/docs/apis.d.ts +1 -1
- package/dist/docs/apis.js +1 -1
- package/dist/docs/components.d.ts +1 -1
- package/dist/docs/components.js +1 -1
- package/dist/docs/index.d.ts +1 -1
- package/dist/docs/index.js +1 -1
- package/dist/docs/loader.d.ts +1 -1
- package/dist/docs/loader.js +1 -1
- package/dist/docs/search.d.ts +1 -1
- package/dist/docs/search.js +1 -1
- package/dist/docs/standards.d.ts +1 -1
- package/dist/docs/standards.js +1 -1
- package/dist/docs/utils.d.ts +1 -1
- package/dist/docs/utils.js +1 -1
- package/dist/generator/header.d.ts +1 -1
- package/dist/generator/header.js +1 -1
- package/dist/generator/index.d.ts +1 -1
- package/dist/generator/index.js +1 -1
- package/dist/generator/vue-template.d.ts +22 -1
- package/dist/generator/vue-template.d.ts.map +1 -1
- package/dist/generator/vue-template.js +498 -34
- package/dist/generator/vue-template.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/recommend/index.d.ts +1 -1
- package/dist/recommend/index.js +1 -1
- package/dist/tools/generate-code.d.ts +1 -1
- package/dist/tools/generate-code.js +1 -1
- package/dist/tools/get-api-info.d.ts +1 -1
- package/dist/tools/get-api-info.js +1 -1
- package/dist/tools/get-coding-standard.d.ts +1 -1
- package/dist/tools/get-coding-standard.js +1 -1
- package/dist/tools/get-component-info.d.ts +1 -1
- package/dist/tools/get-component-info.js +1 -1
- package/dist/tools/get-util-info.d.ts +1 -1
- package/dist/tools/get-util-info.js +1 -1
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/index.js +1 -1
- package/dist/tools/recommend-solution.d.ts +1 -1
- package/dist/tools/recommend-solution.js +1 -1
- package/dist/tools/search-docs.d.ts +1 -1
- package/dist/tools/search-docs.js +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.js +1 -1
- package/package.json +4 -4
- package/resources/cases/.gitkeep +0 -0
- package/resources/cases/form-submit-vue2.json +0 -15
- package/resources/cases/index.json +0 -8
- package/resources/cases/list-detail-vue2.json +0 -27
- package/resources/components/.gitkeep +0 -0
- package/resources/components/button.json +0 -74
- package/resources/components/cell.json +0 -69
- package/resources/components/field.json +0 -88
- package/resources/components/index.json +0 -72
- package/resources/standards/.gitkeep +0 -0
- package/resources/standards/css.json +0 -108
- package/resources/standards/javascript.json +0 -129
- package/resources/standards/project-structure.json +0 -101
- package/resources/standards/vue.json +0 -122
- package/resources/utils/.gitkeep +0 -0
- package/resources/utils/ajax.json +0 -76
- package/resources/utils/common.json +0 -129
- package/resources/utils/index.json +0 -7
- package/resources/utils/string.json +0 -112
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"id": "vue-style",
|
|
3
|
-
"category": "vue",
|
|
4
|
-
"title": "Vue 组件编码规范",
|
|
5
|
-
"version": "1.2.0",
|
|
6
|
-
"lastUpdated": "2024-12-22",
|
|
7
|
-
"description": "M8 框架 Vue 组件的编码标准,适用于 M8.3 (Vue2) 和 M8.4 (Vue3) 项目",
|
|
8
|
-
"rules": [
|
|
9
|
-
{
|
|
10
|
-
"id": "vue-file-header",
|
|
11
|
-
"title": ".vue 文件必须包含头部注释",
|
|
12
|
-
"description": "每个 .vue 文件必须在顶部添加标准化的注释块,包含作者、时间、版本、版权和描述信息。",
|
|
13
|
-
"correctExample": "<!--\n * @作者: 张三\n * @创建时间: 2024-11-11 14:20:03\n * @修改时间: 2024-11-11 14:20:03\n * @版本: [1.0]\n * @版权: 国泰新点软件股份有限公司\n * @描述: 用户信息展示组件\n-->\n<template>\n <!-- 组件内容 -->\n</template>",
|
|
14
|
-
"incorrectExample": "<template>\n <!-- 缺少头部注释 -->\n</template>"
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
"id": "vue-component-naming",
|
|
18
|
-
"title": "组件文件命名使用 PascalCase",
|
|
19
|
-
"description": "组件文件名应使用 PascalCase 命名法。",
|
|
20
|
-
"correctExample": "UserProfile.vue\nTodoList.vue\nSearchInput.vue",
|
|
21
|
-
"incorrectExample": "userProfile.vue\nuser-profile.vue\ntodolist.vue"
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
"id": "vue-base-component-prefix",
|
|
25
|
-
"title": "基础组件使用特定前缀",
|
|
26
|
-
"description": "应用特定样式和约定的基础组件应该全部以一个特定的前缀开头,比如 Base、App 或 Ne。",
|
|
27
|
-
"correctExample": "BaseButton.vue\nBaseTable.vue\nNeInput.vue",
|
|
28
|
-
"incorrectExample": "MyButton.vue\nVueTable.vue"
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
"id": "vue-props-type",
|
|
32
|
-
"title": "Props 必须指定类型",
|
|
33
|
-
"description": "Props 定义应该尽量详细,至少需要指定其类型。",
|
|
34
|
-
"correctExample": "// Vue2\nexport default {\n props: {\n status: {\n type: String,\n required: true\n },\n count: {\n type: Number,\n default: 0\n }\n }\n}\n\n// Vue3\nconst props = defineProps<{\n status: 'success' | 'warning' | 'error';\n count?: number;\n}>();",
|
|
35
|
-
"incorrectExample": "props: ['status', 'count']"
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
"id": "vue-props-camelcase",
|
|
39
|
-
"title": "Props 命名使用 camelCase",
|
|
40
|
-
"description": "在声明 props 时,其命名应该始终使用 camelCase。",
|
|
41
|
-
"correctExample": "props: {\n greetingText: String\n}",
|
|
42
|
-
"incorrectExample": "props: {\n 'greeting-text': String\n}"
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
"id": "vue-event-kebabcase",
|
|
46
|
-
"title": "事件名使用 kebab-case",
|
|
47
|
-
"description": "事件名应该使用 kebab-case 命名。",
|
|
48
|
-
"correctExample": "this.$emit('item-click', item);\nemit('update-value', newValue);",
|
|
49
|
-
"incorrectExample": "this.$emit('itemClick', item);\nemit('updateValue', newValue);"
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
"id": "vue-self-closing",
|
|
53
|
-
"title": "组件标签自闭合",
|
|
54
|
-
"description": "没有内容的组件应该自闭合。",
|
|
55
|
-
"correctExample": "<MyComponent />\n<ne-button type=\"primary\" />",
|
|
56
|
-
"incorrectExample": "<MyComponent></MyComponent>\n<ne-button type=\"primary\"></ne-button>"
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
"id": "vue-multi-attribute",
|
|
60
|
-
"title": "多属性换行",
|
|
61
|
-
"description": "当组件有多个属性时,应该每个属性占一行。",
|
|
62
|
-
"correctExample": "<ne-field\n v-model=\"formData.name\"\n label=\"姓名\"\n placeholder=\"请输入姓名\"\n required\n :rules=\"nameRules\"\n/>",
|
|
63
|
-
"incorrectExample": "<ne-field v-model=\"formData.name\" label=\"姓名\" placeholder=\"请输入姓名\" required :rules=\"nameRules\" />"
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
"id": "vue-script-setup",
|
|
67
|
-
"title": "使用 script setup (Vue3)",
|
|
68
|
-
"description": "Vue3 项目推荐使用 <script setup> 语法。",
|
|
69
|
-
"correctExample": "<script setup>\nimport { ref, computed } from 'vue';\n\nconst count = ref(0);\nconst double = computed(() => count.value * 2);\n</script>",
|
|
70
|
-
"incorrectExample": "<script>\nimport { ref, computed, defineComponent } from 'vue';\n\nexport default defineComponent({\n setup() {\n const count = ref(0);\n return { count };\n }\n});\n</script>"
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
"id": "vue-code-order",
|
|
74
|
-
"title": "响应式数据声明顺序",
|
|
75
|
-
"description": "按照以下顺序组织代码:props/emits → refs → computed → watch → 生命周期 → methods",
|
|
76
|
-
"correctExample": "<script setup>\n// 1. Props 和 Emits\nconst props = defineProps<{ title: string }>();\nconst emit = defineEmits<{ (e: 'update', value: string): void }>();\n\n// 2. 响应式数据\nconst count = ref(0);\n\n// 3. 计算属性\nconst total = computed(() => count.value);\n\n// 4. 侦听器\nwatch(count, (newVal) => { });\n\n// 5. 生命周期\nonMounted(() => { });\n\n// 6. 方法\nfunction loadData() { }\n</script>",
|
|
77
|
-
"incorrectExample": "// 代码顺序混乱"
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
"id": "vue-style-external",
|
|
81
|
-
"title": "样式必须剥离到外部文件",
|
|
82
|
-
"description": "Vue 组件的样式必须剥离到独立的 SCSS 文件中,通过 @import 方式引入。",
|
|
83
|
-
"correctExample": "<style lang=\"scss\" scoped>\n@import './css/login.scss';\n</style>",
|
|
84
|
-
"incorrectExample": "<style lang=\"scss\" scoped>\n.login_page {\n // 大量样式代码直接写在 .vue 文件中\n}\n</style>"
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
"id": "vue-style-scoped",
|
|
88
|
-
"title": "style 标签必须使用 scoped",
|
|
89
|
-
"description": "为避免样式污染,<style> 标签必须添加 scoped 属性。",
|
|
90
|
-
"correctExample": "<style lang=\"scss\" scoped>\n@import './css/user-profile.scss';\n</style>",
|
|
91
|
-
"incorrectExample": "<style lang=\"scss\">\n@import './css/user-profile.scss';\n</style>"
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
"id": "vue-no-header-refactor",
|
|
95
|
-
"title": "重构页面时不添加导航栏",
|
|
96
|
-
"description": "重构现有页面时,不需要添加 em-header 或 nav-bar 导航栏组件。导航栏由框架或原生容器统一管理。",
|
|
97
|
-
"correctExample": "<template>\n <div class=\"page-container\">\n <div class=\"content\">\n <em-cell title=\"用户信息\" />\n </div>\n </div>\n</template>",
|
|
98
|
-
"incorrectExample": "<template>\n <div class=\"page-container\">\n <em-header title=\"页面标题\" />\n <div class=\"content\">\n <em-cell title=\"用户信息\" />\n </div>\n </div>\n</template>"
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
"id": "vue-no-complex-template",
|
|
102
|
-
"title": "避免在模板中使用复杂表达式",
|
|
103
|
-
"description": "复杂的逻辑应该使用计算属性,而不是直接写在模板中。",
|
|
104
|
-
"correctExample": "<template>\n <div>{{ activeItemNames }}</div>\n</template>\n\n<script setup>\nconst activeItemNames = computed(() =>\n items.value.filter(i => i.active).map(i => i.name).join(', ')\n);\n</script>",
|
|
105
|
-
"incorrectExample": "<template>\n <div>{{ items.filter(i => i.active).map(i => i.name).join(', ') }}</div>\n</template>"
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
"id": "vue-no-mutate-props",
|
|
109
|
-
"title": "避免直接修改 Props",
|
|
110
|
-
"description": "不要直接修改 props,应该使用 emit 通知父组件。",
|
|
111
|
-
"correctExample": "emit('update:value', newValue);",
|
|
112
|
-
"incorrectExample": "props.value = newValue;"
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
"id": "vue-field-clickable",
|
|
116
|
-
"title": "输入框交互规范",
|
|
117
|
-
"description": "当输入框为 readonly 但需要点击触发操作时,必须同时添加 is-link 和 clickable 属性。",
|
|
118
|
-
"correctExample": "<em-field\n v-model=\"date\"\n readonly\n clickable\n is-link\n label=\"选择日期\"\n @click=\"showDatePicker\"\n/>",
|
|
119
|
-
"incorrectExample": "<em-field\n v-model=\"date\"\n readonly\n label=\"选择日期\"\n @click=\"showDatePicker\"\n/>"
|
|
120
|
-
}
|
|
121
|
-
]
|
|
122
|
-
}
|
package/resources/utils/.gitkeep
DELETED
|
File without changes
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"category": "ajax",
|
|
3
|
-
"title": "Ajax 与文件上传",
|
|
4
|
-
"description": "核心工具集中内置的 Ajax 与 Upload,用于接口请求和文件上传",
|
|
5
|
-
"methods": [
|
|
6
|
-
{
|
|
7
|
-
"name": "ajax",
|
|
8
|
-
"description": "进行 ajax 请求,支持普通版本和 Promise 版本",
|
|
9
|
-
"parameters": [
|
|
10
|
-
{ "name": "url", "type": "String", "required": true, "description": "请求的 url" },
|
|
11
|
-
{ "name": "data", "type": "String/JSON", "required": true, "description": "请求的数据" },
|
|
12
|
-
{ "name": "type", "type": "String", "required": false, "description": "请求类别,GET 或 POST,默认为 POST" },
|
|
13
|
-
{ "name": "isAutoProxy", "type": "Boolean", "required": false, "description": "默认为 true,是否在请求头中携带用户 token" },
|
|
14
|
-
{ "name": "isAutoErrToast", "type": "Boolean", "required": false, "description": "默认为 false,是否开启错误状态码自动弹窗提示" },
|
|
15
|
-
{ "name": "success", "type": "Function", "required": false, "description": "成功回调" },
|
|
16
|
-
{ "name": "error", "type": "Function", "required": false, "description": "失败回调" },
|
|
17
|
-
{ "name": "complete", "type": "Function", "required": false, "description": "请求完成后的回调" },
|
|
18
|
-
{ "name": "dataPath", "type": "String/Array", "required": false, "description": "需要获取的路径指令,例如 custom.infolist" },
|
|
19
|
-
{ "name": "headers", "type": "Object", "required": false, "description": "设置请求的 header" },
|
|
20
|
-
{ "name": "timeout", "type": "Number", "required": false, "description": "请求超时的毫秒数" },
|
|
21
|
-
{ "name": "cancelKey", "type": "String", "required": false, "description": "中断请求的自定义 key 值" }
|
|
22
|
-
],
|
|
23
|
-
"returnValue": { "type": "Promise", "description": "返回 Promise 对象,支持链式调用" },
|
|
24
|
-
"examples": [
|
|
25
|
-
{
|
|
26
|
-
"title": "Promise 版本",
|
|
27
|
-
"code": "Util.ajax({\n url: Config.serverUrl + '/api/list',\n type: 'POST',\n data: {\n params: JSON.stringify({ keyword: 'test' })\n },\n dataPath: 'custom.infolist'\n}).then((res) => {\n if (res.code === 1) {\n console.log(res.data);\n }\n}).catch((err) => {\n console.error(err);\n});",
|
|
28
|
-
"description": "使用 Promise 方式进行 ajax 请求"
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
"title": "回调版本",
|
|
32
|
-
"code": "Util.ajax({\n url: Config.serverUrl + '/api/detail',\n data: {\n params: JSON.stringify({ guid: '12345' })\n },\n dataPath: 'custom',\n success: (result) => {\n if (result.code === 1) {\n // 处理数据\n }\n },\n error: (err) => {\n console.error(err);\n }\n});",
|
|
33
|
-
"description": "使用回调方式进行 ajax 请求"
|
|
34
|
-
}
|
|
35
|
-
]
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
"name": "ajaxAll",
|
|
39
|
-
"description": "控制多个 Ajax 请求并发执行",
|
|
40
|
-
"parameters": [
|
|
41
|
-
{ "name": "...requests", "type": "Promise[]", "required": true, "description": "多个 ajax 请求的 Promise 对象" }
|
|
42
|
-
],
|
|
43
|
-
"returnValue": { "type": "Promise<Array>", "description": "返回所有请求结果的数组" },
|
|
44
|
-
"examples": [
|
|
45
|
-
{
|
|
46
|
-
"title": "并发请求",
|
|
47
|
-
"code": "const ajax1 = Util.ajax({ url: Config.serverUrl + '/api/users' });\nconst ajax2 = Util.ajax({ url: Config.serverUrl + '/api/products' });\n\nUtil.ajaxAll(ajax1, ajax2).then((response) => {\n const users = response[0];\n const products = response[1];\n});",
|
|
48
|
-
"description": "同时发起多个请求并等待所有请求完成"
|
|
49
|
-
}
|
|
50
|
-
]
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
"name": "upload",
|
|
54
|
-
"description": "将本地资源上传到开发者服务器",
|
|
55
|
-
"parameters": [
|
|
56
|
-
{ "name": "url", "type": "String", "required": true, "description": "开发者服务器 url" },
|
|
57
|
-
{ "name": "filePath", "type": "String", "required": true, "description": "要上传文件资源的路径(推荐使用)" },
|
|
58
|
-
{ "name": "name", "type": "String", "required": true, "description": "文件对应的 key" },
|
|
59
|
-
{ "name": "files", "type": "Array", "required": false, "description": "需要上传的文件列表(仅 H5 支持)" },
|
|
60
|
-
{ "name": "headers", "type": "Object", "required": false, "description": "设置请求的 header" },
|
|
61
|
-
{ "name": "formData", "type": "Object", "required": false, "description": "HTTP 请求中其他额外的 form data" },
|
|
62
|
-
{ "name": "success", "type": "Function", "required": false, "description": "接口调用成功的回调函数" },
|
|
63
|
-
{ "name": "error", "type": "Function", "required": false, "description": "接口调用失败的回调函数" },
|
|
64
|
-
{ "name": "uploading", "type": "Function", "required": false, "description": "文件上传时,进度回调" }
|
|
65
|
-
],
|
|
66
|
-
"returnValue": { "type": "Promise", "description": "返回 Promise 对象" },
|
|
67
|
-
"examples": [
|
|
68
|
-
{
|
|
69
|
-
"title": "文件上传",
|
|
70
|
-
"code": "Util.upload({\n url: Config.serverUrl + '/api/upload',\n filePath: file.path,\n name: file.name,\n formData: {\n user: 'test'\n },\n success: (res) => {\n console.log(res);\n }\n});",
|
|
71
|
-
"description": "上传文件到服务器"
|
|
72
|
-
}
|
|
73
|
-
]
|
|
74
|
-
}
|
|
75
|
-
]
|
|
76
|
-
}
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"category": "common",
|
|
3
|
-
"title": "通用工具方法",
|
|
4
|
-
"description": "Util 提供的通用工具方法,包括 uuid 生成、对象合并、数据处理等",
|
|
5
|
-
"methods": [
|
|
6
|
-
{
|
|
7
|
-
"name": "uuid",
|
|
8
|
-
"description": "生成一个随机 uuid",
|
|
9
|
-
"parameters": [
|
|
10
|
-
{ "name": "len", "type": "Number", "required": false, "description": "长度,默认为 32 位,最大不能超过 36,最小不能小于 4" },
|
|
11
|
-
{ "name": "radix", "type": "Number", "required": false, "description": "随机的基数,如果小于等于 10 代表只用纯数字,最大为 62,默认为 62" },
|
|
12
|
-
{ "name": "type", "type": "String", "required": false, "description": "类别,默认为 default 代表 a-c-c-d-e 的连线模式,如果为 noline 代表不会有连线" }
|
|
13
|
-
],
|
|
14
|
-
"returnValue": { "type": "String", "description": "生成的 uuid 字符串" },
|
|
15
|
-
"examples": [
|
|
16
|
-
{
|
|
17
|
-
"title": "生成默认 uuid",
|
|
18
|
-
"code": "const uuid = Util.uuid();\n// 例如: yczYoFSp-ooru-ANjl-Hrgg-XgXmMxSN",
|
|
19
|
-
"description": "生成一个 8-4-4-4-12 格式的 32 位 uuid"
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
"title": "生成纯数字 uuid",
|
|
23
|
-
"code": "const uuid = Util.uuid({ len: 36, radix: 10 });\n// 例如: 52616056-5161-7170-8460-802618729824",
|
|
24
|
-
"description": "生成一个只有数字的 36 位 uuid"
|
|
25
|
-
}
|
|
26
|
-
]
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
"name": "getExtraDataByKey",
|
|
30
|
-
"description": "通过传入 key 值,得到页面 key 的初始化传值",
|
|
31
|
-
"parameters": [
|
|
32
|
-
{ "name": "key", "type": "String", "required": true, "description": "对应的 key 值" }
|
|
33
|
-
],
|
|
34
|
-
"returnValue": { "type": "String", "description": "返回 href 中对应的 key 的 value" },
|
|
35
|
-
"examples": [
|
|
36
|
-
{
|
|
37
|
-
"title": "获取页面参数",
|
|
38
|
-
"code": "const value = Util.getExtraDataByKey('id');\nconsole.log(value);",
|
|
39
|
-
"description": "获取 URL 中的参数值"
|
|
40
|
-
}
|
|
41
|
-
]
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
"name": "getFullUrlByParams",
|
|
45
|
-
"description": "将 json 参数拼接到 url 中",
|
|
46
|
-
"parameters": [
|
|
47
|
-
{ "name": "url", "type": "String", "required": true, "description": "需要拼接的 url" },
|
|
48
|
-
{ "name": "data", "type": "JSON", "required": true, "description": "对应需要拼接的 JSON 参数" },
|
|
49
|
-
{ "name": "isType", "type": "Boolean", "required": false, "description": "是否相对路径,默认 false" }
|
|
50
|
-
],
|
|
51
|
-
"returnValue": { "type": "String", "description": "拼接后的完整 URL" },
|
|
52
|
-
"examples": [
|
|
53
|
-
{
|
|
54
|
-
"title": "拼接 URL 参数",
|
|
55
|
-
"code": "const url = 'http://app.epoint.com.cn/api';\nconst data = { key1: 'value1' };\nconst finalUrl = Util.getFullUrlByParams(url, data);\n// 返回: http://app.epoint.com.cn/api?key1=value1",
|
|
56
|
-
"description": "将 JSON 参数拼接到 URL 中"
|
|
57
|
-
}
|
|
58
|
-
]
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
"name": "extend",
|
|
62
|
-
"description": "合并多个对象",
|
|
63
|
-
"parameters": [
|
|
64
|
-
{ "name": "deep", "type": "Boolean", "required": false, "description": "为 true 时会进行递归合并" },
|
|
65
|
-
{ "name": "target", "type": "Object", "required": true, "description": "需要合并的目标对象" },
|
|
66
|
-
{ "name": "source1", "type": "Object", "required": true, "description": "需要合并的源对象" },
|
|
67
|
-
{ "name": "sourceN", "type": "Object", "required": false, "description": "更多需要合并的源对象" }
|
|
68
|
-
],
|
|
69
|
-
"returnValue": { "type": "Object", "description": "合并后的对象" },
|
|
70
|
-
"examples": [
|
|
71
|
-
{
|
|
72
|
-
"title": "浅合并",
|
|
73
|
-
"code": "const target = { a: 1 };\nconst source = { b: 2 };\nconst result = Util.extend({}, target, source);\n// { a: 1, b: 2 }",
|
|
74
|
-
"description": "浅合并多个对象"
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
"title": "深合并",
|
|
78
|
-
"code": "const target = { product: { ejs: 'ejs' } };\nconst source = { product: { m7: 'm7' } };\nconst result = Util.extend(true, {}, target, source);\n// { product: { ejs: 'ejs', m7: 'm7' } }",
|
|
79
|
-
"description": "递归合并多个对象"
|
|
80
|
-
}
|
|
81
|
-
]
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
"name": "each",
|
|
85
|
-
"description": "遍历对象或数组",
|
|
86
|
-
"parameters": [
|
|
87
|
-
{ "name": "object", "type": "Object/Array", "required": true, "description": "需要遍历的对象或数组" },
|
|
88
|
-
{ "name": "handler", "type": "Function", "required": true, "description": "每个元素执行的回调函数" }
|
|
89
|
-
],
|
|
90
|
-
"returnValue": { "type": "void", "description": "无返回值" },
|
|
91
|
-
"examples": [
|
|
92
|
-
{
|
|
93
|
-
"title": "遍历数组",
|
|
94
|
-
"code": "const array = [1, 2, 3];\nUtil.each(array, function(index, item) {\n console.log(item * item);\n});",
|
|
95
|
-
"description": "遍历数组并处理每个元素"
|
|
96
|
-
}
|
|
97
|
-
]
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
"name": "dataProcess",
|
|
101
|
-
"description": "处理返回数据,返回按指令处理过后的最终数据",
|
|
102
|
-
"parameters": [
|
|
103
|
-
{ "name": "response", "type": "JSON", "required": true, "description": "需要处理的数据" },
|
|
104
|
-
{ "name": "options.dataPath", "type": "String/Array", "required": false, "description": "需要获取的路径指令" }
|
|
105
|
-
],
|
|
106
|
-
"returnValue": { "type": "Object", "description": "包含 code、message、data 的处理结果" },
|
|
107
|
-
"examples": [
|
|
108
|
-
{
|
|
109
|
-
"title": "处理接口返回数据",
|
|
110
|
-
"code": "const response = {\n custom: { infolist: [{ title: '测试' }] },\n status: { code: 1, text: '成功' }\n};\nconst result = Util.dataProcess(response, {\n dataPath: 'custom.infolist'\n});\nconsole.log(result.data);",
|
|
111
|
-
"description": "从接口返回数据中提取指定路径的数据"
|
|
112
|
-
}
|
|
113
|
-
]
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
"name": "os",
|
|
117
|
-
"description": "判断当前的运行环境",
|
|
118
|
-
"parameters": [],
|
|
119
|
-
"returnValue": { "type": "Object", "description": "包含 android、ios、ejs、h5、wechat 等环境判断属性" },
|
|
120
|
-
"examples": [
|
|
121
|
-
{
|
|
122
|
-
"title": "判断运行环境",
|
|
123
|
-
"code": "if (Util.os.android) {\n console.log('Android 环境');\n}\nif (Util.os.ios) {\n console.log('iOS 环境');\n}\nif (Util.os.h5) {\n console.log('H5 环境');\n}",
|
|
124
|
-
"description": "判断当前代码运行的平台环境"
|
|
125
|
-
}
|
|
126
|
-
]
|
|
127
|
-
}
|
|
128
|
-
]
|
|
129
|
-
}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"category": "string",
|
|
3
|
-
"title": "字符串校验工具",
|
|
4
|
-
"description": "Util.string 提供的字符串校验方法,用于验证手机号、邮箱、身份证等",
|
|
5
|
-
"methods": [
|
|
6
|
-
{
|
|
7
|
-
"name": "isMobile",
|
|
8
|
-
"description": "验证是否为手机号",
|
|
9
|
-
"parameters": [
|
|
10
|
-
{ "name": "str", "type": "String", "required": true, "description": "需要验证的字符串" }
|
|
11
|
-
],
|
|
12
|
-
"returnValue": { "type": "Boolean", "description": "是否为有效手机号" },
|
|
13
|
-
"examples": [
|
|
14
|
-
{
|
|
15
|
-
"title": "验证手机号",
|
|
16
|
-
"code": "const isValid = Util.string.isMobile('13800138000');\nconsole.log(isValid); // true",
|
|
17
|
-
"description": "验证字符串是否为有效的手机号"
|
|
18
|
-
}
|
|
19
|
-
]
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
"name": "isTel",
|
|
23
|
-
"description": "验证是否为固定电话",
|
|
24
|
-
"parameters": [
|
|
25
|
-
{ "name": "str", "type": "String", "required": true, "description": "需要验证的字符串" }
|
|
26
|
-
],
|
|
27
|
-
"returnValue": { "type": "Boolean", "description": "是否为有效固定电话" },
|
|
28
|
-
"examples": [
|
|
29
|
-
{
|
|
30
|
-
"title": "验证固定电话",
|
|
31
|
-
"code": "const isValid = Util.string.isTel('0512-12345678');\nconsole.log(isValid); // true",
|
|
32
|
-
"description": "验证字符串是否为有效的固定电话"
|
|
33
|
-
}
|
|
34
|
-
]
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
"name": "isPhone",
|
|
38
|
-
"description": "验证是否为电话(手机或固话)",
|
|
39
|
-
"parameters": [
|
|
40
|
-
{ "name": "str", "type": "String", "required": true, "description": "需要验证的字符串" }
|
|
41
|
-
],
|
|
42
|
-
"returnValue": { "type": "Boolean", "description": "是否为有效电话" },
|
|
43
|
-
"examples": [
|
|
44
|
-
{
|
|
45
|
-
"title": "验证电话",
|
|
46
|
-
"code": "const isValid = Util.string.isPhone('13800138000');\nconsole.log(isValid); // true",
|
|
47
|
-
"description": "验证字符串是否为有效的电话号码"
|
|
48
|
-
}
|
|
49
|
-
]
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
"name": "isEmail",
|
|
53
|
-
"description": "验证是否为邮箱",
|
|
54
|
-
"parameters": [
|
|
55
|
-
{ "name": "str", "type": "String", "required": true, "description": "需要验证的字符串" }
|
|
56
|
-
],
|
|
57
|
-
"returnValue": { "type": "Boolean", "description": "是否为有效邮箱" },
|
|
58
|
-
"examples": [
|
|
59
|
-
{
|
|
60
|
-
"title": "验证邮箱",
|
|
61
|
-
"code": "const isValid = Util.string.isEmail('test@example.com');\nconsole.log(isValid); // true",
|
|
62
|
-
"description": "验证字符串是否为有效的邮箱地址"
|
|
63
|
-
}
|
|
64
|
-
]
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
"name": "isIdCard",
|
|
68
|
-
"description": "验证是否为身份证号",
|
|
69
|
-
"parameters": [
|
|
70
|
-
{ "name": "str", "type": "String", "required": true, "description": "需要验证的字符串" }
|
|
71
|
-
],
|
|
72
|
-
"returnValue": { "type": "Boolean", "description": "是否为有效身份证号" },
|
|
73
|
-
"examples": [
|
|
74
|
-
{
|
|
75
|
-
"title": "验证身份证",
|
|
76
|
-
"code": "const isValid = Util.string.isIdCard('110101199001011234');\nconsole.log(isValid); // true",
|
|
77
|
-
"description": "验证字符串是否为有效的身份证号"
|
|
78
|
-
}
|
|
79
|
-
]
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
"name": "isPostCode",
|
|
83
|
-
"description": "验证是否为邮政编码",
|
|
84
|
-
"parameters": [
|
|
85
|
-
{ "name": "str", "type": "String", "required": true, "description": "需要验证的字符串" }
|
|
86
|
-
],
|
|
87
|
-
"returnValue": { "type": "Boolean", "description": "是否为有效邮政编码" },
|
|
88
|
-
"examples": [
|
|
89
|
-
{
|
|
90
|
-
"title": "验证邮政编码",
|
|
91
|
-
"code": "const isValid = Util.string.isPostCode('215000');\nconsole.log(isValid); // true",
|
|
92
|
-
"description": "验证字符串是否为有效的邮政编码"
|
|
93
|
-
}
|
|
94
|
-
]
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
"name": "isOrgCode",
|
|
98
|
-
"description": "验证是否为组织机构代码",
|
|
99
|
-
"parameters": [
|
|
100
|
-
{ "name": "str", "type": "String", "required": true, "description": "需要验证的字符串" }
|
|
101
|
-
],
|
|
102
|
-
"returnValue": { "type": "Boolean", "description": "是否为有效组织机构代码" },
|
|
103
|
-
"examples": [
|
|
104
|
-
{
|
|
105
|
-
"title": "验证组织机构代码",
|
|
106
|
-
"code": "const isValid = Util.string.isOrgCode('12345678-9');\nconsole.log(isValid);",
|
|
107
|
-
"description": "验证字符串是否为有效的组织机构代码"
|
|
108
|
-
}
|
|
109
|
-
]
|
|
110
|
-
}
|
|
111
|
-
]
|
|
112
|
-
}
|