Skip to content

Commit 8c1e44d

Browse files
chore: clean code
1 parent 39ee00d commit 8c1e44d

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/generator/serviceGenarator.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -689,11 +689,14 @@ export default class ServiceGenerator {
689689
if (response?.isAnonymous) {
690690
const responseName = upperFirst(`${functionName}Response`);
691691
// 使用正则表达式移除 response?.type 中包含 this.config.namespace 的部分,isAnonymous模式不需要 this.config.namespace 前缀
692-
const cleanType =
693-
response?.type?.replace(
694-
new RegExp(`${this.config.namespace}\\.`, 'g'),
695-
''
696-
) || '';
692+
const cleanType = response?.type?.includes(
693+
`${this.config.namespace}.`
694+
)
695+
? response?.type?.replace(
696+
new RegExp(`${this.config.namespace}\\.`, 'g'),
697+
''
698+
)
699+
: response?.type || '';
697700
this.interfaceTPConfigs.push({
698701
typeName: responseName,
699702
type: cleanType,

0 commit comments

Comments
 (0)