Browse Source

基本不慌不忙鞥完善

wangeditor
chenlong 2 years ago
parent
commit
31086b028f
  1. 8
      Install.php
  2. 8
      Service/Admin/NotebookService.php
  3. 47
      View/Admin/Notebook/lists.blade.php
  4. 27
      resource/wangeditor_editor@5.1.23_dist_css_style.css
  5. 24129
      resource/wangeditor_editor@5.1.23_dist_index.js

8
Install.php

@ -1,16 +1,16 @@
<?php
namespace Notebook;
namespace Plugins\Notebook;
use App\Interfaces\PluginsInstallInterface;
use App\Util\PluginsInstallHelper;
use Hyperf\DbConnection\Db;
class Install implements PluginsInstallInterface
{
public static function run(): void
{
PluginsInstallHelper::addResource(__DIR__ . '/resource/wangeditor_editor@5.1.23_dist_index.js', '/static/wangeditor_editor@5.1.23_dist_index.js');
PluginsInstallHelper::addResource(__DIR__ . '/resource/wangeditor_editor@5.1.23_dist_css_style.css', '/static/wangeditor_editor@5.1.23_dist_css_style.css');
// 添加菜单
Db::insert("INSERT INTO `sd_module`.`sc_route` (`pid`, `type`, `title`, `icon`, `route`, `power_route`, `weigh`, `create_time`, `update_time`, `delete_time`) VALUES (0, 1, '笔记本', 'Document', '/admin/plugins/notebook/lists', NULL, 1, '2023-09-24 12:36:45', '2023-09-24 12:36:45', NULL);");
}
}

8
Service/Admin/NotebookService.php

@ -3,6 +3,7 @@
namespace Plugins\Notebook\Service\Admin;
use App\Exception\ApiMessageException;
use App\Service\Admin\AbstractAdminService;
use App\Service\Admin\Traits\DestroyServiceTrait;
use App\Service\Admin\Traits\StoreServiceTrait;
@ -47,6 +48,13 @@ class NotebookService extends AbstractAdminService
$data['latest_administrators_id'] = AdminAuth::getInfo()->id;
}
public function beforeUpdate(&$data, $id): void
{
if (strtotime($data['update_time']) < strtotime($this->model->update_time)){
throw new ApiMessageException("文档内容不是最新版,请更新后编辑");
}
}
/**
* @param int $id
* @param string $update_time

47
View/Admin/Notebook/lists.blade.php

@ -1,10 +1,13 @@
@extends('Admin.layout')
@section('header')
<link rel="stylesheet" href="/froala/froala_editor.pkgd.min.css" />
<link rel="stylesheet" href="/static/wangeditor_editor@5.1.23_dist_css_style.css" />
<script src="/froala/froala_editor.pkgd.min.js"></script>
<script src="/froala/zh_cn.js"></script>
<script src="/static/wangeditor_editor@5.1.23_dist_index.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.3.0/codemirror.min.css">
<!-- Include Code Mirror JS. -->
{{-- <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.3.0/codemirror.min.js"></script>--}}
{{-- <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.3.0/mode/xml/xml.min.js"></script>--}}
<style>
.notebook-lists.warning-background{
background-color: #fdf6ec;
@ -59,15 +62,22 @@
cursor: pointer;
color: #129b00;
}
.delete:hover{
.list-tool{
position: absolute;
top: 8px;
right: 10px;
display: flex;
}
.list-tool-item{
margin: 0 5px;
font-size: 15px;
}
.list-tool-item:hover{
cursor: pointer;
font-size: 18px;
font-weight: bold;
}
.delete{
position: absolute;
top: 8px;
right: 10px;
color: red;
}
#fr-logo{ display: none; }
@ -140,7 +150,10 @@
<div class="content">@{{item.content.replace(/<\/?.+?>/g,"").replace(/ /g,"").substring(0, 30)}}...</div>
<div class="time">创建时间:@{{item.create_time}}</div>
<div class="time"><div>创建人:@{{ item.create_name }}</div> <div>最后更新: @{{ item.latest_name }}</div></div>
<div class="delete" @click.stop="deleteaa"><el-icon><delete/></el-icon></div>
<div class="list-tool">
<div class="list-tool-item" v-if="item.id === currentNotebook.id"><el-icon @click.stop="getLatest"><Refresh/></el-icon></div>
<div class="list-tool-item delete" ><el-icon @click.stop="deleteaa"><delete/></el-icon></div>
</div>
</div>
<el-divider v-if="notNotebook">
没有更多笔记了
@ -162,7 +175,6 @@
@section('footer')
<script>
VueInit.data.notebook = [];
VueInit.data.active = 0;
VueInit.data.searchText = "";
@ -260,13 +272,31 @@
if(this.noteBookUpVersion === upVersion){
return;
}
this.currentNotebook.update_time = this.toTime();
axios({
url: "update",
method: 'post',
data: this.currentNotebook
}).then(({ data:res }) => {
if(res.code !== 200){
this.$message.warning(res.msg);
}else{
this.currentNotebook.update_time = this.toTime();
this.$notify.success("文档已同步");
}
});
this.noteBookUpVersion = upVersion;
}
VueInit.methods.toTime = function () {
var date = new Date();//时间戳为10位需*1000,时间戳为13位的话不需乘1000
var Y = date.getFullYear() + '-';
var M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1):date.getMonth()+1) + '-';
var D = (date.getDate()< 10 ? '0'+date.getDate():date.getDate())+ ' ';
var h = (date.getHours() < 10 ? '0'+date.getHours():date.getHours())+ ':';
var m = (date.getMinutes() < 10 ? '0'+date.getMinutes():date.getMinutes()) + ':';
var s = date.getSeconds() < 10 ? '0'+date.getSeconds():date.getSeconds();
return Y+M+D+h+m+s;
}
VueInit.event.addHandler('created:updateRegularly', function (){
setInterval(() => {
@ -289,6 +319,7 @@
if (!res.data) {
return;
}
this.$notify.success("已获取获取最新笔记");
this.currentNotebook.latest_name = res.data.latest_name;
this.currentNotebook.content = res.data.content;
this.currentNotebook.title = res.data.title;

27
resource/wangeditor_editor@5.1.23_dist_css_style.css

File diff suppressed because one or more lines are too long

24129
resource/wangeditor_editor@5.1.23_dist_index.js

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save