{"action":"created","issue":{"url":"https://api.github.com/repos/fex-team/ueditor/issues/2561","repository_url":"https://api.github.com/repos/fex-team/ueditor","labels_url":"https://api.github.com/repos/fex-team/ueditor/issues/2561/labels{/name}","comments_url":"https://api.github.com/repos/fex-team/ueditor/issues/2561/comments","events_url":"https://api.github.com/repos/fex-team/ueditor/issues/2561/events","html_url":"https://github.com/fex-team/ueditor/issues/2561","id":130706794,"number":2561,"title":"golang-UE初探","user":{"login":"3xxx","id":10678867,"avatar_url":"https://avatars.githubusercontent.com/u/10678867?v=3","gravatar_id":"","url":"https://api.github.com/users/3xxx","html_url":"https://github.com/3xxx","followers_url":"https://api.github.com/users/3xxx/followers","following_url":"https://api.github.com/users/3xxx/following{/other_user}","gists_url":"https://api.github.com/users/3xxx/gists{/gist_id}","starred_url":"https://api.github.com/users/3xxx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/3xxx/subscriptions","organizations_url":"https://api.github.com/users/3xxx/orgs","repos_url":"https://api.github.com/users/3xxx/repos","events_url":"https://api.github.com/users/3xxx/events{/privacy}","received_events_url":"https://api.github.com/users/3xxx/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-02-02T14:58:30Z","updated_at":"2016-02-03T03:20:46Z","closed_at":null,"body":"1、不同页面实现不同请求：addcategory页面的ue采用添加图片到category目录中，addtopic页面的ue采用添加图片到topic目录下。\r\n用serverparam在请求的时候带上参数，然后在controllers中根据这个参数判断不同页面。\r\nview中：\r\n```\r\n/* 2.传入参数表,添加到已有参数表里 */\r\nue.ready(function() {\r\n    ue.execCommand('serverparam', {\r\n        'key': 'value'\r\n    });\r\n});\r\n```\r\ncontrollers中（beego）：\r\n```\r\nfunc (c *UeditorController) ControllerUE() {\r\n\top := c.Input().Get(\"action\")\r\n\tkey := c.Input().Get(\"key\") //这里进行判断各个页面，如果是addtopic，如果是addcategory\r\n\t\r\nif key=?? {//加入key=？？则将图片存入……\r\n        switch op {\r\n\tcase \"config\":\r\n\t\tfile, err := os.Open(\"conf/config.json\")\r\n\t\tif err != nil {\r\n\t\t\tlog.Fatal(err)\r\n\t\t\tos.Exit(1)\r\n\t\t}\r\n\t\tdefer file.Close()\r\n\t\tfd, err := ioutil.ReadAll(file)\r\n\t\tsrc := string(fd)\r\n\t\tre, _ := regexp.Compile(\"\\\\/\\\\*[\\\\S\\\\s]+?\\\\*\\\\/\") //参考php的$CONFIG = json_decode(preg_replace(\"/\\/\\*[\\s\\S]+?\\*\\//\", \"\", file_get_contents(\"config.json\")), true);\r\n\t\tsrc = re.ReplaceAllString(src, \"\")\r\n\t\ttt := []byte(src)\r\n\r\n\t\tvar r interface{}\r\n\t\tjson.Unmarshal(tt, &r) //这个byte要解码\r\n\t\tc.Data[\"json\"] = r\r\n\t\tc.ServeJson()\r\n\tcase \"uploadimage\", \"uploadscrawl\", \"uploadfile\", \"uploadvideo\":\r\n                number := c.Input().Get(\"number\")\r\n\t\tname := c.Input().Get(\"name\")\r\n\t\terr := os.MkdirAll(\".\\\\attachment\\\\\"+number+name, 0777) \r\n\t\tif err != nil {\r\n\t\t\tbeego.Error(err)\r\n\t\t}\r\n\t\t_, h, err := c.GetFile(\"upfile\")\r\n\t\tif err != nil {\r\n\t\t\tbeego.Error(err)\r\n\t\t}\r\n\t\tpath1 := \".\\\\attachment\\\\\" + number + name + \"\\\\\" + h.Filename\r\n\t\terr = c.SaveToFile(\"upfile\", path1) \r\n\t\tif err != nil {\r\n\t\t\tbeego.Error(err)\r\n\t\t}\r\n\t\tfilesize, _ = FileSize(path1)\r\n\t\tfilesize = filesize / 1000.0\r\n\t\tc.Data[\"json\"] = map[string]interface{}{\"state\": \"SUCCESS\", \"url\": \"/attachment/\" + number + name + \"/\" + h.Filename, \"title\": h.Filename, \"original\": h.Filename}\r\n\t\tc.ServeJson()\r\n\tcase \"listimage\":\r\n\r\n```"},"comment":{"url":"https://api.github.com/repos/fex-team/ueditor/issues/comments/178979587","html_url":"https://github.com/fex-team/ueditor/issues/2561#issuecomment-178979587","issue_url":"https://api.github.com/repos/fex-team/ueditor/issues/2561","id":178979587,"user":{"login":"Phinome","id":1940194,"avatar_url":"https://avatars.githubusercontent.com/u/1940194?v=3","gravatar_id":"","url":"https://api.github.com/users/Phinome","html_url":"https://github.com/Phinome","followers_url":"https://api.github.com/users/Phinome/followers","following_url":"https://api.github.com/users/Phinome/following{/other_user}","gists_url":"https://api.github.com/users/Phinome/gists{/gist_id}","starred_url":"https://api.github.com/users/Phinome/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Phinome/subscriptions","organizations_url":"https://api.github.com/users/Phinome/orgs","repos_url":"https://api.github.com/users/Phinome/repos","events_url":"https://api.github.com/users/Phinome/events{/privacy}","received_events_url":"https://api.github.com/users/Phinome/received_events","type":"User","site_admin":false},"created_at":"2016-02-03T03:20:46Z","updated_at":"2016-02-03T03:20:46Z","body":"赞，有产出了，我帮你放到 wiki 上。当然署你的名。"}}