mirror of
https://gitee.com/ulthon/ulthon_information.git
synced 2026-03-03 16:24:28 +08:00
自动保存编写的文章
This commit is contained in:
@@ -257,6 +257,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"))}')
|
||||
@@ -301,18 +307,34 @@
|
||||
} else {
|
||||
console.log('Cursor not in the editor');
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
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({
|
||||
@@ -369,8 +391,6 @@
|
||||
formData.content = quill.getContents().ops
|
||||
formData.content_html = $('#editor .ql-editor').html()
|
||||
|
||||
console.log(formData);
|
||||
|
||||
$.post('{:url("update")}', formData, function (result) {
|
||||
|
||||
layer.msg('保存成功')
|
||||
|
||||
Reference in New Issue
Block a user