From d465fd6b47e2ff3e0d325f12634398e329559b1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=83=9D=E5=85=88=E7=91=9E?= <1490493387@qq.com> Date: Fri, 7 Jan 2022 23:58:25 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=95=86=E5=93=81=E5=88=86=E7=B1=BB?= =?UTF-8?q?=E5=92=8C=E5=95=86=E5=93=81=E5=9F=BA=E7=A1=80=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E5=8D=87=E7=BA=A7=E6=94=B9=E9=80=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 20 +- package.json | 3 + src/components/Tinymce/Index.vue | 255 ++++++++++++++++++ .../Tinymce/components/EditorImage.vue | 152 +++++++++++ src/components/Tinymce/config.ts | 8 + .../pms/goods/components/GoodsCategory.vue | 24 +- src/views/pms/goods/components/GoodsInfo.vue | 232 ++++++++-------- 7 files changed, 574 insertions(+), 120 deletions(-) create mode 100644 src/components/Tinymce/Index.vue create mode 100644 src/components/Tinymce/components/EditorImage.vue create mode 100644 src/components/Tinymce/config.ts diff --git a/README.md b/README.md index 82e1b09f..56a67335 100644 --- a/README.md +++ b/README.md @@ -503,7 +503,7 @@ vite-plugin-svg-icons 使用说明:https://github.com/anncwb/vite-plugin-svg-i **安装** ``` -npm i vite-plugin-svg-icons -D +npm i -D vite-plugin-svg-icons ``` @@ -550,4 +550,20 @@ router.afterEach(() => { NProgress.done() }) -``` \ No newline at end of file +``` + +## TinyMCE 富文本编辑器 + +**官网:** http://tinymce.ax-z.cn/integrations/integrate-index.php + +**安装** + +``` +npm i -S tinymce + +npm i -S @tinymce/tinymce-vue + +npm i -D @types/tinymce +``` + + diff --git a/package.json b/package.json index 1c803cbf..bd620750 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ }, "dependencies": { "@element-plus/icons": "0.0.11", + "@tinymce/tinymce-vue": "^4.0.5", "axios": "^0.24.0", "element-plus": "^1.2.0-beta.6", "nprogress": "^0.2.0", @@ -15,6 +16,7 @@ "path-to-regexp": "^6.2.0", "pinia": "^2.0.9", "screenfull": "^6.0.0", + "tinymce": "^5.10.2", "vue": "^3.2.16", "vue-router": "^4.0.12" }, @@ -22,6 +24,7 @@ "@types/node": "^16.11.7", "@types/nprogress": "^0.2.0", "@types/path-browserify": "^1.0.0", + "@types/tinymce": "^4.6.4", "@vitejs/plugin-vue": "^1.9.3", "sass": "^1.43.4", "typescript": "^4.4.3", diff --git a/src/components/Tinymce/Index.vue b/src/components/Tinymce/Index.vue new file mode 100644 index 00000000..4ec6849e --- /dev/null +++ b/src/components/Tinymce/Index.vue @@ -0,0 +1,255 @@ + + + + + diff --git a/src/components/Tinymce/components/EditorImage.vue b/src/components/Tinymce/components/EditorImage.vue new file mode 100644 index 00000000..b20a4f30 --- /dev/null +++ b/src/components/Tinymce/components/EditorImage.vue @@ -0,0 +1,152 @@ + + + + + + + diff --git a/src/components/Tinymce/config.ts b/src/components/Tinymce/config.ts new file mode 100644 index 00000000..937d7511 --- /dev/null +++ b/src/components/Tinymce/config.ts @@ -0,0 +1,8 @@ +// Import plugins that you want to use +// Detail plugins list see: https://www.tiny.cloud/apps/#core-plugins +// Custom builds see: https://www.tiny.cloud/get-tiny/custom-builds/ +export const plugins = ['advlist anchor autolink autoresize autosave charmap code codesample directionality emoticons fullpage fullscreen help hr image imagetools insertdatetime link lists media nonbreaking noneditable pagebreak paste preview print save searchreplace spellchecker tabfocus table template textpattern visualblocks visualchars wordcount'] + +// Here is the list of toolbar control components +// Details see: https://www.tinymce.com/docs/advanced/editor-control-identifiers/#toolbarcontrols +export const toolbar = ['searchreplace bold italic underline strikethrough alignleft aligncenter alignright outdent indent blockquote undo redo removeformat subscript superscript code codesample help', 'hr bullist numlist link image charmap preview anchor pagebreak insertdatetime media table emoticons charmap forecolor backcolor fullpage fullscreen'] diff --git a/src/views/pms/goods/components/GoodsCategory.vue b/src/views/pms/goods/components/GoodsCategory.vue index 53845286..a6a0665e 100644 --- a/src/views/pms/goods/components/GoodsCategory.vue +++ b/src/views/pms/goods/components/GoodsCategory.vue @@ -20,7 +20,7 @@ @@ -32,8 +32,10 @@ import {ElCascaderPanel, ElMessage} from "element-plus"; const emit = defineEmits(['next']) const props = defineProps({ - goodsId: Number, - categoryId: Number + modelValue: { + type: Object, + default:{ } + } }) const state = reactive({ @@ -44,15 +46,11 @@ const state = reactive({ const {categoryOptions, pathLabels, categoryId} = toRefs(state) -onMounted(() => { - loadData() -}) - function loadData() { listCascadeCategories({}).then(response => { state.categoryOptions = response.data - if (props.goodsId) { - state.categoryId = props.categoryId as any + if (props.modelValue.id) { + state.categoryId = props.modelValue.categoryId nextTick(() => { handleCategoryChange() }) @@ -67,8 +65,7 @@ function handleCategoryChange() { state.categoryId = checkNode.value } - -function onNextStepClick() { +function handleNext() { if (!state.categoryId) { ElMessage.warning('请选择商品分类') return false @@ -76,6 +73,11 @@ function onNextStepClick() { emit('next' ) } + +onMounted(() => { + loadData() +}) + --->