DTCloud结合amis编辑器上篇~内嵌版

项目目录
image.png

最终需要展示的amis编辑器的html文件

参考编辑器源码链接

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="format-detection" content="telephone=no"/> <meta name="viewport" content="initial-scale=1,user-scalable=no,width=device-width,viewport-fit=cover"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>amis-editor Demo</title> <link rel="stylesheet" href="https://bce.bdstatic.com/iconfont/iconfont.css"/> <link rel="stylesheet" href="https://unpkg.com/[email protected]/animate.min.css"/> <link data-react-helmet="true" rel="shortcut icon" href="https://avatars.githubusercontent.com/u/78204817?s=200&v=4"/> <link href="https://aisuda.github.io/amis-editor-demo/demo/css/vendor.fcbe040c.css" rel="stylesheet"><link href="https://aisuda.github.io/amis-editor-demo/demo/css/index.ed44d890.css" rel="stylesheet"></head> <body> <div id="root"></div> <script defer src="https://aisuda.github.io/amis-editor-demo/demo/scripts/chunk/vendor.41754546.js"></script><script defer src="https://aisuda.github.io/amis-editor-demo/demo/scripts/chunk/index.36c0b146.js"></script></body> </html> 

静态文件的模板-xml文件

<?xml version='1.0' encoding='UTF-8'?>
<templates id='template' xml:space='preserve'>
  <t t-name="my_dtbEditor">
    <iframe src="dtb_editor/static/src/index.html"  marginheight="0" marginwidth="0" width="100%" height="100%"></iframe>
  </t>
</templates>

静态文件的模板-js文件

dtcloud.define('my_dtbEditor', function (require) {
    
    
    'use strict';
    let core = require('web.core');
    let AbstractAction = require('web.AbstractAction');

    let my_vueDemo = AbstractAction.extend({
    
    
        template: 'my_dtbEditor',
        // 初始化,可以在action 里传入参数
        init: function (parent, action) {
    
    
            return this._super.apply(this, arguments);
        },
        start() {
    
    

        },
    })

    core.action_registry.add('my_dtbEditor', my_vueDemo);

    return my_vueDemo

})

视图xml文件

<?xml version="1.0"?>
<dtcloud>
    <data>
        <record id="action_dtbEditor" model="ir.actions.client">
            <field name="name">dtbEditor</field>
            <!--      tag  action在客户端的标识符,一般是一个专用的字符串,在js文件中注册该动作时指定。      -->
            <field name="tag">my_dtbEditor</field>
            <!--      target (可选)  current:当前内容区打开action;fullscreen:以全屏模式打开;new:以新窗口打开。      -->
            <field name="target">current</field>
            <!--      params (可选)  用来传给客户端动作的,字典格式      -->
            <field name="params">{'params': 'params'}</field>
            <!--      context 作为额外数据,传递给客户端函数。      -->
            <field name="context">{'context': 'context'}</field>
        </record>
        <menuitem
                id="menu_dtbEditor"
                name="dtbEditor"
                action="action_dtbEditor"
                groups="base.group_user"
                sequence="10"/>
    </data>
</dtcloud>

manifest.py

// 只放了主要代码
'data': [
    # 视图
    'views/home.xml',
],
'assets': {
    
    
    'web.assets_backend': [
        # 页面
        'dtb_editor/static/src/index.xml',
        # 主要入口
        'dtb_editor/static/src/main.js',
    ],
},

作者:白马不是马

猜你喜欢

转载自blog.csdn.net/ekcchina/article/details/130430826