Skip to content

Commit

Permalink
feat: 优化 ts/dart 方法模板
Browse files Browse the repository at this point in the history
  • Loading branch information
long-woo committed Aug 20, 2024
1 parent ef8c51d commit 4a49891
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/plugins/dart/template/actionMethod.eta
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ Future<<%~ it.responseType %>> <%= it.methodName %>(<% it.params.forEach((param,
method: '<%= it.method %>'<% if (it.params.length) { %>,
params: {
<% it.params.forEach((param, index) => { %>
'<%= param.category %>': <% if (param.category === param.name) { %><%= param.name %><% } else { %>{'<%= param.name %>' : <%= param.name %>}<% if (index < it.params.length - 1) { %>, <% } %><% } %>
'<%= param.category %>': <% if (param.category === param.name) { %><%= param.name %><% } else { %>{'<%= param.name %>' : <%= param.name %>}<% } %><% if (index < it.params.length - 1) { %>, <% } %>

<% }) %>
}
<% } %>
)<% if (it.responseType.includes('List')) { %>, (json) => [<%~ it.responseName %>.fromJson(json)]<% } else if (it.responseName) { %>, <%~ it.responseName %>.fromJson<% } %>);
)<% if (it.responseType.includes('List<')) { %>, (json) => [<%~ it.responseName %>.fromJson(json)]<% } else if (it.responseName) { %>, <%~ it.responseName %>.fromJson<% } %>);

return _res;
}
5 changes: 2 additions & 3 deletions src/plugins/typescript/template/actionMethod.eta
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@ export const <%= it.methodName %> = (<% it.params.forEach((param, index) => { %>
<% }) %>): Promise<<%~ it.responseType %>> => fetchRuntime<<%~ it.responseType %>>('<%= it.url %>', '<%= it.method.toUpperCase() %>'<% if (it.params.length) { %>, {
<% it.params.forEach((param, index) => { %>
<%= param.category %><% if (param.category === param.name) { %>

<% } else { %>: <% if (param.category === 'body') { %><%= param.name %><% } else { %>{
<%= param.name %>

}<% } %><% if (index < it.params.length - 1) { %>, <% } %>
}<% } %>
<% } %><% if (index < it.params.length - 1) { %>, <% } %>

<% } %>
<% }) %>
}<% } %>)

0 comments on commit 4a49891

Please sign in to comment.