增加域名下载码绑定功能,权限大于1的可以使用该功能

dependabot/npm_and_yarn/fir_admin/tmpl-1.0.5
youngS 3 years ago
parent d7a31c62b3
commit f6918011ca
  1. 16
      fir_client/src/components/FirBase.vue
  2. 7
      fir_client/src/components/FirHeader.vue
  3. 8
      fir_client/src/components/apps/FirAppInfosBase.vue
  4. 2
      fir_client/src/components/apps/FirAppInfossecurity.vue
  5. 21
      fir_client/src/components/base/BindDomain.vue
  6. 18
      fir_ser/api/migrations/0009_userdomaininfo_domain_type.py
  7. 3
      fir_ser/api/models.py
  8. 7
      fir_ser/api/utils/baseutils.py
  9. 8
      fir_ser/api/utils/serializer.py
  10. 18
      fir_ser/api/views/domain.py

@ -1,12 +1,13 @@
<template>
<div ref="appbase">
<el-dialog
title="绑定下载页域名"
:title="bind_domain_title"
:close-on-click-modal="false"
:close-on-press-escape="false"
:visible.sync="bind_domain_sure"
width="666px">
<bind-domain transitionName="bind-user-domain"/>
<bind-domain v-if="bind_domain_sure" :transitionName="`bind-user-domain`+ bind_domain_type"
:domain_type="bind_domain_type"/>
</el-dialog>
<canvas ref="canvas" class="canvas" @mousemove="canvas_move" @mouseleave="canvas_leave"/>
<el-container>
@ -56,6 +57,8 @@
return {
mousePosition: {},
bind_domain_sure: false,
bind_domain_title: '绑定下载页域名',
bind_domain_type: 1,
active: 1,
domain_name: '',
bind_status: false,
@ -84,7 +87,14 @@
},
'$store.state.domain_action': function () {
if (this.$store.state.domain_action) {
this.$store.dispatch("dodomainaction", false);
if (this.$store.state.domain_action === 2) {
this.bind_domain_title = '绑定下载码域名';
this.bind_domain_type = 0
} else {
this.bind_domain_title = '绑定下载页域名';
this.bind_domain_type = 1
}
this.$store.dispatch("dodomainaction", 0);
this.bind_domain_sure = true;
}
},

@ -50,6 +50,9 @@
<el-dropdown-item command="userinfo">个人资料</el-dropdown-item>
<el-dropdown-item command="apitoken">API token</el-dropdown-item>
<el-dropdown-item command="setdomian">设置域名</el-dropdown-item>
<el-dropdown-item command="setqrdomian"
v-if="$store.state.userinfo&&$store.state.userinfo.role >1">下载码域名
</el-dropdown-item>
<el-dropdown-item command="storage" v-if="$store.state.userinfo.storage_active">存储管理
</el-dropdown-item>
<el-dropdown-item command="supersign" v-if="$store.state.userinfo.supersign_active">超级签名
@ -129,7 +132,9 @@
}, {methods: 'GET', token: this.token});
} else if (command === 'setdomian') {
this.$store.dispatch("dodomainaction", true);
this.$store.dispatch("dodomainaction", 1);
} else if (command === 'setqrdomian') {
this.$store.dispatch("dodomainaction", 2);
} else if (command === 'myorder') {
this.$router.push({"name": 'FirUserOrders'})
} else if (command === 'contact') {

@ -28,7 +28,8 @@
<span class="version ng-scope">{{ master_release.minimum_os_version }}&nbsp; 或者高版本</span>
<span class="short ng-scope" v-if="appinfos.issupersign">超级签</span>
<el-popover v-if="$store.state.userinfo.role === 3"
<el-popover
v-if="$store.state.userinfo&&$store.state.userinfo.role >1 &&$store.state.userinfo.qrcode_domain_name.length>3 "
placement="right"
width="288">
<div style="text-align: center; margin: 0">
@ -149,7 +150,10 @@
a.dispatchEvent(new MouseEvent('click'))
},
short_url() {
return location.origin + '/' + this.appinfos.short;
const userinfo = this.$store.state.userinfo;
if (userinfo && userinfo.role > 1 && userinfo.qrcode_domain_name.length > 3) {
return 'http://' + userinfo.qrcode_domain_name + '/' + this.appinfos.short;
}
},
setfunactive(item, index) {
for (let key in this.$refs) {

@ -6,7 +6,7 @@
:close-on-press-escape="false"
:visible.sync="bind_domain_sure"
width="666px">
<bind-domain transitionName="bind-user-domain" :app_id="this.currentapp.app_id"/>
<bind-domain v-if="bind_domain_sure" transitionName="bind-app-domain" :app_id="this.currentapp.app_id"/>
</el-dialog>
<el-form label-width="80px">
<el-form-item label-width="200px" label="访问密码">

@ -138,12 +138,16 @@
props: {
transitionName: {
type: String,
default: 'bind-domian'
default: 'bind-domain'
},
app_id: {
type: String,
default: undefined
},
domain_type: {
type: Number,
default: 1
},
},
data() {
return {
@ -155,7 +159,7 @@
}
},
mounted() {
this.bind_click()
this.bind_click();
},
beforeDestroy() {
this.bind_domain_sure = false;
@ -179,7 +183,7 @@
this.bind_status = false;
this.$message.error("绑定失败 " + data.msg)
}
}, {methods: 'PUT', data: {app_id: this.app_id}})
}, {methods: 'PUT', data: {app_id: this.app_id, domain_type: this.domain_type}})
},
remove_domain() {
domainFun(data => {
@ -188,12 +192,14 @@
this.active = 1;
this.$message.success("解除绑定成功 ");
if (!this.app_id) {
if (this.domain_type === 1) {
this.$store.dispatch("dodomainshow", true);
}
}
} else {
this.$message.error("解除绑定失败 " + data.msg)
}
}, {methods: 'DELETE', data: {app_id: this.app_id}});
}, {methods: 'DELETE', data: {app_id: this.app_id, domain_type: this.domain_type}});
},
bind_click() {
domainFun(data => {
@ -215,7 +221,7 @@
} else {
this.$message.error("绑定失败 " + data.msg)
}
}, {methods: 'GET', data: {app_id: this.app_id}});
}, {methods: 'GET', data: {app_id: this.app_id, domain_type: this.domain_type}});
},
format_domain_tData(cname_domain) {
let domain_name_list = this.domain_name.split('.');
@ -239,7 +245,10 @@
} else {
this.$message.error("绑定失败 " + data.msg)
}
}, {methods: 'POST', data: {domain_name: this.domain_name, app_id: this.app_id}})
}, {
methods: 'POST',
data: {domain_name: this.domain_name, app_id: this.app_id, domain_type: this.domain_type}
})
} else if (this.active === 2) {
this.check_cname()
}

@ -0,0 +1,18 @@
# Generated by Django 3.2.3 on 2021-09-18 15:17
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('api', '0008_remove_appiosdeveloperinfo_use_number'),
]
operations = [
migrations.AddField(
model_name='userdomaininfo',
name='domain_type',
field=models.SmallIntegerField(choices=[(0, '下载码域名'), (1, '预览下载域名')], default=1,
help_text='0 表示下载码域名,扫描下载码域名,会自动跳转到预览域名', verbose_name='域名类型'),
),
]

@ -482,6 +482,9 @@ class UserDomainInfo(models.Model):
domain_name = models.CharField(verbose_name="下载页面域名", db_index=True, max_length=64, null=False, blank=False)
is_enable = models.BooleanField(default=False, verbose_name="绑定成功")
created_time = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")
domain_type_choices = ((0, '下载码域名'), (1, '预览下载域名'),)
domain_type = models.SmallIntegerField(choices=domain_type_choices, default=1, verbose_name="域名类型",
help_text="0 表示下载码域名,扫描下载码域名,会自动跳转到预览域名")
class Meta:
verbose_name = '用户分发域名绑定'

@ -168,15 +168,16 @@ def get_cname_from_domain(domain):
return str(None)
def get_user_domain_name(obj):
domain_obj = UserDomainInfo.objects.filter(user_id=obj, is_enable=True, app_id=None).first()
def get_user_domain_name(obj, domain_type=1):
domain_obj = UserDomainInfo.objects.filter(user_id=obj, is_enable=True, app_id=None,
domain_type=domain_type).first()
if domain_obj:
return domain_obj.domain_name
return ''
def get_app_domain_name(obj):
domain_obj = UserDomainInfo.objects.filter(app_id=obj, is_enable=True).first()
domain_obj = UserDomainInfo.objects.filter(app_id=obj, is_enable=True, domain_type=1).first()
if domain_obj:
return domain_obj.domain_name
return ''

@ -57,7 +57,7 @@ class UserInfoSerializer(serializers.ModelSerializer):
model = models.UserInfo
fields = ["username", "uid", "mobile", "job", "email", "domain_name", "role", "first_name",
'head_img', 'storage_active', 'supersign_active', 'free_download_times', 'download_times',
'certification']
'certification', 'qrcode_domain_name']
head_img = serializers.SerializerMethodField()
@ -83,6 +83,12 @@ class UserInfoSerializer(serializers.ModelSerializer):
def get_domain_name(self, obj):
return get_user_domain_name(obj)
qrcode_domain_name = serializers.SerializerMethodField()
def get_qrcode_domain_name(self, obj):
if obj.role and obj.role > 1:
return get_user_domain_name(obj, 0)
class AdminUserInfoSerializer(UserInfoSerializer):
class Meta:

@ -22,8 +22,12 @@ logger = logging.getLogger(__name__)
def get_domain_filter(request):
filter_dict = {'user_id': request.user, 'app_id__app_id': None}
app_id = request.query_params.get("app_id", request.data.get("app_id", None))
if app_id:
domain_type = request.query_params.get("domain_type", request.data.get("domain_type", None))
if app_id is not None:
filter_dict['app_id__app_id'] = app_id
if domain_type is not None:
filter_dict['domain_type'] = domain_type
logger.info(f"domain filter {filter_dict}")
return filter_dict
@ -44,10 +48,16 @@ class DomainCnameView(APIView):
def post(self, request):
res = BaseResponse()
domain_name = request.data.get("domain_name", None)
domain_type = request.data.get('domain_type', 1)
if domain_type not in [x[0] for x in list(UserDomainInfo.domain_type_choices)]:
res.code = 1001
res.msg = "绑定失败"
return Response(res.dict)
if domain_name:
domain_name = domain_name.strip(" ")
if domain_name and len(domain_name) > 3 and is_valid_domain(domain_name):
if UserDomainInfo.objects.filter(domain_name=domain_name, is_enable=True).count() != 0:
if UserDomainInfo.objects.filter(domain_name=domain_name, is_enable=True,
domain_type=domain_type).count() != 0:
res.code = 1001
res.msg = "该域名已经被绑定,请更换其他域名"
else:
@ -65,6 +75,7 @@ class DomainCnameView(APIView):
'cname_id': min_domain_cname_info_obj,
'domain_name': domain_name,
'app_id': None,
'domain_type': domain_type
}
app_id = request.data.get("app_id", None)
if app_id:
@ -85,7 +96,8 @@ class DomainCnameView(APIView):
if cname == user_domain_obj.cname_id.domain_record + '.':
user_domain_obj.is_enable = True
user_domain_obj.save(update_fields=["is_enable"])
UserDomainInfo.objects.filter(domain_name=user_domain_obj.domain_name, is_enable=False).delete()
UserDomainInfo.objects.filter(domain_name=user_domain_obj.domain_name, is_enable=False,
domain_type=user_domain_obj.domain_type).delete()
app_id = request.data.get("app_id", None)
if app_id:
app_obj = Apps.objects.filter(app_id=app_id).first()

Loading…
Cancel
Save