实现gzip

This commit is contained in:
GoEdgeLab
2020-09-29 17:23:06 +08:00
parent ba2bbaff0b
commit 81f2982abc
4 changed files with 35 additions and 30 deletions

View File

@@ -66,12 +66,12 @@ func (this *IndexAction) RunGet(params struct {
} }
func (this *IndexAction) RunPost(params struct { func (this *IndexAction) RunPost(params struct {
WebId int64 WebId int64
GzipId int64 GzipId int64
Level int Level int
MinLength string MinLength string
MaxLength string MaxLength string
CondGroupsJSON []byte CondsJSON []byte
Must *actions.Must Must *actions.Must
}) { }) {
@@ -99,11 +99,11 @@ func (this *IndexAction) RunPost(params struct {
if params.GzipId > 0 { if params.GzipId > 0 {
_, err := this.RPC().HTTPGzipRPC().UpdateHTTPGzip(this.AdminContext(), &pb.UpdateHTTPGzipRequest{ _, err := this.RPC().HTTPGzipRPC().UpdateHTTPGzip(this.AdminContext(), &pb.UpdateHTTPGzipRequest{
GzipId: params.GzipId, GzipId: params.GzipId,
Level: types.Int32(params.Level), Level: types.Int32(params.Level),
MinLength: minLength, MinLength: minLength,
MaxLength: maxLength, MaxLength: maxLength,
CondGroupsJSON: params.CondGroupsJSON, CondsJSON: params.CondsJSON,
}) })
if err != nil { if err != nil {
this.ErrorPage(err) this.ErrorPage(err)
@@ -111,10 +111,10 @@ func (this *IndexAction) RunPost(params struct {
} }
} else { } else {
resp, err := this.RPC().HTTPGzipRPC().CreateHTTPGzip(this.AdminContext(), &pb.CreateHTTPGzipRequest{ resp, err := this.RPC().HTTPGzipRPC().CreateHTTPGzip(this.AdminContext(), &pb.CreateHTTPGzipRequest{
Level: types.Int32(params.Level), Level: types.Int32(params.Level),
MinLength: minLength, MinLength: minLength,
MaxLength: maxLength, MaxLength: maxLength,
CondGroupsJSON: params.CondGroupsJSON, CondsJSON: params.CondsJSON,
}) })
if err != nil { if err != nil {
this.ErrorPage(err) this.ErrorPage(err)

View File

@@ -5,6 +5,7 @@ Vue.component("http-cond-url-extension", {
let cond = this.vCond let cond = this.vCond
if (cond == null) { if (cond == null) {
cond = { cond = {
isRequest: true,
param: "${requestPathExtension}", param: "${requestPathExtension}",
operator: "in", operator: "in",
value: "[]" value: "[]"
@@ -85,7 +86,7 @@ Vue.component("http-cond-mime-type", {
let cond = this.vCond let cond = this.vCond
if (cond == null) { if (cond == null) {
cond = { cond = {
type: "mime-type", isRequest: false,
param: "${response.contentType}", param: "${response.contentType}",
operator: "mime type", operator: "mime type",
value: "[]" value: "[]"
@@ -144,7 +145,7 @@ Vue.component("http-cond-mime-type", {
</div> </div>
<div class="ui fields inline" v-if="isAdding"> <div class="ui fields inline" v-if="isAdding">
<div class="ui field"> <div class="ui field">
<input type="text" size="16" maxlength="100" v-model="addingMimeType" ref="addingMimeType" placeholder="xxxxx/xxx" @keyup.enter="confirmAdding" @keypress.enter.prevent="1" /> <input type="text" size="16" maxlength="100" v-model="addingMimeType" ref="addingMimeType" placeholder="类似于image/png" @keyup.enter="confirmAdding" @keypress.enter.prevent="1" />
</div> </div>
<div class="ui field"> <div class="ui field">
<button class="ui button tiny" type="button" @click.prevent="confirmAdding">确认</button> <button class="ui button tiny" type="button" @click.prevent="confirmAdding">确认</button>

View File

@@ -8,7 +8,7 @@ Vue.component("http-gzip-box", {
level: 0, level: 0,
minLength: null, minLength: null,
maxLength: null, maxLength: null,
condGroups: [] conds: null
} }
} }
@@ -69,7 +69,7 @@ Vue.component("http-gzip-box", {
</td> </td>
</tr> </tr>
</tbody> </tbody>
<http-request-conds-tbody v-show="isOn() && advancedVisible" :v-cond-groups="gzip.condGroups"></http-request-conds-tbody> <http-request-conds-tbody v-show="isOn() && advancedVisible" :v-conds="gzip.conds"></http-request-conds-tbody>
</table> </table>
</div>` </div>`
}) })

View File

@@ -1,12 +1,16 @@
Vue.component("http-request-conds-tbody", { Vue.component("http-request-conds-tbody", {
props: ["v-cond-groups"], props: ["v-conds"],
data: function () { data: function () {
let groups = this.vCondGroups let conds = this.vConds
if (groups == null) { if (conds == null) {
groups = [] conds = {
isOn: true,
connector: "or",
groups: []
}
} }
return { return {
groups: groups, conds: conds,
components: window.REQUEST_COND_COMPONENTS components: window.REQUEST_COND_COMPONENTS
} }
}, },
@@ -16,7 +20,7 @@ Vue.component("http-request-conds-tbody", {
teaweb.popup("/servers/server/settings/conds/addGroupPopup", { teaweb.popup("/servers/server/settings/conds/addGroupPopup", {
height: "30em", height: "30em",
callback: function (resp) { callback: function (resp) {
that.groups.push(resp.data.group) that.conds.groups.push(resp.data.group)
} }
}) })
}, },
@@ -26,14 +30,14 @@ Vue.component("http-request-conds-tbody", {
teaweb.popup("/servers/server/settings/conds/addGroupPopup", { teaweb.popup("/servers/server/settings/conds/addGroupPopup", {
height: "30em", height: "30em",
callback: function (resp) { callback: function (resp) {
Vue.set(that.groups, groupIndex, resp.data.group) Vue.set(that.conds.groups, groupIndex, resp.data.group)
} }
}) })
}, },
removeGroup: function (groupIndex) { removeGroup: function (groupIndex) {
let that = this let that = this
teaweb.confirm("确定要删除这一组条件吗?", function () { teaweb.confirm("确定要删除这一组条件吗?", function () {
that.groups.$remove(groupIndex) that.conds.groups.$remove(groupIndex)
}) })
}, },
typeName: function (cond) { typeName: function (cond) {
@@ -50,11 +54,11 @@ Vue.component("http-request-conds-tbody", {
<tr> <tr>
<td>匹配条件</td> <td>匹配条件</td>
<td> <td>
<input type="hidden" name="condGroupsJSON" :value="JSON.stringify(groups)"/> <input type="hidden" name="condsJSON" :value="JSON.stringify(conds)"/>
<div class="margin"></div> <div class="margin"></div>
<div v-if="groups.length > 0"> <div v-if="conds.groups.length > 0">
<table class="ui table"> <table class="ui table">
<tr v-for="(group, groupIndex) in groups"> <tr v-for="(group, groupIndex) in conds.groups">
<td style="background: white"> <td style="background: white">
<var v-for="(cond, index) in group.conds" style="font-style: normal;display: inline-block; margin-bottom:0.5em"> <var v-for="(cond, index) in group.conds" style="font-style: normal;display: inline-block; margin-bottom:0.5em">
<span class="ui label tiny"> <span class="ui label tiny">