mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-07 02:22:48 +08:00
优化编辑器图片选择和自动保存
This commit is contained in:
@@ -250,6 +250,12 @@
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var lastUpdateSecond = 0;
|
||||
var currentSecond = 0;
|
||||
|
||||
setInterval(() => {
|
||||
currentSecond++
|
||||
}, 1000);
|
||||
var categoryList = JSON.parse('{:json_encode($post->categorys->column("category_id"))}')
|
||||
var tagList = JSON.parse('{:json_encode($post->tags->column("tag_id"))}')
|
||||
layui.use(['form', 'upload', 'laydate'], function () {
|
||||
@@ -295,12 +301,30 @@
|
||||
});
|
||||
|
||||
quill.on('text-change', function (delta, oldDelta, source) {
|
||||
|
||||
currentRange.index = delta.ops[0].retain
|
||||
if (source == 'api') {
|
||||
console.log("An API call triggered this change.");
|
||||
} else if (source == 'user') {
|
||||
console.log("A user action triggered this change.");
|
||||
}
|
||||
|
||||
if (currentSecond - lastUpdateSecond > 30) {
|
||||
|
||||
var formData = {
|
||||
'id': '{$post.id}'
|
||||
};
|
||||
|
||||
formData.content = quill.getContents().ops
|
||||
formData.content_html = $('#editor .ql-editor').html()
|
||||
|
||||
$.post('{:url("update")}', formData, function (result) {
|
||||
lastUpdateSecond = currentSecond
|
||||
layer.msg('自动保存成功', {
|
||||
offset: 't'
|
||||
})
|
||||
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
upload.render({
|
||||
@@ -381,7 +405,7 @@
|
||||
function loadTags() {
|
||||
$.get('{:url("Tag/index")}', {
|
||||
page: tagPage,
|
||||
type:'{$Request.param.type}'
|
||||
type: '{$Request.param.type}'
|
||||
}, function (result) {
|
||||
tagPage++;
|
||||
result.data.data.forEach(tag => {
|
||||
@@ -428,8 +452,8 @@
|
||||
|
||||
function loadCategory() {
|
||||
$.get('{:url("Category/index")}', {
|
||||
type:'{$Request.param.type}'
|
||||
},function (result) {
|
||||
type: '{$Request.param.type}'
|
||||
}, function (result) {
|
||||
|
||||
result.data.forEach(category => {
|
||||
var prefix = '';
|
||||
|
||||
Reference in New Issue
Block a user