mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-04 21:50:28 +08:00
特殊页面可以直接使用HTML
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
"github.com/iwind/TeaGo/types"
|
||||
)
|
||||
@@ -19,12 +20,18 @@ func (this *CreatePopupAction) Init() {
|
||||
}
|
||||
|
||||
func (this *CreatePopupAction) RunGet(params struct{}) {
|
||||
this.Data["bodyTypes"] = shared.FindAllBodyTypes()
|
||||
|
||||
this.Show()
|
||||
}
|
||||
|
||||
func (this *CreatePopupAction) RunPost(params struct {
|
||||
Status string
|
||||
BodyType string
|
||||
|
||||
URL string `alias:"url"`
|
||||
Body string
|
||||
|
||||
NewStatus int
|
||||
Must *actions.Must
|
||||
}) {
|
||||
@@ -32,13 +39,24 @@ func (this *CreatePopupAction) RunPost(params struct {
|
||||
|
||||
params.Must.
|
||||
Field("status", params.Status).
|
||||
Require("请输入响应状态码").
|
||||
Require("请输入响应状态码")
|
||||
|
||||
switch params.BodyType {
|
||||
case shared.BodyTypeURL:
|
||||
params.Must.
|
||||
Field("url", params.URL).
|
||||
Require("请输入要显示的URL")
|
||||
case shared.BodyTypeHTML:
|
||||
params.Must.
|
||||
Field("body", params.Body).
|
||||
Require("请输入要显示的HTML内容")
|
||||
}
|
||||
|
||||
createResp, err := this.RPC().HTTPPageRPC().CreateHTTPPage(this.AdminContext(), &pb.CreateHTTPPageRequest{
|
||||
StatusList: []string{params.Status},
|
||||
BodyType: params.BodyType,
|
||||
Url: params.URL,
|
||||
Body: params.Body,
|
||||
NewStatus: types.Int32(params.NewStatus),
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs/shared"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
"github.com/iwind/TeaGo/types"
|
||||
)
|
||||
@@ -21,6 +22,8 @@ func (this *UpdatePopupAction) Init() {
|
||||
func (this *UpdatePopupAction) RunGet(params struct {
|
||||
PageId int64
|
||||
}) {
|
||||
this.Data["bodyTypes"] = shared.FindAllBodyTypes()
|
||||
|
||||
configResp, err := this.RPC().HTTPPageRPC().FindEnabledHTTPPageConfig(this.AdminContext(), &pb.FindEnabledHTTPPageConfigRequest{PageId: params.PageId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
@@ -42,7 +45,11 @@ func (this *UpdatePopupAction) RunPost(params struct {
|
||||
PageId int64
|
||||
|
||||
Status string
|
||||
|
||||
BodyType string
|
||||
URL string `alias:"url"`
|
||||
Body string
|
||||
|
||||
NewStatus int
|
||||
|
||||
Must *actions.Must
|
||||
@@ -52,14 +59,25 @@ func (this *UpdatePopupAction) RunPost(params struct {
|
||||
|
||||
params.Must.
|
||||
Field("status", params.Status).
|
||||
Require("请输入响应状态码").
|
||||
Require("请输入响应状态码")
|
||||
|
||||
switch params.BodyType {
|
||||
case shared.BodyTypeURL:
|
||||
params.Must.
|
||||
Field("url", params.URL).
|
||||
Require("请输入要显示的URL")
|
||||
case shared.BodyTypeHTML:
|
||||
params.Must.
|
||||
Field("body", params.Body).
|
||||
Require("请输入要显示的HTML内容")
|
||||
}
|
||||
|
||||
_, err := this.RPC().HTTPPageRPC().UpdateHTTPPage(this.AdminContext(), &pb.UpdateHTTPPageRequest{
|
||||
PageId: params.PageId,
|
||||
StatusList: []string{params.Status},
|
||||
BodyType: params.BodyType,
|
||||
Url: params.URL,
|
||||
Body: params.Body,
|
||||
NewStatus: types.Int32(params.NewStatus),
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
@@ -8,10 +8,18 @@ Vue.component("http-pages-and-shutdown-box", {
|
||||
let shutdownConfig = {
|
||||
isPrior: false,
|
||||
isOn: false,
|
||||
bodyType: "url",
|
||||
url: "",
|
||||
body: "",
|
||||
status: 0
|
||||
}
|
||||
if (this.vShutdownConfig != null) {
|
||||
if (this.vShutdownConfig.body == null) {
|
||||
this.vShutdownConfig.body = ""
|
||||
}
|
||||
if (this.vShutdownConfig.bodyType == null) {
|
||||
this.vShutdownConfig.bodyType = "url"
|
||||
}
|
||||
shutdownConfig = this.vShutdownConfig
|
||||
}
|
||||
|
||||
@@ -40,7 +48,7 @@ Vue.component("http-pages-and-shutdown-box", {
|
||||
addPage: function () {
|
||||
let that = this
|
||||
teaweb.popup("/servers/server/settings/pages/createPopup", {
|
||||
height: "22em",
|
||||
height: "26em",
|
||||
callback: function (resp) {
|
||||
that.pages.push(resp.data.page)
|
||||
}
|
||||
@@ -49,7 +57,7 @@ Vue.component("http-pages-and-shutdown-box", {
|
||||
updatePage: function (pageIndex, pageId) {
|
||||
let that = this
|
||||
teaweb.popup("/servers/server/settings/pages/updatePopup?pageId=" + pageId, {
|
||||
height: "22em",
|
||||
height: "26em",
|
||||
callback: function (resp) {
|
||||
Vue.set(that.pages, pageIndex, resp.data.page)
|
||||
}
|
||||
@@ -60,6 +68,23 @@ Vue.component("http-pages-and-shutdown-box", {
|
||||
teaweb.confirm("确定要移除此页面吗?", function () {
|
||||
that.pages.$remove(pageIndex)
|
||||
})
|
||||
},
|
||||
addShutdownHTMLTemplate: function () {
|
||||
this.shutdownConfig.body = `<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
\t<title>升级中</title>
|
||||
\t<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h3>网站升级中</h3>
|
||||
<p>为了给您提供更好的服务,我们正在升级网站,请稍后重新访问。</p>
|
||||
|
||||
<footer>Powered by GoEdge.</footer>
|
||||
|
||||
</body>
|
||||
</html>`
|
||||
}
|
||||
},
|
||||
template: `<div>
|
||||
@@ -71,7 +96,7 @@ Vue.component("http-pages-and-shutdown-box", {
|
||||
<td>
|
||||
<div v-if="pages.length > 0">
|
||||
<div class="ui label small basic" v-for="(page,index) in pages">
|
||||
{{page.status}} -> {{page.url}} <a href="" title="修改" @click.prevent="updatePage(index, page.id)"><i class="icon pencil small"></i></a> <a href="" title="删除" @click.prevent="removePage(index)"><i class="icon remove"></i></a>
|
||||
{{page.status}} -> <span v-if="page.bodyType == 'url'">{{page.url}}</span><span v-if="page.bodyType == 'html'">[HTML内容]</span> <a href="" title="修改" @click.prevent="updatePage(index, page.id)"><i class="icon pencil small"></i></a> <a href="" title="删除" @click.prevent="removePage(index)"><i class="icon remove"></i></a>
|
||||
</div>
|
||||
<div class="ui divider"></div>
|
||||
</div>
|
||||
@@ -100,12 +125,28 @@ Vue.component("http-pages-and-shutdown-box", {
|
||||
</tbody>
|
||||
<tbody v-show="(!vIsLocation || shutdownConfig.isPrior) && shutdownConfig.isOn">
|
||||
<tr>
|
||||
<td class="title">页面URL</td>
|
||||
<td>内容类型 *</td>
|
||||
<td>
|
||||
<select class="ui dropdown auto-width" v-model="shutdownConfig.bodyType">
|
||||
<option value="url">读取URL</option>
|
||||
<option value="html">HTML</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-show="shutdownConfig.bodyType == 'url'">
|
||||
<td class="title">页面URL *</td>
|
||||
<td>
|
||||
<input type="text" v-model="shutdownConfig.url" placeholder="页面文件路径或一个完整URL"/>
|
||||
<p class="comment">页面文件是相对于节点安装目录的页面文件比如pages/40x.html,或者一个完整的URL。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-show="shutdownConfig.bodyType == 'html'">
|
||||
<td>HTML *</td>
|
||||
<td>
|
||||
<textarea name="body" ref="shutdownHTMLBody" v-model="shutdownConfig.body"></textarea>
|
||||
<p class="comment"><a href="" @click.prevent="addShutdownHTMLTemplate">[使用模板]</a>。填写页面的HTML内容,支持请求变量。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>状态码</td>
|
||||
<td><input type="text" size="3" maxlength="3" name="shutdownStatus" style="width:5.2em" placeholder="状态码" v-model="shutdownStatus"/></td>
|
||||
|
||||
@@ -10,12 +10,27 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>内容类型 *</td>
|
||||
<td>
|
||||
<select class="ui dropdown auto-width" name="bodyType" v-model="bodyType">
|
||||
<option v-for="bodyType in bodyTypes" :value="bodyType.code">{{bodyType.name}}</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-show="bodyType == 'url'">
|
||||
<td>URL *</td>
|
||||
<td>
|
||||
<input type="text" name="url" maxlength="500" placeholder="页面文件路径或者完整的URL"/>
|
||||
<p class="comment">页面文件是相对于节点安装目录的页面文件比如web/pages/40x.html,或者一个完整的URL。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-show="bodyType == 'html'">
|
||||
<td>HTML *</td>
|
||||
<td>
|
||||
<textarea name="body" ref="htmlBody"></textarea>
|
||||
<p class="comment"><a href="" @click.prevent="addHTMLTemplate">[使用模板]</a>。填写页面的HTML内容,支持请求变量。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>新状态码</td>
|
||||
<td>
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
Tea.context(function () {
|
||||
this.bodyType = this.bodyTypes[0].code
|
||||
|
||||
this.addHTMLTemplate = function () {
|
||||
this.$refs.htmlBody.value = `<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
\t<title>页面标题</title>
|
||||
\t<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h3>内容标题</h3>
|
||||
<p>内容</p>
|
||||
|
||||
<footer>Powered by GoEdge.</footer>
|
||||
|
||||
</body>
|
||||
</html>`
|
||||
}
|
||||
})
|
||||
@@ -11,12 +11,27 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>内容类型 *</td>
|
||||
<td>
|
||||
<select class="ui dropdown auto-width" name="bodyType" v-model="bodyType">
|
||||
<option v-for="bodyType in bodyTypes" :value="bodyType.code">{{bodyType.name}}</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-show="bodyType == 'url'">
|
||||
<td>URL *</td>
|
||||
<td>
|
||||
<input type="text" name="url" maxlength="500" placeholder="页面文件路径或者完整的URL" v-model="pageConfig.url"/>
|
||||
<p class="comment">页面文件是相对于节点安装目录的页面文件比如web/pages/40x.html,或者一个完整的URL。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-show="bodyType == 'html'">
|
||||
<td>HTML *</td>
|
||||
<td>
|
||||
<textarea name="body" ref="htmlBody" v-model="pageConfig.body"></textarea>
|
||||
<p class="comment"><a href="" @click.prevent="addHTMLTemplate">[使用模板]</a>。填写页面的HTML内容,支持请求变量。</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>新状态码</td>
|
||||
<td>
|
||||
|
||||
@@ -1,8 +1,28 @@
|
||||
Tea.context(function () {
|
||||
this.success = NotifyPopup
|
||||
|
||||
this.bodyType = this.pageConfig.bodyType
|
||||
|
||||
this.newStatus = ""
|
||||
if (this.pageConfig.newStatus > 0) {
|
||||
this.newStatus = this.pageConfig.newStatus
|
||||
}
|
||||
|
||||
this.addHTMLTemplate = function () {
|
||||
this.$refs.htmlBody.value = `<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
\t<title>页面标题</title>
|
||||
\t<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h3>内容标题</h3>
|
||||
<p>内容</p>
|
||||
|
||||
<footer>Powered by GoEdge.</footer>
|
||||
|
||||
</body>
|
||||
</html>`
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user