feat(instance): add proxy creation functionality
- Add createProxy API method to instanceApi - Implement proxy creation form in InstanceDetail view - Add modal for proxy creation with required fields - Include validation for port numbers
This commit is contained in:
@@ -86,7 +86,9 @@ export const instanceApi = {
|
|||||||
getInstanceLogs: (instanceName) =>
|
getInstanceLogs: (instanceName) =>
|
||||||
api.get('/frpcAct/instanceMgr/logs', { params: { instanceName } }),
|
api.get('/frpcAct/instanceMgr/logs', { params: { instanceName } }),
|
||||||
getInstanceProxies: (instanceName) =>
|
getInstanceProxies: (instanceName) =>
|
||||||
api.get('/frpcAct/instanceMgr/proxies', { params: { instanceName } })
|
api.get('/frpcAct/instanceMgr/proxies', { params: { instanceName } }),
|
||||||
|
createProxy: (instanceID, proxyInfo) =>
|
||||||
|
api.post('/frpcAct/proxyMgr/create', { instanceID, proxyInfo })
|
||||||
};
|
};
|
||||||
|
|
||||||
export const logApi = {
|
export const logApi = {
|
||||||
|
|||||||
@@ -117,16 +117,18 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<button type="button" class="cancel-btn" @click="closeEditConfigModal">Cancel</button>
|
<button type="button" class="cancel-btn" @click="closeEditConfigModal">Cancel</button>
|
||||||
<button type="submit" class="submit-btn" :disabled="loading">
|
<button type="submit" class="submit-btn" :disabled="loading">{{ loading ? 'Processing...' : 'Save' }}</button>
|
||||||
{{ loading ? 'Processing...' : 'Save' }}
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="section">
|
<div class="section">
|
||||||
<h3>Proxy List</h3>
|
<h3>Proxy List
|
||||||
|
<button class="common-btn" @click="addProxy">
|
||||||
|
<i class="fas fa-plus"></i> Add Proxy
|
||||||
|
</button>
|
||||||
|
</h3>
|
||||||
<div v-if="proxies.length > 0" class="proxy-list">
|
<div v-if="proxies.length > 0" class="proxy-list">
|
||||||
<div v-for="proxy in proxies" :key="proxy.name" class="proxy-item">
|
<div v-for="proxy in proxies" :key="proxy.name" class="proxy-item">
|
||||||
<div class="proxy-header">
|
<div class="proxy-header">
|
||||||
@@ -148,6 +150,64 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div v-if="showAddProxyModal" class="modal-overlay" @click="closeAddProxyModal">
|
||||||
|
<div class="modal" @click.stop>
|
||||||
|
<h3>Add Proxy</h3>
|
||||||
|
<form @submit.prevent="handleSubmit" class="form">
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Proxy Name</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
v-model="formData.name"
|
||||||
|
required
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Type</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
v-model="formData.type"
|
||||||
|
required
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Local IP</label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
v-model="formData.localIP"
|
||||||
|
required
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Local Port</label>
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
v-model="formData.localPort"
|
||||||
|
required
|
||||||
|
min="0"
|
||||||
|
max="65535"
|
||||||
|
step="1"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Remote Port</label>
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
v-model="formData.remotePort"
|
||||||
|
required
|
||||||
|
min="0"
|
||||||
|
max="65535"
|
||||||
|
step="1"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<div class="form-actions">
|
||||||
|
<button type="button" class="cancel-btn" @click="closeAddProxyModal">Cancel</button>
|
||||||
|
<button type="submit" class="submit-btn" :disabled="loading">{{ loading ? 'Processing...' : 'Submit' }}</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="section">
|
<div class="section">
|
||||||
<h3>Logs</h3>
|
<h3>Logs</h3>
|
||||||
<div class="logs-container">
|
<div class="logs-container">
|
||||||
@@ -184,6 +244,7 @@ export default {
|
|||||||
const proxies = ref([]);
|
const proxies = ref([]);
|
||||||
const logs = ref([]);
|
const logs = ref([]);
|
||||||
const showEditConfigModal = ref(false);
|
const showEditConfigModal = ref(false);
|
||||||
|
const showAddProxyModal = ref(false);
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const formData = ref({
|
const formData = ref({
|
||||||
name: '',
|
name: '',
|
||||||
@@ -277,10 +338,18 @@ export default {
|
|||||||
showEditConfigModal.value = true;
|
showEditConfigModal.value = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const addProxy = () => {
|
||||||
|
showAddProxyModal.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
const closeEditConfigModal = () => {
|
const closeEditConfigModal = () => {
|
||||||
showEditConfigModal.value = false;
|
showEditConfigModal.value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const closeAddProxyModal = () => {
|
||||||
|
showAddProxyModal.value = false;
|
||||||
|
};
|
||||||
|
|
||||||
const handleEditConfiguration = async () => {
|
const handleEditConfiguration = async () => {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
try {
|
try {
|
||||||
@@ -321,6 +390,7 @@ export default {
|
|||||||
|
|
||||||
showNotification('Configuration saved successfully', 'success');
|
showNotification('Configuration saved successfully', 'success');
|
||||||
closeEditConfigModal();
|
closeEditConfigModal();
|
||||||
|
closeAddProxyModal();
|
||||||
// 重新加载配置
|
// 重新加载配置
|
||||||
instanceName.value = formData.value.name;
|
instanceName.value = formData.value.name;
|
||||||
await loadInstanceConfig();
|
await loadInstanceConfig();
|
||||||
@@ -331,6 +401,29 @@ export default {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleSubmit = async () => {
|
||||||
|
loading.value = true;
|
||||||
|
try {
|
||||||
|
const proxyInfo = {
|
||||||
|
name: formData.value.name,
|
||||||
|
type: formData.value.type,
|
||||||
|
localIP: formData.value.localIP,
|
||||||
|
localPort: formData.value.localPort.toString(),
|
||||||
|
remotePort: formData.value.remotePort.toString()
|
||||||
|
};
|
||||||
|
|
||||||
|
await instanceApi.createProxy(instanceID.value, proxyInfo);
|
||||||
|
|
||||||
|
showNotification('Proxy created successfully', 'success');
|
||||||
|
closeAddProxyModal();
|
||||||
|
await loadProxies();
|
||||||
|
} catch (error) {
|
||||||
|
showNotification(error.message || 'Create proxy failed', 'error');
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
loadInstanceConfig();
|
loadInstanceConfig();
|
||||||
loadProxies();
|
loadProxies();
|
||||||
@@ -343,12 +436,16 @@ export default {
|
|||||||
proxies,
|
proxies,
|
||||||
logs,
|
logs,
|
||||||
showEditConfigModal,
|
showEditConfigModal,
|
||||||
|
showAddProxyModal,
|
||||||
loading,
|
loading,
|
||||||
formData,
|
formData,
|
||||||
goBack,
|
goBack,
|
||||||
editConfig,
|
editConfig,
|
||||||
closeEditConfigModal,
|
closeEditConfigModal,
|
||||||
handleEditConfiguration
|
addProxy,
|
||||||
|
closeAddProxyModal,
|
||||||
|
handleEditConfiguration,
|
||||||
|
handleSubmit
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -483,4 +580,11 @@ export default {
|
|||||||
background: var(--disabled-bg);
|
background: var(--disabled-bg);
|
||||||
cursor: not-allowed;
|
cursor: not-allowed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.section h3 {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user