Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update proxy settings form to support additional parameters #13

Merged
merged 1 commit into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 55 additions & 1 deletion ui/src/components/ProxyEditModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ async function onSubmit(data: WebpCloudProxyEditFormState) {

<template>
<VModal
mount-to-body
ref="modal"
mount-to-body
:width="600"
title="编辑代理"
@close="emit('close')"
Expand Down Expand Up @@ -146,6 +146,60 @@ async function onSubmit(data: WebpCloudProxyEditFormState) {
>
</FormKit>
</FormKit>
<FormKit
help="当代理被禁用时(手动或因为你的配额已用完),你可以指定后续请求处理方式"
:model-value="proxyStats?.data.proxy_operation_on_disabled"
name="proxy_operation_on_disabled"
label="不可用时的处理方式"
type="select"
value="redirect"
:options="[
{
value: 'redirect',
label: '重定向至源图片',
},
{
value: 'deny',
label: '阻止访问,返回 403',
},
{
value: 'placeholder',
label: '占位图',
},
]"
></FormKit>

<FormKit
label="自适应图片大小"
name="proxy_adaptive_resize"
:value="false"
:model-value="proxyStats?.data.proxy_adaptive_resize"
type="checkbox"
></FormKit>

<FormKit
v-if="value.proxy_adaptive_resize"
label="桌面端最大宽度"
help="单位为像素(px)"
name="proxy_adaptive_resize_desktop_width"
:value="1600"
:model-value="proxyStats?.data.proxy_adaptive_resize_desktop_width"
type="number"
number
validation="required"
></FormKit>

<FormKit
v-if="value.proxy_adaptive_resize"
label="移动端最大宽度"
help="单位为像素(px)"
name="proxy_adaptive_resize_mobile_width"
:value="800"
:model-value="proxyStats?.data.proxy_adaptive_resize_mobile_width"
type="number"
number
validation="required"
></FormKit>
<FormKit type="hidden" name="proxy_enabled" :value="true"></FormKit>
</FormKit>
<template #footer>
Expand Down
9 changes: 8 additions & 1 deletion ui/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export interface WebpCloudProxyStats {
proxy_cache_size: number;
proxy_cache_size_limit: number;
proxy_enabled: boolean;
proxy_operation_on_disabled: string;
proxy_operation_on_disabled: "redirect" | "deny" | "placeholder";
proxy_created_at: string;
proxy_enable_extra_params: boolean;
proxy_visual_effects: any[];
Expand All @@ -63,6 +63,9 @@ export interface WebpCloudProxyStats {
proxy_daily_bytes_sent: ProxyDailyBytesSent[];
proxy_last_logs: any[];
proxy_custom_domain: any[];
proxy_adaptive_resize: boolean;
proxy_adaptive_resize_desktop_width: number;
proxy_adaptive_resize_mobile_width: number;
}

export interface ProxyDailyBytesSent {
Expand All @@ -86,6 +89,10 @@ export interface WebpCloudProxyEditFormState {
proxy_cors_header: string;
proxy_allowed_referer: string;
proxy_extra_headers: ProxyExtraHeader[];
proxy_adaptive_resize: boolean;
proxy_adaptive_resize_desktop_width: number;
proxy_adaptive_resize_mobile_width: number;
proxy_operation_on_disabled: "redirect" | "deny" | "placeholder";
}

export interface ProxyExtraHeader {
Expand Down