mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-13 09:41:57 +00:00
feat: 🎸 Rax 出码中增加对 urlParams 这种特殊数据源的处理
urlParams 就是页面的参数, 在 Rax 应用里面得通过 withRouter 注入进组件里,并通过 this.props.location 获取,因而数据源的 handler 没法直接获取到,所以得传给对应的 handler
This commit is contained in:
parent
5f529aeb40
commit
c743afd9ee
@ -23,6 +23,7 @@ const pluginFactory: BuilderComponentPluginFactory<unknown> = () => {
|
||||
// 注意: 出码引擎注入的临时变量默认都以 "__$$" 开头,禁止在搭建的代码中直接访问。
|
||||
// 例外:rax 框架的导出名和各种组件名除外。
|
||||
import { createElement, Component } from 'rax';
|
||||
import { withRouter as __$$withRouter } from 'rax-app';
|
||||
`,
|
||||
linkAfter: [],
|
||||
});
|
||||
|
||||
@ -125,7 +125,7 @@ const pluginFactory: BuilderComponentPluginFactory<unknown> = () => {
|
||||
type: ChunkType.STRING,
|
||||
fileType: FileType.JSX,
|
||||
name: COMMON_CHUNK_NAME.FileExport,
|
||||
content: `export default ${componentClassName};`,
|
||||
content: `export default __$$withRouter(${componentClassName});`,
|
||||
linkAfter: [
|
||||
COMMON_CHUNK_NAME.ExternalDepsImport,
|
||||
COMMON_CHUNK_NAME.InternalDepsImport,
|
||||
|
||||
@ -46,7 +46,9 @@ const pluginFactory: BuilderComponentPluginFactory<PluginConfig> = (config?) =>
|
||||
...handlers,
|
||||
[ds.type]: {
|
||||
type: 'JSExpression',
|
||||
value: `require('@ali/lowcode-datasource-engine/handlers/${changeCase.kebabCase(ds.type)}')`,
|
||||
value:
|
||||
`require('@ali/lowcode-datasource-engine/handlers/${changeCase.kebabCase(ds.type)}')` +
|
||||
(ds.type === 'urlParams' ? '({ search: this.props.location.search })' : ''),
|
||||
},
|
||||
},
|
||||
{} as Record<string, CompositeValue>,
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
// 注意: 出码引擎注入的临时变量默认都以 "__$$" 开头,禁止在搭建的代码中直接访问。
|
||||
// 例外:rax 框架的导出名和各种组件名除外。
|
||||
import { createElement, Component } from 'rax';
|
||||
import { withRouter as __$$withRouter } from 'rax-app';
|
||||
|
||||
import Page from 'rax-view';
|
||||
|
||||
@ -109,7 +110,7 @@ class Home$$Page extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
export default Home$$Page;
|
||||
export default __$$withRouter(Home$$Page);
|
||||
|
||||
function __$$eval(expr) {
|
||||
try {
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
// 注意: 出码引擎注入的临时变量默认都以 "__$$" 开头,禁止在搭建的代码中直接访问。
|
||||
// 例外:rax 框架的导出名和各种组件名除外。
|
||||
import { createElement, Component } from 'rax';
|
||||
import { withRouter as __$$withRouter } from 'rax-app';
|
||||
|
||||
import View from 'rax-view';
|
||||
|
||||
@ -42,7 +43,7 @@ class Home$$Page extends Component {
|
||||
_dataSourceEngine = __$$createDataSourceEngine(this._dataSourceConfig, this._context, {
|
||||
runtimeConfig: true,
|
||||
requestHandlers: {
|
||||
urlParams: require('@ali/lowcode-datasource-engine/handlers/url-params'),
|
||||
urlParams: require('@ali/lowcode-datasource-engine/handlers/url-params')({ search: this.props.location.search }),
|
||||
fetch: require('@ali/lowcode-datasource-engine/handlers/fetch'),
|
||||
},
|
||||
});
|
||||
@ -286,7 +287,7 @@ class Home$$Page extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
export default Home$$Page;
|
||||
export default __$$withRouter(Home$$Page);
|
||||
|
||||
function __$$eval(expr) {
|
||||
try {
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
// 注意: 出码引擎注入的临时变量默认都以 "__$$" 开头,禁止在搭建的代码中直接访问。
|
||||
// 例外:rax 框架的导出名和各种组件名除外。
|
||||
import { createElement, Component } from 'rax';
|
||||
import { withRouter as __$$withRouter } from 'rax-app';
|
||||
|
||||
import View from 'rax-view';
|
||||
|
||||
@ -120,7 +121,7 @@ class Detail$$Page extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
export default Detail$$Page;
|
||||
export default __$$withRouter(Detail$$Page);
|
||||
|
||||
function __$$eval(expr) {
|
||||
try {
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
// 注意: 出码引擎注入的临时变量默认都以 "__$$" 开头,禁止在搭建的代码中直接访问。
|
||||
// 例外:rax 框架的导出名和各种组件名除外。
|
||||
import { createElement, Component } from 'rax';
|
||||
import { withRouter as __$$withRouter } from 'rax-app';
|
||||
|
||||
import View from 'rax-view';
|
||||
|
||||
@ -120,7 +121,7 @@ class Home$$Page extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
export default Home$$Page;
|
||||
export default __$$withRouter(Home$$Page);
|
||||
|
||||
function __$$eval(expr) {
|
||||
try {
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
// 注意: 出码引擎注入的临时变量默认都以 "__$$" 开头,禁止在搭建的代码中直接访问。
|
||||
// 例外:rax 框架的导出名和各种组件名除外。
|
||||
import { createElement, Component } from 'rax';
|
||||
import { withRouter as __$$withRouter } from 'rax-app';
|
||||
|
||||
import View from 'rax-view';
|
||||
|
||||
@ -123,7 +124,7 @@ class List$$Page extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
export default List$$Page;
|
||||
export default __$$withRouter(List$$Page);
|
||||
|
||||
function __$$eval(expr) {
|
||||
try {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user