|
|
@@ -75,7 +75,6 @@
|
|
|
<div class="python-config">
|
|
|
<div class="section-title-row">
|
|
|
<div class="section-title">Python 服务配置</div>
|
|
|
- <el-tag v-if="!canManagePythonService" type="info" size="small">需管理员登录</el-tag>
|
|
|
</div>
|
|
|
<el-form :model="pythonService" label-position="top" class="config-form">
|
|
|
<el-form-item label="服务地址">
|
|
|
@@ -186,23 +185,11 @@ function normalizeBaseUrl(url?: string): string {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-function isLocalServerUrl(url?: string): boolean {
|
|
|
- if (!url) return false;
|
|
|
- try {
|
|
|
- const u = new URL(url);
|
|
|
- const host = u.hostname;
|
|
|
- return host === 'localhost' || host === '127.0.0.1' || host === '::1';
|
|
|
- } catch {
|
|
|
- return false;
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
const apiBaseUrl = computed(() => {
|
|
|
return normalizeBaseUrl(serverStore.currentServer?.url) || normalizeBaseUrl(serverForm.url);
|
|
|
});
|
|
|
|
|
|
-const canManagePythonService = computed(() => authStore.isAdmin || isLocalServerUrl(apiBaseUrl.value));
|
|
|
-const pythonFormEnabled = computed(() => !!apiBaseUrl.value && canManagePythonService.value);
|
|
|
+const pythonFormEnabled = computed(() => !!apiBaseUrl.value);
|
|
|
|
|
|
async function loadPythonService() {
|
|
|
try {
|
|
|
@@ -232,7 +219,7 @@ async function saveAll() {
|
|
|
url: normalizedServerUrl,
|
|
|
});
|
|
|
|
|
|
- if (pythonService.url && canManagePythonService.value) {
|
|
|
+ if (pythonService.url && pythonFormEnabled.value) {
|
|
|
await request.put('/api/system/python-service', { url: normalizeBaseUrl(pythonService.url) }, { baseURL: normalizedServerUrl });
|
|
|
}
|
|
|
|
|
|
@@ -245,8 +232,8 @@ async function saveAll() {
|
|
|
}
|
|
|
|
|
|
async function checkPythonService() {
|
|
|
- if (!canManagePythonService.value) {
|
|
|
- ElMessage.warning('需要管理员登录后才能配置');
|
|
|
+ if (!pythonFormEnabled.value) {
|
|
|
+ ElMessage.warning('请先填写服务器地址');
|
|
|
return;
|
|
|
}
|
|
|
if (!apiBaseUrl.value) {
|