提交 b8591c12 编写于 作者: fxy060608's avatar fxy060608

fix(compat): RENDER_FUNCTION

上级 0779f670
...@@ -7670,7 +7670,8 @@ function initApp(vm) { ...@@ -7670,7 +7670,8 @@ function initApp(vm) {
appVm.$vm = vm; appVm.$vm = vm;
appVm.globalData = appVm.$options.globalData || {}; appVm.globalData = appVm.$options.globalData || {};
} }
function wrapperComponentSetup(comp, {init, setup, after}) { function wrapperComponentSetup(comp, {init, setup, before}) {
before && before(comp);
const oldSetup = comp.setup; const oldSetup = comp.setup;
comp.setup = (props2, ctx) => { comp.setup = (props2, ctx) => {
const instance = vue.getCurrentInstance(); const instance = vue.getCurrentInstance();
...@@ -7680,7 +7681,6 @@ function wrapperComponentSetup(comp, {init, setup, after}) { ...@@ -7680,7 +7681,6 @@ function wrapperComponentSetup(comp, {init, setup, after}) {
return oldSetup(query, ctx); return oldSetup(query, ctx);
} }
}; };
after && after(comp);
} }
function setupComponent(comp, options) { function setupComponent(comp, options) {
if (comp && (comp.__esModule || comp[Symbol.toStringTag] === "Module")) { if (comp && (comp.__esModule || comp[Symbol.toStringTag] === "Module")) {
...@@ -7715,9 +7715,11 @@ function setupApp(comp) { ...@@ -7715,9 +7715,11 @@ function setupApp(comp) {
return route.query; return route.query;
} }
}, },
after(comp2) { before(comp2) {
comp2.mpType = "app"; comp2.mpType = "app";
comp2.render = () => (vue.openBlock(), vue.createBlock(LayoutComponent)); comp2.setup = () => () => {
return vue.openBlock(), vue.createBlock(LayoutComponent);
};
} }
}); });
} }
......
...@@ -13185,7 +13185,8 @@ function initApp(vm) { ...@@ -13185,7 +13185,8 @@ function initApp(vm) {
appVm.$vm = vm; appVm.$vm = vm;
appVm.globalData = appVm.$options.globalData || {}; appVm.globalData = appVm.$options.globalData || {};
} }
function wrapperComponentSetup(comp, {init: init2, setup, after}) { function wrapperComponentSetup(comp, {init: init2, setup, before}) {
before && before(comp);
const oldSetup = comp.setup; const oldSetup = comp.setup;
comp.setup = (props2, ctx) => { comp.setup = (props2, ctx) => {
const instance2 = getCurrentInstance(); const instance2 = getCurrentInstance();
...@@ -13195,7 +13196,6 @@ function wrapperComponentSetup(comp, {init: init2, setup, after}) { ...@@ -13195,7 +13196,6 @@ function wrapperComponentSetup(comp, {init: init2, setup, after}) {
return oldSetup(query, ctx); return oldSetup(query, ctx);
} }
}; };
after && after(comp);
} }
function setupComponent(comp, options) { function setupComponent(comp, options) {
if (comp && (comp.__esModule || comp[Symbol.toStringTag] === "Module")) { if (comp && (comp.__esModule || comp[Symbol.toStringTag] === "Module")) {
...@@ -13279,9 +13279,11 @@ function setupApp(comp) { ...@@ -13279,9 +13279,11 @@ function setupApp(comp) {
}); });
return route.query; return route.query;
}, },
after(comp2) { before(comp2) {
comp2.mpType = "app"; comp2.mpType = "app";
comp2.render = () => (openBlock(), createBlock(LayoutComponent)); comp2.setup = () => () => {
return openBlock(), createBlock(LayoutComponent);
};
} }
}); });
} }
......
...@@ -21,13 +21,14 @@ import { usePageMeta, usePageRoute } from './provide' ...@@ -21,13 +21,14 @@ import { usePageMeta, usePageRoute } from './provide'
interface SetupComponentOptions { interface SetupComponentOptions {
init: (vm: ComponentPublicInstance) => void init: (vm: ComponentPublicInstance) => void
setup: (instance: ComponentInternalInstance) => Record<string, any> setup: (instance: ComponentInternalInstance) => Record<string, any>
after?: (comp: DefineComponent) => void before?: (comp: DefineComponent) => void
} }
function wrapperComponentSetup( function wrapperComponentSetup(
comp: DefineComponent, comp: DefineComponent,
{ init, setup, after }: SetupComponentOptions { init, setup, before }: SetupComponentOptions
) { ) {
before && before(comp)
const oldSetup = comp.setup const oldSetup = comp.setup
comp.setup = (props, ctx) => { comp.setup = (props, ctx) => {
const instance = getCurrentInstance()! const instance = getCurrentInstance()!
...@@ -37,7 +38,6 @@ function wrapperComponentSetup( ...@@ -37,7 +38,6 @@ function wrapperComponentSetup(
return oldSetup(query, ctx) return oldSetup(query, ctx)
} }
} }
after && after(comp)
} }
function setupComponent(comp: any, options: SetupComponentOptions) { function setupComponent(comp: any, options: SetupComponentOptions) {
...@@ -137,9 +137,11 @@ export function setupApp(comp: any) { ...@@ -137,9 +137,11 @@ export function setupApp(comp: any) {
}) })
return route.query return route.query
}, },
after(comp) { before(comp) {
comp.mpType = 'app' comp.mpType = 'app'
comp.render = () => (openBlock(), createBlock(LayoutComponent)) comp.setup = () => () => {
return openBlock(), createBlock(LayoutComponent)
}
}, },
}) })
} }
...@@ -49,6 +49,8 @@ const baseComponents = [ ...@@ -49,6 +49,8 @@ const baseComponents = [
'view', 'view',
] ]
const identifierRE = /^([a-zA-Z_$][a-zA-Z\\d_$]*)$/
export function uniEasycomPlugin(options: UniPluginFilterOptions): Plugin { export function uniEasycomPlugin(options: UniPluginFilterOptions): Plugin {
const filter = createFilter(options.include, options.exclude) const filter = createFilter(options.include, options.exclude)
return { return {
...@@ -82,7 +84,9 @@ export function uniEasycomPlugin(options: UniPluginFilterOptions): Plugin { ...@@ -82,7 +84,9 @@ export function uniEasycomPlugin(options: UniPluginFilterOptions): Plugin {
if (source) { if (source) {
return ( return (
// 解决局部引入组件优先级(理论上让开发者使用script setup就可以解决局部引入) // 解决局部引入组件优先级(理论上让开发者使用script setup就可以解决局部引入)
`typeof ${name} !== 'undefined' ? ${name} : ` + (identifierRE.test(name)
? `typeof ${name} !== 'undefined' ? ${name} : `
: '') +
addImportDeclaration( addImportDeclaration(
importDeclarations, importDeclarations,
`__easycom_${i++}`, `__easycom_${i++}`,
......
...@@ -238,7 +238,7 @@ function generatePageRoute( ...@@ -238,7 +238,7 @@ function generatePageRoute(
const alias = isEntry ? `\n alias:'/${path}',` : '' const alias = isEntry ? `\n alias:'/${path}',` : ''
return `{ return `{
path:'/${isEntry ? '' : path}',${alias} path:'/${isEntry ? '' : path}',${alias}
component:{render(){return renderPage(${name})}}, component:{setup(){return ()=>renderPage(${name})}},
loader: ${normalizePageIdentifier(path)}Loader, loader: ${normalizePageIdentifier(path)}Loader,
meta: ${JSON.stringify(meta)} meta: ${JSON.stringify(meta)}
}` }`
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册