This commit is contained in:
parent
87d2f7a134
commit
71de834e60
12
main.go
12
main.go
|
@ -111,6 +111,17 @@ func loginHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
glog.Infof("Created a HTTP session [%s] for user [%s]", httpSession.Values["id"].(string), args.Username)
|
glog.Infof("Created a HTTP session [%s] for user [%s]", httpSession.Values["id"].(string), args.Username)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 退出(登出).
|
||||||
|
func logoutHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
|
data := map[string]interface{}{"succ": true}
|
||||||
|
defer util.RetJSON(w, r, data)
|
||||||
|
|
||||||
|
httpSession, _ := session.HTTPSession.Get(r, "wide-session")
|
||||||
|
|
||||||
|
httpSession.Options.MaxAge = 0
|
||||||
|
httpSession.Save(r, w)
|
||||||
|
}
|
||||||
|
|
||||||
// Wide 首页.
|
// Wide 首页.
|
||||||
func indexHandler(w http.ResponseWriter, r *http.Request) {
|
func indexHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
i18n.Load()
|
i18n.Load()
|
||||||
|
@ -167,6 +178,7 @@ func main() {
|
||||||
|
|
||||||
// IDE
|
// IDE
|
||||||
http.HandleFunc("/login", handlerWrapper(loginHandler))
|
http.HandleFunc("/login", handlerWrapper(loginHandler))
|
||||||
|
http.HandleFunc("/logout", handlerWrapper(logoutHandler))
|
||||||
http.HandleFunc("/", handlerWrapper(indexHandler))
|
http.HandleFunc("/", handlerWrapper(indexHandler))
|
||||||
|
|
||||||
// 静态资源
|
// 静态资源
|
||||||
|
|
|
@ -179,7 +179,6 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: 会话校验
|
|
||||||
sid := args["sid"].(string)
|
sid := args["sid"].(string)
|
||||||
|
|
||||||
filePath := args["file"].(string)
|
filePath := args["file"].(string)
|
||||||
|
|
|
@ -400,7 +400,6 @@ var wide = {
|
||||||
this.fmt(editors.getCurrentPath(), wide.curEditor);
|
this.fmt(editors.getCurrentPath(), wide.curEditor);
|
||||||
},
|
},
|
||||||
saveAllFiles: function () {
|
saveAllFiles: function () {
|
||||||
// TODO: 需要全部保存的接口
|
|
||||||
if ($(".menu li.save-all").hasClass("disabled")) {
|
if ($(".menu li.save-all").hasClass("disabled")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -409,9 +408,6 @@ var wide = {
|
||||||
this.fmt(tree.fileTree.getNodeByTId(editors.data[i].id).path, editors.data[i].editor);
|
this.fmt(tree.fileTree.getNodeByTId(editors.data[i].id).path, editors.data[i].editor);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
closeFile: function () {
|
|
||||||
// TODO: close file
|
|
||||||
},
|
|
||||||
closeAllFiles: function () {
|
closeAllFiles: function () {
|
||||||
if ($(".menu li.close-all").hasClass("disabled")) {
|
if ($(".menu li.close-all").hasClass("disabled")) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -427,7 +423,19 @@ var wide = {
|
||||||
menu.disabled(['save-all', 'close-all', 'run', 'go-get', 'go-install']);
|
menu.disabled(['save-all', 'close-all', 'run', 'go-get', 'go-install']);
|
||||||
},
|
},
|
||||||
exit: function () {
|
exit: function () {
|
||||||
// TODO: exit
|
var request = newWideRequest();
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
type: 'POST',
|
||||||
|
url: '/logout',
|
||||||
|
data: JSON.stringify(request),
|
||||||
|
dataType: "json",
|
||||||
|
success: function (data) {
|
||||||
|
if (data.succ) {
|
||||||
|
window.location.href = "/login";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
stop: function () {
|
stop: function () {
|
||||||
if ($(".toolbars .ico-buildrun").length === 1) {
|
if ($(".toolbars .ico-buildrun").length === 1) {
|
||||||
|
|
Loading…
Reference in New Issue