44323
2024-04-23 16b704d18a875d1fb63827aaa507790ba2bef5be
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/**
 * 角色管理的单例
 */
var Html = {
    layerIndex: -1,
    domId: '',
    dataId: null,
    type: 1
};
 
var editor = null;
 
Html.cutover = function(type, e){
    if(typeof type != 'undefined' && null != type){
        Html.type = type;
    }
    if(null != e){
        $('.nav-tabs li').removeAttr('class');
        $(e).attr('class', 'active');
    }
    Html.queryData();
}
 
 
 
 
 
Html.queryData = function(){
    $.ajax({
        url: Feng.ctxPath + '/html/queryHtml',
        type: 'POST',
        data:{
            type: Html.type
        },
        success: function (res) {
            if(res.code == 200){
                editor.ready(function() {
                    editor.setContent(res.data)
                });
            }else{
                Feng.error(res.msg);
            }
        }
    });
}
 
 
Html.submit = function(){
    $.ajax({
        url: Feng.ctxPath + '/html/saveHtml',
        type: 'POST',
        data:{
            type: Html.type,
            content: editor.getContent()
        },
        success: function (res) {
            if(res.code == 200){
                Feng.success("保存成功");
            }else{
                Feng.error(res.msg);
            }
        }
    });
}
 
 
 
$(function () {
    editor = UE.getEditor('editor');
    // 手动指定上传文件调用的接口(不同文件类型不同接口)
    UE.Editor.prototype._bkGetActionUrl = UE.Editor.prototype.getActionUrl;
    UE.Editor.prototype.getActionUrl = function(action) {
        // 这里很重要,很重要,很重要,要和配置中的imageActionName值一样
        if(action == 'uploadimage'){
            // 这里调用后端我们写的图片上传接口
            return '/ueditor/uploadImageData';
        }else if(action == 'uploadfile'){
            return '/ueditor/uploadFileData';
        }else{
            return this._bkGetActionUrl.call(this, action);
        }
    }
 
    Html.queryData();
});