From 514709548cf2fb8a6c933f44948cfc1c05e44d8b Mon Sep 17 00:00:00 2001 From: LiYang Date: Mon, 1 Aug 2016 11:20:37 +0800 Subject: [PATCH] =?UTF-8?q?bootbox=E4=BB=A3=E6=9B=BFalert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/admin/package.json | 3 + .../admin/src/components/account/editUser.vue | 5 +- .../admin/src/components/problem/problem.vue | 3 + frontend/admin/src/components/utils/alert.vue | 113 ------------------ frontend/admin/src/locales.js | 4 + frontend/admin/src/main.js | 46 +++++-- 6 files changed, 47 insertions(+), 127 deletions(-) delete mode 100644 frontend/admin/src/components/utils/alert.vue diff --git a/frontend/admin/package.json b/frontend/admin/package.json index 684d7881..b66b9117 100644 --- a/frontend/admin/package.json +++ b/frontend/admin/package.json @@ -20,10 +20,13 @@ "babel-preset-es2015": "^6.0.0", "babel-preset-stage-2": "^6.0.0", "babel-register": "^6.0.0", + "bootbox": "^4.4.0", + "bootstrap-modal": "^2.0.0", "codemirror": "^5.17.0", "connect-history-api-fallback": "^1.1.0", "css-loader": "^0.23.0", "eventsource-polyfill": "^0.9.6", + "expose-loader": "^0.7.1", "express": "^4.13.3", "extract-text-webpack-plugin": "^1.0.1", "file-loader": "^0.8.4", diff --git a/frontend/admin/src/components/account/editUser.vue b/frontend/admin/src/components/account/editUser.vue index 1b74a8ab..7c1a3777 100644 --- a/frontend/admin/src/components/account/editUser.vue +++ b/frontend/admin/src/components/account/editUser.vue @@ -126,10 +126,7 @@ this.request({ url: "/api/admin/user/", method: "PUT", - data: data, - success: (data)=> { - alert("更新成功"); - } + data: data }) } }, diff --git a/frontend/admin/src/components/problem/problem.vue b/frontend/admin/src/components/problem/problem.vue index 4af4d227..3fbb98bf 100644 --- a/frontend/admin/src/components/problem/problem.vue +++ b/frontend/admin/src/components/problem/problem.vue @@ -14,6 +14,9 @@ components: { simditor, uploader + }, + ready() { + alert("111111"); } }) \ No newline at end of file diff --git a/frontend/admin/src/components/utils/alert.vue b/frontend/admin/src/components/utils/alert.vue deleted file mode 100644 index 2ad7fd1a..00000000 --- a/frontend/admin/src/components/utils/alert.vue +++ /dev/null @@ -1,113 +0,0 @@ - - - - - \ No newline at end of file diff --git a/frontend/admin/src/locales.js b/frontend/admin/src/locales.js index f642cf5e..e68db77c 100644 --- a/frontend/admin/src/locales.js +++ b/frontend/admin/src/locales.js @@ -1,5 +1,9 @@ export default { "zh-cn": { + alert: { + alert: "提示", + OK: "确定" + }, nav: { UserManagement: "用户管理" }, diff --git a/frontend/admin/src/main.js b/frontend/admin/src/main.js index 76632dc5..15d5d8a4 100644 --- a/frontend/admin/src/main.js +++ b/frontend/admin/src/main.js @@ -8,8 +8,20 @@ import locale from "./locales" import userList from "./components/account/userList.vue" import editUser from "./components/account/editUser.vue" import problem from "./components/problem/problem.vue" -import uploader from "./components/utils/uploader.vue" +import "expose?$!expose?jQuery!jquery" +import "bootstrap" +import bootbox from "bootbox" +Vue.use(VueI18n); + + +// todo: strore lang config in localstorage +var lang = "zh-cn"; +Vue.config.lang = lang; + +Object.keys(locale).forEach(function (lang) { + Vue.locale(lang, locale[lang]) +}); var request = { install: function (Vue, options) { @@ -29,7 +41,7 @@ var request = { option.error(request) } else { - alert("请求失败"); + alert(locale[lang].request.error); } }; request.onload = function () { @@ -44,7 +56,12 @@ var request = { catch (err) { request.onerror(); } - option.success(data); + if(option.success) { + option.success(data); + } + else { + alert(locale[lang].request.succeeded); + } } else { request.onerror(); @@ -66,13 +83,6 @@ var request = { Vue.use(request); Vue.use(VueRouter); -Vue.use(VueI18n); - -Vue.config.lang = "zh-cn"; - -Object.keys(locale).forEach(function (lang) { - Vue.locale(lang, locale[lang]) -}); var router = new VueRouter(); @@ -92,8 +102,24 @@ router.map({ } }); +// hide loading document.getElementsByClassName("cssload-battery")[0].style.display = "none"; +// override window.alert +function bootboxAlert(content) { + bootbox.dialog({ + message: content, + title: locale[lang].alert.alert, + buttons: { + main: { + label: locale[lang].alert.OK, + className: "btn-primary" + } + } + }) +} +window.alert = bootboxAlert; + router.redirect({"/user": "/user/1"}); router.start(App, '#app');