diff --git a/app.py b/app.py index dc6818f3d..b9003b39a 100644 --- a/app.py +++ b/app.py @@ -1,22 +1,17 @@ from flask import Flask -# from flask import Blueprint,render_template -from views import dashboard -from views import site -from views import files -from views import soft -from views import config -from views import plugins +import views app = Flask(__name__) app.debug = True DEFAULT_MODULES = ( - (dashboard, "/"), - (site, "/site"), - (files, "/files"), - (soft, "/soft"), - (config, "/config"), - (plugins, "/plugins"), + (views.dashboard, "/"), + (views.site, "/site"), + (views.files, "/files"), + (views.soft, "/soft"), + (views.config, "/config"), + (views.plugins, "/plugins"), + (views.task, "/task"), ) diff --git a/static/js/public.js b/static/js/public.js index ffade6501..51d65156f 100755 --- a/static/js/public.js +++ b/static/js/public.js @@ -936,7 +936,7 @@ function GetTaskList(a) { } function GetTaskCount() { - $.post("/ajax?action=GetTaskCount", "", function(a) { + $.get("/task/count", "", function(a) { $(".task").text(a) }) } diff --git a/static/js/soft.js b/static/js/soft.js index e865c222a..fe54b099e 100755 --- a/static/js/soft.js +++ b/static/js/soft.js @@ -194,7 +194,7 @@ function service(name, status) { //更新软件列表 function updateSoftList() { - $.get('/plugin?action=getCloudPlugin', function(rdata) {}); + $.get('/plugins/list?action=getCloudPlugin', function(rdata) {}); } //php上传限制 @@ -1810,7 +1810,9 @@ function GetSList(isdisplay) { setCookie('p' + getCookie('softType'), isdisplay); } - $.post('/plugin?action=getPluginList&tojs=GetSList' + search + type + page, '', function(rdata) { + console.log("1212"); + + $.post('/plugins/list&tojs=GetSList' + search + type + page, '', function(rdata) { layer.close(loadT); var tBody = ''; var sBody = ''; @@ -2182,197 +2184,7 @@ function get_plugin_coupon(pid) { } }) } -//取专业版代金券 -function get_pro_coupon() { - $("#couponlist").html("
加载中,请稍后
"); - $.get("/auth?action=get_voucher", function(rdata) { - if (rdata != null) { - var con = ''; - var len = rdata.length; - for (var i = 0; i < len; i++) { - if (rdata[i].status != 1) { - var cyc = rdata[i].cycle + conver_unit(rdata[i].unit); - if (rdata[i].cycle == 999) { - cyc = "永久" - } - con += '
  • ' + cyc + '
  • '; - } - } - $("#couponlist").html(''); - $(".pay-btn-group > li").click(function() { - $(this).addClass("active").siblings().removeClass("active"); - $(".paymethod-submit button").css({ "background-color": "#20a53a", "border-color": "#20a53a" }); - }); - $(".paymethod-submit button").click(function() { - var code = $("#couponlist .pay-btn-group .active").attr("data-code"); - if (code == undefined) { - layer.msg("请选择代金券"); - } else { - useCoupon(code); - } - }) - } else { - $("#couponlist").html("

    暂无代金券

    "); - } - }) -} -//插件代金券续费 -function useCoupon_plugin(code, pid) { - var loadT = layer.msg("提交中,请稍后。", { icon: 16, time: 0, shade: [0.3, "#000"] }); - $.post("/auth?action=create_order_voucher_plugin", { pid: pid, code: code }, function(rdata) { - layer.closeAll(); - layer.msg(rdata.msg); - }) -} -//专业版代金券续费 -function useCoupon(code) { - var loadT = layer.msg("提交中,请稍后。", { icon: 16, time: 0, shade: [0.3, "#000"] }); - $.post("/auth?action=create_order_voucher", { code: code }, function(rdata) { - layer.closeAll(); - layer.msg(rdata.msg); - if (rdata.status === true) { - layer.msg("支付成功!专业版升级中,请勿操作!", { icon: 16, time: 0, shade: [0.3, "#000"] }); - $.get("/system?action=UpdatePro", function(rr) { - show_upVip(); - }).error(function() { - show_upVip(); - }); - } - }) -} - -function show_upVip() { - layer.closeAll(); - layer.msg("恭喜您,升级完成!", { icon: 1 }); - setTimeout(function() { window.location.href = '/'; }, 3000); -} - -//取专业版产品折扣信息 -function get_product_discount() { - var con = '
    \ -
    付款方式
    \ -
    \ -
    \ -
    \ -
    \ -
    \ -
    开通时长
    \ -
    \ -
    \ -
    总计
    \ -
    \ -
    \ -
    微信扫码支付
    \ -
    \ -
    \ - \ -
    ' - $(".libpay-con").html("
    加载中,请稍后
    "); - $.get("/auth?action=get_product_discount_by", function(rdata) { - if (rdata != null) { - var coucon = ''; - var qarr = Object.keys(rdata); - var qlen = qarr.length; - //折扣列表 - for (var i = 0; i < qlen; i++) { - var j = qarr[i]; - var a = rdata[j].price; - var b = rdata[j].sprice; - var c = rdata[j].discount; - coucon += '
  • ' + conver_unit(j) + '' + (c == 1 ? "" : '' + c * 10 + '折') + '
  • '; - } - $(".libpay-con").html(con); - $("#PayCycle").html(''); - $(".pay-btn-group li").click(function() { - $(this).addClass("active").siblings().removeClass("active"); - }); - $(".pay-cycle li").click(function() { - var i = $(this).index(); - $(this).addClass("active").siblings().removeClass("active"); - $(".payment-con > div").eq(i).show().siblings().hide(); - }); - $("#PayCycle .pay-btn-group li").eq(0).click(); - } - }) -} -//单位转换 -function conver_unit(name) { - var unit = ''; - switch (name) { - case "year": - unit = "年"; - break; - case "month": - unit = "个月"; - break; - case "day": - unit = "天"; - break; - case "1": - unit = "1个月"; - break; - case "3": - unit = "3个月"; - break; - case "6": - unit = "6个月"; - break; - case "12": - unit = "1年"; - break; - case "24": - unit = "2年"; - break; - case "36": - unit = "3年"; - break; - case "999": - unit = "永久"; - break; - } - return unit; -} -var wxpayTimeId = 0; - -function getRsCode(pid, price, sprice, cycle) { - $(".sale-price").text(price); - if (price == sprice) { - $(".cost-price").text(sprice + '元').hide(); - } else { - $(".cost-price").text(sprice + '元').show(); - } - $(".pay-wx").html('加载中,请稍后'); - $(".libPay").append('
    '); - $.post('/auth?action=get_buy_code', { pid: pid, cycle: cycle }, function(rdata) { - $(".payloadingmask").remove(); - if (rdata.status === false) { - layer.msg(rdata.msg, { icon: 2 }); - return; - } - $(".pay-wx").html(''); - $(".pay-wx").qrcode(rdata.msg); - clearInterval(wxpayTimeId); - wxpayTimeId = setInterval(function() { - $.post('/auth?action=check_pay_status', { id: pid }, function(rdata) { - if (rdata.status) { - layer.closeAll(); - layer.msg('支付成功!', { icon: 1 }); - clearInterval(wxpayTimeId); - return; - } - }) - }, 3000); - }); -} function getRsCodePro(price, sprice, cycle) { $(".sale-price").text(price); @@ -2416,20 +2228,6 @@ function anTo(pluginName, pid) { Renewinstall(pluginName, pid, 1); } -//登陆宝塔官网帐户 -function loginBT(pluginName, pid) { - p1 = $("#p1").val(); - p2 = $("#p2").val(); - var loadT = layer.msg(lan.config.token_get, { icon: 16, time: 0, shade: [0.3, '#000'] }); - $.post("/ssl?action=GetToken", "username=" + p1 + "&password=" + p2, function(b) { - layer.close(loadT); - layer.msg(b.msg, { icon: b.status ? 1 : 2 }); - if (b.status) { - layer.closeAll(); - Renewinstall(pluginName, pid); - } - }); -} //独立安装 function oneInstall(name, version) { diff --git a/templates/default/soft.html b/templates/default/soft.html index 12672c8aa..716591a50 100755 --- a/templates/default/soft.html +++ b/templates/default/soft.html @@ -27,7 +27,7 @@ 插件 --> - +
    @@ -57,11 +57,11 @@ {% endblock %} \ No newline at end of file diff --git a/views/__init__.py b/views/__init__.py index 898fcd90c..2f1792da6 100644 --- a/views/__init__.py +++ b/views/__init__.py @@ -6,3 +6,4 @@ from files import * from soft import * from config import * from plugins import * +from task import * diff --git a/views/dashboard.py b/views/dashboard.py index f339a486b..c7d82ce06 100644 --- a/views/dashboard.py +++ b/views/dashboard.py @@ -1,40 +1,42 @@ # coding:utf-8 from flask import Flask -from flask import Blueprint,render_template +from flask import Blueprint, render_template from flask import jsonify -import psutil,time - +import psutil +import time dashboard = Blueprint('dashboard', __name__, template_folder='templates') + @dashboard.route("/") def index(): return render_template('default/index.html') + @dashboard.route("getnetwork") def getNetWork(): - #取网络流量信息 - networkIo = psutil.net_io_counters()[:4] - # if not hasattr(web.ctx.session,'otime'): - # web.ctx.session.up = networkIo[0] - # web.ctx.session.down = networkIo[1] - # web.ctx.session.otime = time.time(); - - ntime = time.time(); - networkInfo = {} - networkInfo['upTotal'] = networkIo[0] - networkInfo['downTotal'] = networkIo[1] - # networkInfo['up'] = round(float(networkIo[0] - web.ctx.session.up) / 1024 / (ntime - web.ctx.session.otime),2) - # networkInfo['down'] = round(float(networkIo[1] - web.ctx.session.down) / 1024 / (ntime - web.ctx.session.otime),2) - networkInfo['downPackets'] =networkIo[3] - networkInfo['upPackets'] =networkIo[2] - - # web.ctx.session.up = networkIo[0] - # web.ctx.session.down = networkIo[1] - # web.ctx.session.otime = ntime; - - # networkInfo['cpu'] = self.GetCpuInfo() - # networkInfo['load'] = self.GetLoadAverage(get); - return jsonify(networkInfo) \ No newline at end of file + # 取网络流量信息 + networkIo = psutil.net_io_counters()[:4] + # if not hasattr(web.ctx.session,'otime'): + # web.ctx.session.up = networkIo[0] + # web.ctx.session.down = networkIo[1] + # web.ctx.session.otime = time.time(); + + ntime = time.time() + networkInfo = {} + networkInfo['upTotal'] = networkIo[0] + networkInfo['downTotal'] = networkIo[1] + # networkInfo['up'] = round(float(networkIo[0] - web.ctx.session.up) / 1024 / (ntime - web.ctx.session.otime),2) + # networkInfo['down'] = round(float(networkIo[1] - web.ctx.session.down) / 1024 / (ntime - web.ctx.session.otime),2) + networkInfo['downPackets'] = networkIo[3] + networkInfo['upPackets'] = networkIo[2] + + # web.ctx.session.up = networkIo[0] + # web.ctx.session.down = networkIo[1] + # web.ctx.session.otime = ntime; + + # networkInfo['cpu'] = self.GetCpuInfo() + # networkInfo['load'] = self.GetLoadAverage(get); + return jsonify(networkInfo) diff --git a/views/plugins.py b/views/plugins.py index 79529da28..6e34bce1e 100644 --- a/views/plugins.py +++ b/views/plugins.py @@ -1,6 +1,7 @@ # coding:utf-8 from flask import Blueprint, render_template +from flask import jsonify plugins = Blueprint('plugins', __name__, template_folder='templates') @@ -12,4 +13,4 @@ def index(): @plugins.route("/list") def list(): - pass + return jsonify({"ss": 3}) diff --git a/views/task.py b/views/task.py index f8d82fa5e..3926be998 100644 --- a/views/task.py +++ b/views/task.py @@ -10,3 +10,8 @@ task = Blueprint('task', __name__, template_folder='templates') @task.route("/") def index(): return render_template('default/site.html') + + +@task.route("/count") +def count(): + return "0"