Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

完善编译链,mpharmony编译时将taro-components组件库替换为components-mpharmony #5

Merged
merged 5 commits into from
Jun 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions examples/mini-program-example/src/pages/index/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {View, Text,Image} from '@tarojs/components'
import {View, Text,Image,GridView,ListView} from '@tarojs/components'
import {useLoad} from '@tarojs/taro'
import './index.scss'
import {TestBlock, GridView,ListView} from "@tarojs/components-mpharmony";

const grid_data = [
{
Expand Down Expand Up @@ -39,7 +38,6 @@ export default function Index() {
return (
<View className='index'>
<Text>Hello world!</Text>
<TestBlock><Text>Hello world!</Text></TestBlock>

<GridView columnNum={3} data={grid_data} columnItem={(childItem, i,index) => (

Expand All @@ -59,7 +57,7 @@ export default function Index() {

<ListView orientation={'vertical'} data={grid_data} columnItem={(childItem, i) => (

<View key={`list-group-item-${i}`} onClick={() => ( console.log("childItem "+childItem.value+" i "+i+" index "+index) )}>
<View key={`list-group-item-${i}`} onClick={() => ( console.log("childItem "+childItem.value+" i "+i) )}>
{childItem.image && (
<Image
src={childItem.image}
Expand Down
2 changes: 2 additions & 0 deletions packages/taro-components-mpharmony/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"loader-utils": "^3.2.1",
"memoize-one": "^6.0.0",
"@tarojs/components": "~3.3.20",
"@tarojs/components-react": "3.6.8",
"@tarojs/taro": "~3.3.20",
"@tarojs/plugin-framework-react": "3.6.8",
"@tarojs/react": "3.6.8",
Expand All @@ -34,6 +35,7 @@
"@babel/core": "^7.21.0",
"@babel/parser": "^7.14.5",
"@tarojs/components": "~3.3.20",
"@tarojs/components-react": "3.6.8",
"@tarojs/react": "~3.3.20",
"@tarojs/taro": "~3.3.20",
"@babel/plugin-proposal-decorators": "^7.14.5",
Expand Down
14 changes: 7 additions & 7 deletions packages/taro-components-mpharmony/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export { FollowSwan } from '@tarojs/components/lib/react'
export { Form } from '@tarojs/components/lib/react'
export { FunctionalPageNavigator } from '@tarojs/components/lib/react'
export { Icon } from '@tarojs/components/lib/react'
// export { default as Image } from './components/image'
export { default as Image } from '@tarojs/components-react/dist/components/image'
export { InlinePaymentPanel } from '@tarojs/components/lib/react'
export { Input } from '@tarojs/components/lib/react'
export { KeyboardAccessory } from '@tarojs/components/lib/react'
Expand All @@ -46,24 +46,24 @@ export { PageMeta } from '@tarojs/components/lib/react'
export { Picker, PickerGroup } from '@tarojs/components/lib/react'
export { PickerView, PickerViewColumn } from '@tarojs/components/lib/react'
export { Progress } from '@tarojs/components/lib/react'
// export { default as PullDownRefresh } from './components/pull-down-refresh'
// export { PullToRefresh } from '@tarojs/components/lib/react'
export { default as PullDownRefresh } from '@tarojs/components-react/dist/components/pull-down-refresh'
export { PullToRefresh } from '@tarojs/components/lib/react'
export { Radio, RadioGroup } from '@tarojs/components/lib/react'
export { RichText } from '@tarojs/components/lib/react'
export { RootPortal } from '@tarojs/components/lib/react'
export { RtcRoom, RtcRoomItem } from '@tarojs/components/lib/react'
// export { default as ScrollView } from './components/scroll-view'
export { default as ScrollView } from '@tarojs/components-react/dist/components/scroll-view'
export { ShareElement } from '@tarojs/components/lib/react'
export { Slider } from '@tarojs/components/lib/react'
export { NativeSlot, Slot } from '@tarojs/components/lib/react'
// export { Swiper, SwiperItem } from './components/swiper'
export { Swiper, SwiperItem } from '@tarojs/components-react/dist/components/swiper'
export { Switch } from '@tarojs/components/lib/react'
export { Tabbar, TabItem } from '@tarojs/components/lib/react'
export { Tabs } from '@tarojs/components/lib/react'
// export { default as Text } from './components/text'
export { default as Text } from '@tarojs/components-react/dist/components/text'
export { Textarea } from '@tarojs/components/lib/react'
export { Video, VideoControl, VideoDanmu } from '@tarojs/components/lib/react'
// export { default as View } from './components/view'
export { default as View } from '@tarojs/components-react/dist/components/view'
export { VoipRoom } from '@tarojs/components/lib/react'
export { WebView } from '@tarojs/components/lib/react'
export * from './components/block/block'
Expand Down
17 changes: 3 additions & 14 deletions packages/taro-platform-mpharmony/src/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,12 @@ export default class H5 extends TaroPlatformWeb {
return this.ctx.initialConfig.framework || 'react'
}

get useHtmlComponents () {
return !!this.ctx.initialConfig.h5?.useHtmlComponents
}

get useDeprecatedAdapterComponent () {
return !!this.ctx.initialConfig.h5?.useDeprecatedAdapterComponent
}

get componentLibrary () {
if (this.useHtmlComponents && this.framework === 'react') {
if (this.framework === 'react') {
return './runtime/components'
} else if (this.useDeprecatedAdapterComponent) {
return `@tarojs/components/lib/component-lib/${compLibraryAlias[this.framework] || 'react'}`
Expand Down Expand Up @@ -87,11 +83,6 @@ export default class H5 extends TaroPlatformWeb {
args[0].loaderMeta.execBeforeCreateWebApp += `applyPolyfills().then(() => defineCustomElements(window))\n`
}

if (!this.useHtmlComponents) {
args[0].loaderMeta.extraImportForWeb += `import { defineCustomElementTaroPullToRefresh } from '@tarojs/components/dist/components'\n`
args[0].loaderMeta.execBeforeCreateWebApp += `defineCustomElementTaroPullToRefresh()\n`
}

switch (this.framework) {
case 'vue':
args[0].loaderMeta.extraImportForWeb += `import { initVue2Components } from '@tarojs/components/lib/vue2/components-loader'\nimport * as list from '@tarojs/components'\n`
Expand All @@ -102,10 +93,8 @@ export default class H5 extends TaroPlatformWeb {
args[0].loaderMeta.execBeforeCreateWebApp += `initVue3Components(component, list)\n`
break
default:
if (this.useHtmlComponents) {
args[0].loaderMeta.extraImportForWeb += `import { PullDownRefresh } from '@tarojs/components'\n`
args[0].loaderMeta.execBeforeCreateWebApp += `config.PullDownRefresh = PullDownRefresh\n`
}
args[0].loaderMeta.extraImportForWeb += `import { PullDownRefresh } from '@tarojs/components'\n`
args[0].loaderMeta.execBeforeCreateWebApp += `config.PullDownRefresh = PullDownRefresh\n`
}
return args
})
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.