fix: 修复脚本切换参数和远程数据源排版

This commit is contained in:
2026-06-25 17:38:41 +08:00
parent 9339453482
commit 9cad3ba807
6 changed files with 54 additions and 57 deletions
+1
View File
@@ -0,0 +1 @@
# demo
+5 -5
View File
@@ -32,9 +32,9 @@ def _resolve_script_path(script_type: str) -> Path:
@router.get("/api/script/content")
async def get_script_content(type: str = Query("report")):
script_path = _resolve_script_path(type)
label = SCRIPT_LABELS.get(type, type)
async def get_script_content(script_type: str = Query("report")):
script_path = _resolve_script_path(script_type)
label = SCRIPT_LABELS.get(script_type, script_type)
try:
if not script_path.exists():
return {
@@ -42,7 +42,7 @@ async def get_script_content(type: str = Query("report")):
"content": f"# {label}文件不存在,请在此编写脚本\n",
"modified": None,
"path": str(script_path),
"script_type": type,
"script_type": script_type,
}
modified = datetime.fromtimestamp(script_path.stat().st_mtime).strftime("%Y-%m-%d %H:%M:%S")
@@ -51,7 +51,7 @@ async def get_script_content(type: str = Query("report")):
"content": script_path.read_text(encoding="utf-8"),
"modified": modified,
"path": str(script_path),
"script_type": type,
"script_type": script_type,
}
except Exception as exc:
return {"success": False, "error": str(exc)}
@@ -17,7 +17,7 @@
:disabled="activationLoading"
/>
<div class="license-metrix-toggle">
<n-switch v-model:value="metrixEnabled" :loading="savingMetrix" size="small" @update:value="toggleMetrix" />
<n-switch :value="metrixEnabled" :loading="savingMetrix" size="small" @update:value="toggleMetrix" />
<span class="license-metrix-label">启用 Metrix 平台</span>
</div>
</div>
@@ -72,14 +72,14 @@ async function loadMetrixEnabled() {
}
}
async function toggleMetrix(enabled: boolean) {
async function toggleMetrix(target: boolean) {
if (target === metrixEnabled.value) return;
savingMetrix.value = true;
try {
await apiPost('/api/config/metrix-enabled', { enabled });
metrixEnabled.value = enabled;
emit('metrixChanged', enabled);
await apiPost('/api/config/metrix-enabled', { enabled: target });
metrixEnabled.value = target;
emit('metrixChanged', target);
} catch (error) {
metrixEnabled.value = !enabled;
message.error(error instanceof Error ? error.message : '保存失败');
} finally {
savingMetrix.value = false;
+9 -6
View File
@@ -79,6 +79,7 @@ const editor = shallowRef<monaco.editor.IStandaloneCodeEditor | null>(null);
const disposables: monaco.IDisposable[] = [];
const content = ref('');
const originalContent = ref('');
const scriptPath = ref('');
const modified = ref<string | null>(null);
const cursorText = ref('行 1,列 1');
const lineCount = ref(1);
@@ -125,7 +126,7 @@ const currentLabel = computed(() => SCRIPT_OPTIONS.find(o => o.key === scriptTyp
onMounted(async () => {
setPageHeader({
subtitle: computed(() => currentLabel.value),
subtitle: computed(() => scriptPath.value || currentLabel.value),
actions: [
{ key: 'script-modified', kind: 'text', label: modifiedText },
{
@@ -228,19 +229,21 @@ async function switchScript(type: string) {
const confirm = window.confirm(`当前脚本有未保存的修改,是否放弃?`);
if (!confirm) return;
}
scriptType.value = type;
await loadScript();
await loadScript(type);
}
async function loadScript() {
async function loadScript(type?: string) {
const target = type || scriptType.value;
loading.value = true;
try {
const result = await apiGet<ScriptContent>(`/api/script/content?type=${scriptType.value}`);
const result = await apiGet<ScriptContent & { script_type?: string }>(`/api/script/content?script_type=${target}`);
if (!result.success) {
throw new Error(result.error || '加载脚本失败');
}
applyScriptContent(result.content);
scriptType.value = target;
scriptPath.value = result.path || '';
modified.value = result.modified;
applyScriptContent(result.content);
} catch (error) {
message.error(error instanceof Error ? error.message : '加载脚本失败');
} finally {
+4 -3
View File
@@ -682,9 +682,8 @@
>
<div class="cell-data-settings-body">
<section class="cell-data-settings-section">
<div class="cell-data-section-title">
<strong>高级匹配</strong>
</div>
<n-collapse>
<n-collapse-item title="高级匹配" name="advanced">
<n-grid :cols="12" :x-gap="12">
<n-gi :span="4">
<n-form-item label="年份目录正则">
@@ -712,6 +711,8 @@
</n-form-item>
</n-gi>
</n-grid>
</n-collapse-item>
</n-collapse>
</section>
<section class="cell-data-settings-section">
+2 -10
View File
@@ -1547,7 +1547,7 @@ select {
}
.settings-remote-panel {
grid-template-columns: repeat(2, minmax(420px, 1fr));
grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
}
.settings-scheduler-panel {
@@ -1556,7 +1556,7 @@ select {
.remote-connection-row {
display: grid;
grid-template-columns: minmax(112px, 0.8fr) minmax(220px, 1.8fr) minmax(110px, 0.8fr) minmax(120px, 0.8fr) minmax(116px, 0.7fr);
grid-template-columns: repeat(auto-fill, minmax(min(120px, 100%), 1fr));
gap: 12px;
align-items: start;
}
@@ -2281,10 +2281,6 @@ select {
grid-template-columns: 1fr;
}
.remote-connection-row {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
.settings-rules-grid {
grid-template-rows: auto minmax(520px, 1fr);
align-items: start;
@@ -2292,10 +2288,6 @@ select {
overflow-y: auto;
}
.settings-remote-panel {
grid-template-columns: 1fr;
}
.settings-tabs .n-tab-pane {
overflow: hidden;
}