-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: parser and api,case (#183)
* refactor: add type hint for Parse and Format, extract statement to function * refactor(api,case): use mixin replace duplicate methods
- Loading branch information
1 parent
a333f09
commit 559b6be
Showing
8 changed files
with
761 additions
and
800 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// apiListMixin.js | ||
export default { | ||
methods: { | ||
getAPIList(params) { | ||
this.$nextTick(() => { | ||
const defaultParams = { | ||
page: this.listCurrentPage || 1, // 提供默认值 | ||
node: this.node || this.currentNode, // 支持不同的命名 | ||
project: this.project, | ||
search: this.search, | ||
tag: this.visibleTag || this.tag, | ||
rigEnv: this.rigEnv, | ||
onlyMe: this.onlyMe, | ||
showYAPI: this.showYAPI, | ||
creator: this.selectUser | ||
}; | ||
|
||
// 使用传入的参数覆盖默认参数 | ||
const apiParams = { ...defaultParams, ...params }; | ||
|
||
this.$api.apiList({ params: apiParams }).then(res => { | ||
this.apiData = res; | ||
}); | ||
}); | ||
} | ||
} | ||
}; |
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,28 @@ | ||
// configMixin.js | ||
export default { | ||
data() { | ||
return { | ||
configOptions: [], | ||
currentConfig: null | ||
}; | ||
}, | ||
methods: { | ||
getConfig({ addPlaceholder = false, setDefaultConfig = false } = {}) { | ||
this.$api.getAllConfig(this.$route.params.id).then(resp => { | ||
this.configOptions = resp; | ||
|
||
// 根据配置决定是否添加占位符,并设置默认选项 | ||
if (addPlaceholder) { | ||
const placeHolderOption = { name: '请选择' }; | ||
if (setDefaultConfig) { | ||
this.configOptions.unshift(placeHolderOption); | ||
const _config = this.configOptions.find(item => item.is_default === true); | ||
this.currentConfig = _config || placeHolderOption; | ||
} else { | ||
this.configOptions.push(placeHolderOption); | ||
} | ||
} | ||
}); | ||
} | ||
} | ||
}; |
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,15 @@ | ||
// treeMixin.js | ||
export default { | ||
methods: { | ||
getTree(callback) { | ||
this.$api.getTree(this.$route.params.id, { params: { type: 1 } }).then(resp => { | ||
this.dataTree = resp['tree']; | ||
|
||
// 如果有提供回调函数,则调用它 | ||
if (callback && typeof callback === 'function') { | ||
callback(resp); | ||
} | ||
}); | ||
} | ||
} | ||
}; |
Oops, something went wrong.