fix: 修复脚本切换参数和远程数据源排版
This commit is contained in:
@@ -0,0 +1 @@
|
|||||||
|
# demo
|
||||||
@@ -32,9 +32,9 @@ def _resolve_script_path(script_type: str) -> Path:
|
|||||||
|
|
||||||
|
|
||||||
@router.get("/api/script/content")
|
@router.get("/api/script/content")
|
||||||
async def get_script_content(type: str = Query("report")):
|
async def get_script_content(script_type: str = Query("report")):
|
||||||
script_path = _resolve_script_path(type)
|
script_path = _resolve_script_path(script_type)
|
||||||
label = SCRIPT_LABELS.get(type, type)
|
label = SCRIPT_LABELS.get(script_type, script_type)
|
||||||
try:
|
try:
|
||||||
if not script_path.exists():
|
if not script_path.exists():
|
||||||
return {
|
return {
|
||||||
@@ -42,7 +42,7 @@ async def get_script_content(type: str = Query("report")):
|
|||||||
"content": f"# {label}文件不存在,请在此编写脚本\n",
|
"content": f"# {label}文件不存在,请在此编写脚本\n",
|
||||||
"modified": None,
|
"modified": None,
|
||||||
"path": str(script_path),
|
"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")
|
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"),
|
"content": script_path.read_text(encoding="utf-8"),
|
||||||
"modified": modified,
|
"modified": modified,
|
||||||
"path": str(script_path),
|
"path": str(script_path),
|
||||||
"script_type": type,
|
"script_type": script_type,
|
||||||
}
|
}
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
return {"success": False, "error": str(exc)}
|
return {"success": False, "error": str(exc)}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
:disabled="activationLoading"
|
:disabled="activationLoading"
|
||||||
/>
|
/>
|
||||||
<div class="license-metrix-toggle">
|
<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>
|
<span class="license-metrix-label">启用 Metrix 平台</span>
|
||||||
</div>
|
</div>
|
||||||
</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;
|
savingMetrix.value = true;
|
||||||
try {
|
try {
|
||||||
await apiPost('/api/config/metrix-enabled', { enabled });
|
await apiPost('/api/config/metrix-enabled', { enabled: target });
|
||||||
metrixEnabled.value = enabled;
|
metrixEnabled.value = target;
|
||||||
emit('metrixChanged', enabled);
|
emit('metrixChanged', target);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
metrixEnabled.value = !enabled;
|
|
||||||
message.error(error instanceof Error ? error.message : '保存失败');
|
message.error(error instanceof Error ? error.message : '保存失败');
|
||||||
} finally {
|
} finally {
|
||||||
savingMetrix.value = false;
|
savingMetrix.value = false;
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ const editor = shallowRef<monaco.editor.IStandaloneCodeEditor | null>(null);
|
|||||||
const disposables: monaco.IDisposable[] = [];
|
const disposables: monaco.IDisposable[] = [];
|
||||||
const content = ref('');
|
const content = ref('');
|
||||||
const originalContent = ref('');
|
const originalContent = ref('');
|
||||||
|
const scriptPath = ref('');
|
||||||
const modified = ref<string | null>(null);
|
const modified = ref<string | null>(null);
|
||||||
const cursorText = ref('行 1,列 1');
|
const cursorText = ref('行 1,列 1');
|
||||||
const lineCount = ref(1);
|
const lineCount = ref(1);
|
||||||
@@ -125,7 +126,7 @@ const currentLabel = computed(() => SCRIPT_OPTIONS.find(o => o.key === scriptTyp
|
|||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
setPageHeader({
|
setPageHeader({
|
||||||
subtitle: computed(() => currentLabel.value),
|
subtitle: computed(() => scriptPath.value || currentLabel.value),
|
||||||
actions: [
|
actions: [
|
||||||
{ key: 'script-modified', kind: 'text', label: modifiedText },
|
{ key: 'script-modified', kind: 'text', label: modifiedText },
|
||||||
{
|
{
|
||||||
@@ -228,19 +229,21 @@ async function switchScript(type: string) {
|
|||||||
const confirm = window.confirm(`当前脚本有未保存的修改,是否放弃?`);
|
const confirm = window.confirm(`当前脚本有未保存的修改,是否放弃?`);
|
||||||
if (!confirm) return;
|
if (!confirm) return;
|
||||||
}
|
}
|
||||||
scriptType.value = type;
|
await loadScript(type);
|
||||||
await loadScript();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadScript() {
|
async function loadScript(type?: string) {
|
||||||
|
const target = type || scriptType.value;
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
try {
|
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) {
|
if (!result.success) {
|
||||||
throw new Error(result.error || '加载脚本失败');
|
throw new Error(result.error || '加载脚本失败');
|
||||||
}
|
}
|
||||||
applyScriptContent(result.content);
|
scriptType.value = target;
|
||||||
|
scriptPath.value = result.path || '';
|
||||||
modified.value = result.modified;
|
modified.value = result.modified;
|
||||||
|
applyScriptContent(result.content);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
message.error(error instanceof Error ? error.message : '加载脚本失败');
|
message.error(error instanceof Error ? error.message : '加载脚本失败');
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -682,9 +682,8 @@
|
|||||||
>
|
>
|
||||||
<div class="cell-data-settings-body">
|
<div class="cell-data-settings-body">
|
||||||
<section class="cell-data-settings-section">
|
<section class="cell-data-settings-section">
|
||||||
<div class="cell-data-section-title">
|
<n-collapse>
|
||||||
<strong>高级匹配</strong>
|
<n-collapse-item title="高级匹配" name="advanced">
|
||||||
</div>
|
|
||||||
<n-grid :cols="12" :x-gap="12">
|
<n-grid :cols="12" :x-gap="12">
|
||||||
<n-gi :span="4">
|
<n-gi :span="4">
|
||||||
<n-form-item label="年份目录正则">
|
<n-form-item label="年份目录正则">
|
||||||
@@ -712,6 +711,8 @@
|
|||||||
</n-form-item>
|
</n-form-item>
|
||||||
</n-gi>
|
</n-gi>
|
||||||
</n-grid>
|
</n-grid>
|
||||||
|
</n-collapse-item>
|
||||||
|
</n-collapse>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section class="cell-data-settings-section">
|
<section class="cell-data-settings-section">
|
||||||
|
|||||||
+2
-10
@@ -1547,7 +1547,7 @@ select {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.settings-remote-panel {
|
.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 {
|
.settings-scheduler-panel {
|
||||||
@@ -1556,7 +1556,7 @@ select {
|
|||||||
|
|
||||||
.remote-connection-row {
|
.remote-connection-row {
|
||||||
display: grid;
|
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;
|
gap: 12px;
|
||||||
align-items: start;
|
align-items: start;
|
||||||
}
|
}
|
||||||
@@ -2281,10 +2281,6 @@ select {
|
|||||||
grid-template-columns: 1fr;
|
grid-template-columns: 1fr;
|
||||||
}
|
}
|
||||||
|
|
||||||
.remote-connection-row {
|
|
||||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
||||||
}
|
|
||||||
|
|
||||||
.settings-rules-grid {
|
.settings-rules-grid {
|
||||||
grid-template-rows: auto minmax(520px, 1fr);
|
grid-template-rows: auto minmax(520px, 1fr);
|
||||||
align-items: start;
|
align-items: start;
|
||||||
@@ -2292,10 +2288,6 @@ select {
|
|||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.settings-remote-panel {
|
|
||||||
grid-template-columns: 1fr;
|
|
||||||
}
|
|
||||||
|
|
||||||
.settings-tabs .n-tab-pane {
|
.settings-tabs .n-tab-pane {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user