Commit 1a7f4e9e authored by 铭飞's avatar 铭飞
Browse files

!68 修改预览主页

Merge pull request !68 from TanWH/4.6.3
parents 97dd8460 28cd1630
Showing with 6 additions and 34 deletions
+6 -34
......@@ -772,28 +772,12 @@ public class GeneraterAction extends BaseAction {
* @return
*/
@RequestMapping("/{position}/viewIndex")
public void viewIndex(HttpServletRequest request, @PathVariable String position, HttpServletResponse response) {
//获取应用实体信息
AppEntity app = this.getApp(request);
public String viewIndex(HttpServletRequest request, @PathVariable String position, HttpServletResponse response) {
AppEntity app = BasicUtil.getApp();
//组织主页预览地址
String indexPosition = app.getAppHostUrl() + "/" + IParserRegexConstant.HTML_SAVE_PATH + "/" + app.getAppId() + "/" + position;
//请求更新后的主页,如果返回200就是是更新成功,可以访问,返回404,就是 更新不成功或者是没有更新主页,返回false
URL url;
HttpURLConnection huc;
try {
url = new URL(indexPosition);
huc = (HttpURLConnection) url.openConnection();
System.out.println(huc.getResponseCode());
huc.connect();
if(huc.getResponseCode()!=200){
this.outJson(response, false);
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
this.outJson(response, true, indexPosition);
String indexPosition = app.getAppHostUrl() + File.separator + IParserRegexConstant.HTML_SAVE_PATH + File.separator + app.getAppId() + File.separator + position;
return "redirect:" + indexPosition;
}
}
\ No newline at end of file
......@@ -106,19 +106,7 @@
//点击预览时,进行预览
$("#viewIndex").click(function(){
var position =$("input[name='position']").val();
var urlStr = '${managerPath}/cms/generate/'+position+'/viewIndex.do';
$.ajax({
type: "get",
url: urlStr,
success : function(msg) {//返回数据根据结果进行相应的处理
if(msg.result){
var url=msg.resultMsg;
window.open(url,"_blank");
}else{
<@ms.notify msg="请先生成主页,再次访问" type="warning"/>
}
}
})
window.open("${managerPath}/cms/generate/"+position+"/viewIndex.do");
});
</script>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment