fix: run scripts path erro r from local dev and prod env

This commit is contained in:
engigu
2026-02-10 12:05:00 +08:00
parent 27769c2702
commit 7c6437dbaf
4 changed files with 30 additions and 5 deletions
+1
View File
@@ -122,6 +122,7 @@ export const api = {
getScheduler: () => request<SchedulerSettings>('/settings/scheduler'),
updateScheduler: (data: SchedulerSettings) =>
request('/settings/scheduler', { method: 'PUT', body: JSON.stringify(data) }),
getPaths: () => request<{ scripts_dir: string }>('/settings/paths'),
getAbout: () => request<AboutInfo>('/settings/about'),
getLoginLogs: (params?: { page?: number; page_size?: number; username?: string }) => {
const query = new URLSearchParams()
+17 -3
View File
@@ -44,6 +44,16 @@ const hasChanges = computed(() => fileContent.value !== originalContent.value)
const showTerminalDialog = ref(false)
const terminalRef = ref<InstanceType<typeof XTerminal> | null>(null)
const runCommand = ref('')
const scriptsDir = ref('')
async function fetchPaths() {
try {
const res = await api.settings.getPaths()
scriptsDir.value = res.scripts_dir
} catch {
scriptsDir.value = PATHS.SCRIPTS_DIR
}
}
// Monaco Editor 实例引用
const editorRef = shallowRef()
@@ -188,10 +198,11 @@ async function runScript() {
const cmd = runner ? `${runner} ${fileName}` : `./${fileName}`
// 构建完整命令
const baseDir = scriptsDir.value || PATHS.SCRIPTS_DIR
if (dirPath) {
runCommand.value = `cd ${PATHS.SCRIPTS_DIR}/${dirPath} && ${cmd}`
runCommand.value = `cd ${baseDir}/${dirPath} && ${cmd}`
} else {
runCommand.value = `cd ${PATHS.SCRIPTS_DIR} && ${cmd}`
runCommand.value = `cd ${baseDir} && ${cmd}`
}
showTerminalDialog.value = true
@@ -346,7 +357,10 @@ async function initFromUrl() {
}
}
onMounted(initFromUrl)
onMounted(() => {
initFromUrl()
fetchPaths()
})
onMounted(() => {
window.addEventListener('resize', handleResize)