From 94c56fc39f0e6d831a91517549fdf9278d54b06d Mon Sep 17 00:00:00 2001 From: LiYang Date: Sun, 7 Aug 2016 22:23:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E6=B5=8B=E8=AF=95=E7=94=A8?= =?UTF-8?q?=E4=BE=8B=E4=B8=8A=E4=BC=A0=E4=B8=8B=E8=BD=BD=E5=9F=BA=E7=A1=80?= =?UTF-8?q?=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- account/middleware.py | 1 + .../admin/src/components/problem/problem.vue | 6 +- .../src/components/problem/testCaseMgnt.vue | 68 +++++++++++++++++++ .../admin/src/components/utils/uploader.vue | 44 ++++++------ frontend/admin/src/locales.js | 12 +++- frontend/admin/src/main.js | 15 ++-- frontend/admin/src/utils/cookie.js | 10 +++ 7 files changed, 122 insertions(+), 34 deletions(-) create mode 100644 frontend/admin/src/components/problem/testCaseMgnt.vue create mode 100644 frontend/admin/src/utils/cookie.js diff --git a/account/middleware.py b/account/middleware.py index 8d024c49..d5f58ef1 100644 --- a/account/middleware.py +++ b/account/middleware.py @@ -5,6 +5,7 @@ import urllib from django.http import HttpResponse from django.utils.translation import ugettext as _ +from django.contrib import auth from utils.shortcuts import redirect_to_login from .models import AdminType diff --git a/frontend/admin/src/components/problem/problem.vue b/frontend/admin/src/components/problem/problem.vue index 3d1307b4..27c2635e 100644 --- a/frontend/admin/src/components/problem/problem.vue +++ b/frontend/admin/src/components/problem/problem.vue @@ -1,15 +1,15 @@ \ No newline at end of file diff --git a/frontend/admin/src/components/problem/testCaseMgnt.vue b/frontend/admin/src/components/problem/testCaseMgnt.vue new file mode 100644 index 00000000..431975d5 --- /dev/null +++ b/frontend/admin/src/components/problem/testCaseMgnt.vue @@ -0,0 +1,68 @@ + + + \ No newline at end of file diff --git a/frontend/admin/src/components/utils/uploader.vue b/frontend/admin/src/components/utils/uploader.vue index f0ee62e4..5354da78 100644 --- a/frontend/admin/src/components/utils/uploader.vue +++ b/frontend/admin/src/components/utils/uploader.vue @@ -1,48 +1,54 @@ diff --git a/frontend/admin/src/locales.js b/frontend/admin/src/locales.js index b05cab00..ec830104 100644 --- a/frontend/admin/src/locales.js +++ b/frontend/admin/src/locales.js @@ -57,7 +57,10 @@ export default { addSample: "添加样例", fold: "折叠", show: "展开", - deleteThisSample: "删除这组样例?" + deleteThisSample: "删除这组样例?", + testCase: "测试用例", + uploadProgress: "上传进度", + }, adminUtils: { search: "搜索", @@ -82,6 +85,13 @@ export default { delete: "删除", input: "输入", output: "输出", + download: "下载", + upload: "上传", + + score: "分数", + help: "帮助", + + chooseFile: "选择文件", unsupportedBrowserWarningMsg: "当前网页 不支持 你正在使用的浏览器, 为了正常的访问,请到 升级你的浏览器" } diff --git a/frontend/admin/src/main.js b/frontend/admin/src/main.js index 90221b75..f0c06755 100644 --- a/frontend/admin/src/main.js +++ b/frontend/admin/src/main.js @@ -8,6 +8,7 @@ import "bootstrap" import bootbox from "bootbox" import locale from "./locales" +import getCookie from "./utils/cookie" import userList from "./components/account/userList.vue" import editUser from "./components/account/editUser.vue" @@ -32,14 +33,6 @@ Object.keys(locale).forEach(function (lang) { // custom ajax Vue.use({ install: function (Vue, options) { - function getCookie(name) { - var value = "; " + document.cookie; - var parts = value.split("; " + name + "="); - if (parts.length == 2) { - return parts.pop().split(";").shift(); - } - } - Vue.prototype.request = function (option) { var request = new XMLHttpRequest(); request.open(option.method, option.url, true); @@ -74,10 +67,10 @@ Vue.use({ request.onerror(); } }; - request.setRequestHeader('x-requested-with', 'XMLHttpRequest'); - if (option.method.toLowerCase() == 'post' || option.method.toLowerCase() == 'put') { + request.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); + if (option.method.toLowerCase() != 'get') { request.setRequestHeader('Content-Type', 'application/json; charset=UTF-8'); - request.setRequestHeader('x-csrftoken', getCookie('csrftoken')); + request.setRequestHeader('X-CSRFToken', getCookie('csrftoken')); request.send(JSON.stringify(option.data)); } else { diff --git a/frontend/admin/src/utils/cookie.js b/frontend/admin/src/utils/cookie.js new file mode 100644 index 00000000..bcae3066 --- /dev/null +++ b/frontend/admin/src/utils/cookie.js @@ -0,0 +1,10 @@ +function getCookie(name) { + var value = "; " + document.cookie; + var parts = value.split("; " + name + "="); + if (parts.length == 2) { + return parts.pop().split(";").shift(); + } +} + + +module.exports = getCookie; \ No newline at end of file