forked from goplus/builder
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(gui):update the request of get project and modify loading status
- Loading branch information
1 parent
1ff5e35
commit 93f1af8
Showing
7 changed files
with
226 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
<!-- | ||
* @Author: Zhang Zhi Yang | ||
* @Date: 2024-02-26 17:49:39 | ||
* @LastEditors: Zhang Zhi Yang | ||
* @LastEditTime: 2024-02-28 11:37:20 | ||
* @FilePath: \builder\spx-gui\src\widgets\spx-runner\spxRunner.vue | ||
* @Description: | ||
--> | ||
<template> | ||
<div class="spx-runner-widget"> | ||
<div class="operation"> | ||
<n-button :disabled="!projectid || !ready || !!errorMsg || run" @click="onRun">run</n-button> | ||
<n-button :disabled="!projectid || !ready || !!errorMsg || !run" @click="onStop" | ||
>stop</n-button | ||
> | ||
</div> | ||
<div class="project-runner"> | ||
<div v-if="!ready" class="loading"> | ||
<n-spin /> | ||
</div> | ||
<div v-if="errorMsg" class="error"> | ||
<p>{{ errorMsg }}</p> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
<script setup lang="ts"> | ||
import { ref, defineProps, watch } from 'vue' | ||
import { NButton, NSpin } from 'naive-ui' | ||
// consider use fetch instead of axios | ||
import axios from 'axios' | ||
const props = defineProps<{ projectid?: string }>() | ||
const run = ref(false) | ||
const ready = ref(false) | ||
const errorMsg = ref('') | ||
const baseUrl = import.meta.env.VITE_API_BASE_URL | ||
watch( | ||
() => props.projectid, | ||
async (projectid) => { | ||
if (projectid) { | ||
ready.value = false | ||
errorMsg.value = '' | ||
try { | ||
const res = await axios.get(baseUrl + '/project?id=' + projectid) | ||
await new Promise((resolve) => { | ||
setTimeout(() => { | ||
resolve(200) | ||
}, 2000) | ||
}) | ||
ready.value = true | ||
} catch (err) { | ||
console.log(err) | ||
errorMsg.value = 'loading project fail' | ||
} finally { | ||
ready.value = true | ||
} | ||
} | ||
}, | ||
{ | ||
immediate: true | ||
} | ||
) | ||
const onRun = () => { | ||
run.value = true | ||
} | ||
const onStop = () => { | ||
run.value = false | ||
} | ||
</script> | ||
<style lang="scss" scoped> | ||
.spx-runner-widget { | ||
width: 100%; | ||
height: 100%; | ||
display: flex; | ||
flex-direction: column; | ||
.operation { | ||
display: flex; | ||
} | ||
.project-runner { | ||
position: relative; | ||
width: 100%; | ||
flex: 1; | ||
.loading, | ||
.error { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
} | ||
} | ||
// loading icon is not center | ||
:deep(.n-base-loading__container){ | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<!-- | ||
* @Author: Zhang Zhi Yang | ||
* @Date: 2024-02-28 09:15:20 | ||
* @LastEditors: Zhang Zhi Yang | ||
* @LastEditTime: 2024-02-28 11:30:43 | ||
* @FilePath: \builder\spx-gui\src\widgets\spx-runner\spxRunnerDemo.vue | ||
* @Description: | ||
--> | ||
<template> | ||
<div class="spx-runner-demo"> | ||
<input v-model="projectid" /> | ||
<SpxRunner :projectid="projectid" /> | ||
</div> | ||
</template> | ||
<script setup lang="ts"> | ||
import { useRoute } from 'vue-router' | ||
import { onMounted, ref } from 'vue' | ||
import SpxRunner from './SpxRunner.vue' | ||
const route = useRoute() | ||
const projectid = ref<string>() | ||
onMounted(() => { | ||
console.log('router:', route.params.id) | ||
if (route.params.id) { | ||
console.log('router:', route.params.id) | ||
projectid.value = route.params.id as string | ||
} | ||
}) | ||
</script> | ||
<style scoped lang="scss"> | ||
.spx-runner-demo { | ||
width: 300px; | ||
height: 300px; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters