This repository has been archived by the owner on Nov 17, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
fix: request in data loader #662
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b324bee
fix: support request in data loader
chenjun1011 f89dacb
fix: type
chenjun1011 3c96d7d
fix: type
chenjun1011 46f5555
fix: ts error
chenjun1011 c71bf2f
fix: type
chenjun1011 b3a4193
feat: support config exports in plugin
chenjun1011 ae16444
fix: filter static modules
chenjun1011 979a4c9
refactor: rename
chenjun1011 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
@@ -1,20 +1,39 @@ | ||
import { dataLoader } from '@ice/runtime'; | ||
<% if(hasExportAppData) {-%>import { getAppData } from '@/app';<% } -%> | ||
|
||
<% if(hasExportAppData) {-%>import * as app from '@/app';<% } -%> | ||
<% if(dataLoaderImport.imports) {-%><%-dataLoaderImport.imports%><% } -%> | ||
<% const staticModuleNames = []; -%> | ||
<% if (runtimeModules.length) { -%> | ||
<% runtimeModules.forEach((runtimeModule, index) => { -%> | ||
<% if (runtimeModule.staticRuntime) { -%> | ||
import module<%= index %> from '<%= runtimeModule.path %>'; | ||
<% staticModuleNames.push('module' + index) -%> | ||
<% } -%> | ||
<% }) -%> | ||
<% } -%> | ||
|
||
<% if (loaders) {-%> | ||
<%- loaders %> | ||
<% } else { -%> | ||
const loaders = {}; | ||
<% } -%> | ||
|
||
<% if(hasExportAppData) {-%>loaders['__app'] = getAppData;<% } -%> | ||
<% if(hasExportAppData) {-%>loaders['__app'] = app.getAppData;<% } -%> | ||
|
||
<% if(!dataLoaderImport.imports) {-%> | ||
let fetcher = (options) => { | ||
window.fetch(options.url, options); | ||
} | ||
<% } -%> | ||
|
||
dataLoader.init(loaders, fetcher); | ||
// Only init static runtime in data-loader. | ||
const staticRuntimeModules = [ | ||
<% staticModuleNames.forEach((moduleName, index) => { -%> | ||
<%= moduleName %>, | ||
<% }) -%> | ||
]; | ||
|
||
dataLoader.init(loaders, { | ||
fetcher, | ||
runtimeModules: staticRuntimeModules, | ||
appExport: app, | ||
}); |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个是干啥的?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
通过插件注册的一些运行时模块,比如 request 插件,会配置请求的 baseUrl,需要对 data-loader 生效