diff --git a/auto_pt/urls.py b/auto_pt/urls.py index ddc8242..939ae21 100644 --- a/auto_pt/urls.py +++ b/auto_pt/urls.py @@ -24,6 +24,9 @@ urlpatterns = [ path(r'site_status_api', views.site_status_api, name='site_status_api'), path(r'site_status', views.site_status, name='site_status'), path(r'site_data_api', views.site_data_api, name='site_data_api'), + path(r'sign_in_api', views.sign_in_api, name='sign_in_api'), + path(r'update_site_api', views.update_site_api, name='update_site_api'), + path(r'edit_site_api', views.edit_site_api, name='edit_site_api'), path(r'downloading_status', views.downloading_status, name='downloading_status'), path(r'do_sql', views.do_sql, name='do_sql'), ] diff --git a/auto_pt/views.py b/auto_pt/views.py index 0828264..0e7fa32 100644 --- a/auto_pt/views.py +++ b/auto_pt/views.py @@ -599,12 +599,14 @@ def get_status(ids: list = None): seeding_size += site_info.seed_vol weeks = (now - my_site.time_join).days // 7 days = (now - my_site.time_join).days % 7 + # my_site.signin_set.filter(created_at__day=now.date()).first().sign_in_today site_info = { 'id': my_site.id, 'name': my_site.site.name, 'icon': my_site.site.logo, 'url': my_site.site.url, 'class': my_site.my_level, + # 'sign_in': my_site.signin_set.filter(created_at__day=now.date()), 'invite': my_site.invitation, 'sp_hour': my_site.sp_hour, 'sp_hour_full': '{:.2%}'.format( @@ -696,3 +698,21 @@ def site_data_api(request): 'site_status_list': site_status_list } ).to_dict(), safe=False) + + +def sign_in_api(request): + return JsonResponse(data=CommonResponse.success( + msg='ok' + ).to_dict(), safe=False) + + +def update_site_api(request): + return JsonResponse(data=CommonResponse.success( + msg='ok' + ).to_dict(), safe=False) + + +def edit_site_api(request): + return JsonResponse(data=CommonResponse.success( + msg='ok' + ).to_dict(), safe=False) diff --git a/templates/auto_pt/status.html b/templates/auto_pt/status.html index 38c0950..222d666 100644 --- a/templates/auto_pt/status.html +++ b/templates/auto_pt/status.html @@ -269,25 +269,97 @@ deep: true, } }, - methods: { - signIn(id) { - alert(id) - }, - updateSite(id) { - alert(id) - }, - editSite(id) { - alert(id) - }, - showHistoryList(id) { - axios.get( - "{% url 'site_data_api' %}" + '?id=' + id - ).then(res => { - console.log('获取数据列表成功', res.data) - let data = res.data - if ((typeof res.data) == "string") { - data = JSON.parse(data) - } + methods: { + signIn(id) { + axios.get( + "{% url 'sign_in_api' %}" + '?id=' + id + ).then(res => { + console.log('获取数据列表成功', res.data) + let data = res.data + {#console.log(typeof res.data.data)#} + if (res.data.code === 0) { + this.$message({ + type: 'success', + message: res.data.msg + }); + } else { + this.loading = false + this.$message({ + type: 'warning', + message: '获取数据列表失败!' + }); + } + }).catch(res => { + console.log('获取数据列表失败', res) + this.$message({ + type: 'warning', + message: '获取数据列表失败!' + res + }); + }) + }, + updateSite(id) { + axios.get( + "{% url 'update_site_api' %}" + '?id=' + id + ).then(res => { + console.log('获取数据列表成功', res.data) + let data = res.data + {#console.log(typeof res.data.data)#} + if (res.data.code === 0) { + this.$message({ + type: 'success', + message: res.data.msg + }); + } else { + this.loading = false + this.$message({ + type: 'warning', + message: '获取数据列表失败!' + }); + } + }).catch(res => { + console.log('获取数据列表失败', res) + this.$message({ + type: 'warning', + message: '获取数据列表失败!' + res + }); + }) + }, + editSite(id) { + axios.get( + "{% url 'edit_site_api' %}" + '?id=' + id + ).then(res => { + console.log('获取数据列表成功', res.data) + let data = res.data + {#console.log(typeof res.data.data)#} + if (res.data.code === 0) { + this.$message({ + type: 'success', + message: res.data.msg + }); + } else { + this.loading = false + this.$message({ + type: 'warning', + message: '获取数据列表失败!' + }); + } + }).catch(res => { + console.log('获取数据列表失败', res) + this.$message({ + type: 'warning', + message: '获取数据列表失败!' + res + }); + }) + }, + showHistoryList(id) { + axios.get( + "{% url 'site_data_api' %}" + '?id=' + id + ).then(res => { + console.log('获取数据列表成功', res.data) + let data = res.data + if ((typeof res.data) == "string") { + data = JSON.parse(data) + } {#console.log(typeof res.data.data)#} if (res.data.code === 0) { {#this.ptData = res.data.data#}