mirror of
https://github.com/zmister2016/MrDoc.git
synced 2025-04-18 20:40:48 +08:00
新增收藏功能,优化后台样式
This commit is contained in:
parent
caa4172dc8
commit
68bd783c33
@ -10,6 +10,8 @@
|
||||
- [新增]文集图标配置功能;
|
||||
- [新增]Word(.docx格式)文档导入功能;
|
||||
- [优化]文档编辑器界面样式和交互;
|
||||
- [修复]仅有私密文集的站点游客可搜索到私密文集的问题;
|
||||
- [新增]文集水印配置;
|
||||
|
||||
|
||||
### v0.6.2 2020-12
|
||||
|
@ -900,43 +900,65 @@ def admin_center_menu(request):
|
||||
"id": 2,
|
||||
"title": "文集管理",
|
||||
"type": 1,
|
||||
"icon": "layui-icon layui-icon-console",
|
||||
"icon": "layui-icon layui-icon-list",
|
||||
"href": reverse('project_manage'),
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"title": "文档管理",
|
||||
"type": 1,
|
||||
"icon": "layui-icon layui-icon-console",
|
||||
"icon": "layui-icon layui-icon-form",
|
||||
"href": reverse('doc_manage'),
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"title": "文档模板管理",
|
||||
"type": 1,
|
||||
"icon": "layui-icon layui-icon-console",
|
||||
"icon": "layui-icon layui-icon-templeate-1",
|
||||
"href": reverse('doctemp_manage'),
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"title": "注册码管理",
|
||||
"type": 1,
|
||||
"icon": "layui-icon layui-icon-console",
|
||||
"icon": "layui-icon layui-icon-component",
|
||||
"href": reverse('register_code_manage'),
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
"title": "用户管理",
|
||||
"type": 1,
|
||||
"icon": "layui-icon layui-icon-console",
|
||||
"icon": "layui-icon layui-icon-user",
|
||||
"href": reverse('user_manage'),
|
||||
},
|
||||
{
|
||||
"id": 7,
|
||||
"title": "站点设置",
|
||||
"type": 1,
|
||||
"icon": "layui-icon layui-icon-console",
|
||||
"icon": "layui-icon layui-icon-set",
|
||||
"href": reverse('sys_setting'),
|
||||
},
|
||||
{
|
||||
"id": "common",
|
||||
"title": "使用帮助",
|
||||
"icon": "layui-icon layui-icon-template-1",
|
||||
"type": 0,
|
||||
"href": "",
|
||||
"children": [{
|
||||
"id": 701,
|
||||
"title": "安装说明",
|
||||
"icon": "layui-icon layui-icon-face-smile",
|
||||
"type": 1,
|
||||
"openType": "_blank",
|
||||
"href": "http://mrdoc.zmister.com/project-7/"
|
||||
}, {
|
||||
"id": 702,
|
||||
"title": "使用说明",
|
||||
"icon": "layui-icon layui-icon-face-smile",
|
||||
"type": 1,
|
||||
"openType": "_blank",
|
||||
"href": "http://mrdoc.zmister.com/project-54/"
|
||||
}]
|
||||
}
|
||||
]
|
||||
return JsonResponse(menu_data,safe=False)
|
||||
|
30
app_doc/migrations/0037_mycollect.py
Normal file
30
app_doc/migrations/0037_mycollect.py
Normal file
@ -0,0 +1,30 @@
|
||||
# Generated by Django 2.2.12 on 2020-12-30 21:02
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
('app_doc', '0036_auto_20201229_2004'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='MyCollect',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('collect_type', models.IntegerField(verbose_name='收藏类型')),
|
||||
('collect_id', models.IntegerField(verbose_name='收藏对象ID')),
|
||||
('create_time', models.DateTimeField(auto_now_add=True)),
|
||||
('create_user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
options={
|
||||
'verbose_name': '我的收藏',
|
||||
'verbose_name_plural': '我的收藏',
|
||||
},
|
||||
),
|
||||
]
|
@ -250,4 +250,20 @@ class Attachment(models.Model):
|
||||
|
||||
class Meta:
|
||||
verbose_name = '附件管理'
|
||||
verbose_name_plural = verbose_name
|
||||
|
||||
|
||||
# 我的收藏
|
||||
class MyCollect(models.Model):
|
||||
# 收藏类型 1表示文档 2表示文集
|
||||
collect_type = models.IntegerField(verbose_name="收藏类型")
|
||||
collect_id = models.IntegerField(verbose_name="收藏对象ID")
|
||||
create_user = models.ForeignKey(User,on_delete=models.CASCADE)
|
||||
create_time = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.collect_type
|
||||
|
||||
class Meta:
|
||||
verbose_name = '我的收藏'
|
||||
verbose_name_plural = verbose_name
|
@ -64,4 +64,5 @@ urlpatterns = [
|
||||
path('doc_search/', views_search.DocSearchView(),name="doc_search"), # 全文检索框架
|
||||
path('manage_overview/',views.manage_overview,name="manage_overview"), # 个人中心概览
|
||||
path('manage_self/',views.manage_self,name="manage_self"), # 个人设置
|
||||
path('my_collect/',views.my_collect,name="my_collect"), # 我的收藏
|
||||
]
|
@ -323,6 +323,13 @@ def project_index(request,pro_id):
|
||||
# 获取文集的协作成员
|
||||
colla_user_list = ProjectCollaborator.objects.filter(project=project)
|
||||
|
||||
# 获取文集收藏状态
|
||||
if request.user.is_authenticated:
|
||||
is_collect_pro = MyCollect.objects.filter(
|
||||
collect_type=2,collect_id=pro_id,create_user=request.user).exists()
|
||||
else:
|
||||
is_collect_pro = False
|
||||
|
||||
# 获取文集的协作用户信息
|
||||
if request.user.is_authenticated: # 对登陆用户查询其协作文档信息
|
||||
colla_user = ProjectCollaborator.objects.filter(project=project,user=request.user).count()
|
||||
@ -849,6 +856,16 @@ def doc(request,pro_id,doc_id):
|
||||
else:
|
||||
colla_user = 0
|
||||
|
||||
# 获取文集收藏状态
|
||||
if request.user.is_authenticated:
|
||||
is_collect_pro = MyCollect.objects.filter(collect_type=2, collect_id=pro_id,
|
||||
create_user=request.user).exists()
|
||||
# 获取文档收藏状态
|
||||
is_collect_doc = MyCollect.objects.filter(collect_type=1, collect_id=doc_id,
|
||||
create_user=request.user).exists()
|
||||
else:
|
||||
is_collect_pro,is_collect_doc = False,False
|
||||
|
||||
# 私密文集且访问者非创建者、协作者 - 不能访问
|
||||
if (project.role == 1) and (request.user != project.create_user) and (colla_user == 0):
|
||||
return render(request, '404.html')
|
||||
@ -2936,4 +2953,33 @@ def manage_self(request):
|
||||
)
|
||||
return JsonResponse({'status':True,'data':'ok'})
|
||||
else:
|
||||
return JsonResponse({'status':False,'data':'参数不正确'})
|
||||
return JsonResponse({'status':False,'data':'参数不正确'})
|
||||
|
||||
|
||||
# 文集文档收藏
|
||||
@login_required()
|
||||
def my_collect(request):
|
||||
if request.method == 'GET':
|
||||
pass
|
||||
elif request.method == 'POST':
|
||||
collect_type = request.POST.get('type',None) # 收藏类型
|
||||
collect_id = request.POST.get('id',None) # 收藏对象ID
|
||||
if (collect_type is None) or (collect_id is None):
|
||||
return JsonResponse({'status':False,'data':'参数错误'})
|
||||
else:
|
||||
is_collect = MyCollect.objects.filter(collect_type=collect_type,collect_id=collect_id,create_user=request.user)
|
||||
# 存在收藏
|
||||
if is_collect.exists():
|
||||
is_collect.delete()
|
||||
return JsonResponse({'status': True, 'data': '取消收藏成功'})
|
||||
else:
|
||||
MyCollect.objects.create(
|
||||
collect_type = collect_type,
|
||||
collect_id = collect_id,
|
||||
create_user = request.user,
|
||||
create_time = datetime.datetime.now()
|
||||
)
|
||||
return JsonResponse({'status':True,'data':'收藏成功'})
|
||||
|
||||
elif request.method == 'DELETE':
|
||||
pass
|
@ -177,6 +177,14 @@ def user_center_menu(request):
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "user_manual",
|
||||
"title": "使用手册",
|
||||
"icon": "layui-icon layui-icon-template-1",
|
||||
"type": 1,
|
||||
"openType": "_blank",
|
||||
"href": "http://mrdoc.zmister.com/project-54/",
|
||||
}
|
||||
# {
|
||||
# "id": "common",
|
||||
# "title": "使用帮助",
|
||||
|
@ -101,4 +101,10 @@ li.L1, li.L3, li.L5, li.L7, li.L9 {
|
||||
position: absolute;
|
||||
opacity: 0.1;
|
||||
pointer-events: none;
|
||||
}
|
||||
.collected{
|
||||
color: rgb(250, 173, 20);
|
||||
}
|
||||
.doc-bottom-icon,.doc-bottom-btn{
|
||||
cursor: pointer;
|
||||
}
|
@ -307,7 +307,7 @@ doc_qrcode = function(){
|
||||
};
|
||||
doc_qrcode();
|
||||
|
||||
|
||||
// 文集水印
|
||||
textBecomeImg = function(text,fontsize,fontcolor){
|
||||
var canvas = document.createElement('canvas');
|
||||
canvas.height = 180;
|
||||
|
@ -71,20 +71,32 @@
|
||||
</div>
|
||||
|
||||
<div class="layui-row layui-col-space20" style="padding-left: 20px;">
|
||||
<span>
|
||||
<span class="doc-bottom-icon">
|
||||
<i class="layui-icon layui-icon-user"></i> {% if doc.create_user.first_name != '' %} {{doc.create_user.first_name}} {% else %} {{doc.create_user.username}}{% endif %}
|
||||
</span>
|
||||
<span tooltip="{% trans '更新于:' %}{{doc.modify_time}}">
|
||||
<span tooltip="{% trans '更新于:' %}{{doc.modify_time}}" class="doc-bottom-icon">
|
||||
<i class="layui-icon layui-icon-log"></i> {{ doc.modify_time }}
|
||||
</span>
|
||||
|
||||
<button id="share" class="doc-bottom-btn" tooltip="{% trans '分享本文档' %}">
|
||||
<i class="layui-icon layui-icon-share" ></i> {% trans "分享" %}
|
||||
<i class="layui-icon layui-icon-share" ></i> {% trans "分享文档" %}
|
||||
</button>
|
||||
|
||||
<span class="doc-bottom-icon">
|
||||
{% if request.user.is_authenticated %}
|
||||
{% if is_collect_doc %}
|
||||
<i class="layui-icon layui-icon-star-fill collected" id="collect_doc"></i> {% trans "收藏文档" %}
|
||||
{% else %}
|
||||
<i class="layui-icon layui-icon-star" id="collect_doc"></i> {% trans "收藏文档" %}
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<i class="layui-icon layui-icon-star" title="请登录后收藏"></i> {% trans "收藏文档" %}
|
||||
{% endif %}
|
||||
</span>
|
||||
|
||||
{% if request.user == doc.create_user or request.user.is_superuser %}
|
||||
<button class="doc-bottom-btn" tooltip="{% trans '下载文档' %}" id="download_doc">
|
||||
<i class="fa fa-download"></i> {% trans "下载" %}
|
||||
<i class="fa fa-download"></i> {% trans "下载文档" %}
|
||||
</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
@ -55,6 +55,15 @@
|
||||
<i class="layui-icon layui-icon-password" title="{% trans '私密文档' %}"></i>
|
||||
{% endif %}
|
||||
</a>
|
||||
{% if request.user.is_authenticated %}
|
||||
{% if is_collect_pro %}
|
||||
<i class="layui-icon layui-icon-star-fill collected" style="cursor: pointer;" title="已收藏文集,点击取消" id="collect_pro"></i>
|
||||
{% else %}
|
||||
<i class="layui-icon layui-icon-star" style="cursor: pointer;" title="收藏文集" id="collect_pro"></i>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<i class="layui-icon layui-icon-star" style="cursor: pointer;" title="请登录后收藏"></i>
|
||||
{% endif %}
|
||||
<p>
|
||||
{% if colla_user > 0 %}
|
||||
<span style="font-size:12px;color:gray;font-weight:100;">{% trans "* 此为协作文集" %}</span>
|
||||
@ -389,7 +398,6 @@
|
||||
|
||||
{% if project.is_watermark %}
|
||||
var img_base64 = textBecomeImg('{{project.watermark_value}}','14','#000')
|
||||
console.log(img_base64)
|
||||
document.getElementById("wm").style.background = 'url('+ img_base64 + ')'
|
||||
{% endif %}
|
||||
</script>
|
||||
@ -408,6 +416,41 @@
|
||||
};
|
||||
var img_viewer = new Viewer(document.getElementById('content'), img_options);
|
||||
{% endif %}
|
||||
|
||||
// 收藏文集
|
||||
var layer = layui.layer;
|
||||
$("#collect_pro").click(function(e){
|
||||
$(this).toggleClass("layui-icon-star-fill layui-icon-star");
|
||||
$(this).toggleClass("collected");
|
||||
$.ajax({
|
||||
url:'/my_collect/',
|
||||
type:'post',
|
||||
data:{'type':2,'id':'{{project.id}}'},
|
||||
success:function(r){
|
||||
layer.msg(r.data)
|
||||
},
|
||||
error:function(){
|
||||
layer.msg("操作异常")
|
||||
}
|
||||
});
|
||||
});
|
||||
// 收藏文档
|
||||
$("#collect_doc").click(function(){
|
||||
$(this).toggleClass("layui-icon-star-fill layui-icon-star")
|
||||
$(this).toggleClass("collected")
|
||||
$.ajax({
|
||||
url:'/my_collect/',
|
||||
type:'post',
|
||||
data:{'type':1,'id':'{{doc.id}}'},
|
||||
success:function(r){
|
||||
layer.msg(r.data)
|
||||
},
|
||||
error:function(){
|
||||
layer.msg("操作异常")
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<!-- 统计代码开始 -->
|
||||
|
@ -310,10 +310,10 @@
|
||||
layer.closeAll("loading"); //关闭加载层
|
||||
window.localStorage.removeItem('mrdoc_doc_cache') // 清空文档缓存
|
||||
if(status === 1){
|
||||
layer.msg('发布成功,即将跳转到文档页面',function(){
|
||||
layer.msg('发布成功',{time:1000},function(){
|
||||
md_changed = false;
|
||||
//跳转到发布的文档
|
||||
window.location.href = "/project-" + r.data.pro + "/doc-" + r.data.doc
|
||||
//跳转到文档修改
|
||||
window.location.href = "/modify_doc/"+r.data.doc+"/";
|
||||
});
|
||||
}else{
|
||||
layer.msg('保存成功',{time:1000},function(){
|
||||
|
Loading…
x
Reference in New Issue
Block a user