From 27d9b977332aadfe9f0de1c1667c560596e400d6 Mon Sep 17 00:00:00 2001 From: ly525 Date: Mon, 3 May 2021 17:40:34 +0800 Subject: [PATCH 1/2] feat(field): add code field with vue-codemirror --- examples/crm-admin-pro | 1 + package.json | 1 + src/fields/code/__config__/ams.config.js | 13 ++++++ src/fields/code/__config__/default.example.js | 1 + src/fields/code/code.vue | 41 +++++++++++++++++++ src/fields/code/index.js | 9 ++++ 6 files changed, 66 insertions(+) create mode 160000 examples/crm-admin-pro create mode 100644 src/fields/code/__config__/ams.config.js create mode 100644 src/fields/code/__config__/default.example.js create mode 100644 src/fields/code/code.vue create mode 100644 src/fields/code/index.js diff --git a/examples/crm-admin-pro b/examples/crm-admin-pro new file mode 160000 index 00000000..e2f0d05f --- /dev/null +++ b/examples/crm-admin-pro @@ -0,0 +1 @@ +Subproject commit e2f0d05f6d9475b412b0ead7f10aa5c3a012b1a3 diff --git a/package.json b/package.json index c66ae846..50af2981 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "element-ui": "^2.12.0", "normalize.css": "^8.0.1", "vue": "^2.6.10", + "vue-codemirror": "^4.0.6", "vue-router": "^3.0.6" }, "devDependencies": { diff --git a/src/fields/code/__config__/ams.config.js b/src/fields/code/__config__/ams.config.js new file mode 100644 index 00000000..05d0b196 --- /dev/null +++ b/src/fields/code/__config__/ams.config.js @@ -0,0 +1,13 @@ +export const config = { + BASE: 'CONFIG_FIELD', + type: { + default: 'code' + }, + default: { + type: 'code', + valueType: 'js', + default: '' + } +}; + +export const defaults = {}; diff --git a/src/fields/code/__config__/default.example.js b/src/fields/code/__config__/default.example.js new file mode 100644 index 00000000..ff8b4c56 --- /dev/null +++ b/src/fields/code/__config__/default.example.js @@ -0,0 +1 @@ +export default {}; diff --git a/src/fields/code/code.vue b/src/fields/code/code.vue new file mode 100644 index 00000000..8565a758 --- /dev/null +++ b/src/fields/code/code.vue @@ -0,0 +1,41 @@ + + + + \ No newline at end of file diff --git a/src/fields/code/index.js b/src/fields/code/index.js new file mode 100644 index 00000000..fbd355da --- /dev/null +++ b/src/fields/code/index.js @@ -0,0 +1,9 @@ +import code from './code'; + +export default { + type: 'code', + install(Vue) { + Vue.component(`ams-field-${this.type}-view`, code); + Vue.component(`ams-field-${this.type}-edit`, code); + } +}; From c5bc69c44c3845d09d706937788175231b49847b Mon Sep 17 00:00:00 2001 From: ly525 Date: Mon, 3 May 2021 21:01:34 +0800 Subject: [PATCH 2/2] chore: add code to ams entry --- src/index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/index.js b/src/index.js index 544e4e5f..3f19b93e 100644 --- a/src/index.js +++ b/src/index.js @@ -66,6 +66,7 @@ import tree from './fields/tree'; import link from './fields/link'; import fbutton from './fields/button'; import html from './fields/html'; +import code from './fields/code'; // operation import button from './operations/button'; @@ -157,6 +158,7 @@ ams.install = function(Vue) { ams.registerField(link); ams.registerField(fbutton); ams.registerField(html); + ams.registerField(code); // operations ams.registerOperation(button); ams.registerOperation(operationsText);