Skip to content

Commit

Permalink
fix(script):fix delete error
Browse files Browse the repository at this point in the history
  • Loading branch information
ni00 committed Jul 6, 2023
1 parent db05ae9 commit 6132c0c
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions src/views/script/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ import MyDialog from '@/components/MyDialog.vue'
import useServers from '@/database/useServices'
import ImportScript from '@/components/ImportScript.vue'
import { scriptTest } from '@/utils/scriptTest'
import script from '@/lang/script'
@Component({
components: {
Expand Down Expand Up @@ -288,7 +289,7 @@ message Person {
this.schemaEditorValue = this.defaultSchema[this.currentSchema].content
this.functionInputValue = this.defaultFunction[this.currentFunction].input
this.schemaInputValue = this.defaultSchema[this.currentSchema].input
this.loadData(true)
this.loadData()
}
private handleTabClick(e: any) {
Expand Down Expand Up @@ -381,7 +382,7 @@ message Person {
}
}
private async loadData(first: boolean = false): Promise<void> {
private async loadData(): Promise<void> {
const { scriptService } = useServers()
let scripts: ScriptModel[] | [] = []
if (this.activeTab === this.functionTab) {
Expand All @@ -393,9 +394,28 @@ message Person {
scripts = (await scriptService.getAllSchema()) ?? []
scripts = scripts.filter((item) => item.name.endsWith(`.${this.defaultSchema[this.currentSchema].extension}`))
}
console.log('scripts:', scripts)
this.scripts = scripts
if (this.scripts && this.scripts.length > 0 && this.scripts[this.scripts.length - 1].id) {
this.currentScriptId = this.scripts[this.scripts.length - 1].id as string
let currentScript = this.scripts[this.scripts.length - 1]
this.currentScriptId = currentScript.id as string
if (this.activeTab === this.functionTab) {
this.functionEditorValue = currentScript.script
this.functionInputValue = this.defaultFunction[this.currentFunction].input
} else {
this.schemaEditorValue = currentScript.script
this.schemaInputValue = this.defaultSchema[this.currentSchema].input
}
} else {
this.currentScriptId = ''
if (this.activeTab === this.functionTab) {
this.functionEditorValue = this.defaultFunction[this.currentFunction].content
this.functionInputValue = this.defaultFunction[this.currentFunction].input
} else {
this.schemaEditorValue = this.defaultSchema[this.currentSchema].content
this.schemaInputValue = this.defaultSchema[this.currentSchema].input
}
this.outputValue = ''
}
}
Expand All @@ -411,6 +431,8 @@ message Person {
.then(async () => {
const res: ScriptModel | undefined = await scriptService.delete(this.currentScriptId)
if (res) {
console.log('id:', this.currentScriptId)
console.log('scripts:', this.scripts)
this.$message.success(this.$tc('common.deleteSuccess'))
this.currentScriptId = ''
this.loadData()
Expand Down

0 comments on commit 6132c0c

Please sign in to comment.