Skip to content

Commit

Permalink
fix(ui,runtime): 组件注册默认以magic-ui-xx的形式,不再需要在组件中设置name
Browse files Browse the repository at this point in the history
fix #291
  • Loading branch information
roymondchen authored and jia000 committed Aug 19, 2022
1 parent 143bded commit de38035
Show file tree
Hide file tree
Showing 20 changed files with 7 additions and 32 deletions.
2 changes: 0 additions & 2 deletions packages/ui-vue2/src/Component.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import { MComponent } from '@tmagic/schema';
import { toLine } from '@tmagic/utils';
export default defineComponent({
name: 'magic-ui-component',
props: {
config: {
type: Object as PropType<MComponent>,
Expand Down
1 change: 0 additions & 1 deletion packages/ui-vue2/src/button/Button.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import type { MComponent } from '@tmagic/schema';
import useApp from '../useApp';
export default defineComponent({
name: 'magic-ui-button',
props: {
config: {
type: Object as PropType<MComponent>,
Expand Down
2 changes: 0 additions & 2 deletions packages/ui-vue2/src/container/Container.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ import useApp from '../useApp';
import useCommonMethod from '../useCommonMethod';
export default defineComponent({
name: 'magic-ui-container',
components: {
'magic-ui-component': Component,
},
Expand Down
1 change: 0 additions & 1 deletion packages/ui-vue2/src/img/src/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { defineComponent } from 'vue';
import useApp from '../../useApp';
export default defineComponent({
name: 'magic-ui-img',
props: {
config: {
type: Object,
Expand Down
1 change: 0 additions & 1 deletion packages/ui-vue2/src/overlay/src/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import type { MNode } from '@tmagic/schema';
import useApp from '../../useApp';
export default defineComponent({
name: 'magic-ui-overlay',
props: {
config: {
type: Object,
Expand Down
2 changes: 0 additions & 2 deletions packages/ui-vue2/src/page/Page.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import Component from '../Component.vue';
import useApp from '../useApp';
export default defineComponent({
name: 'magic-ui-page',
components: {
'magic-ui-component': Component,
},
Expand Down
2 changes: 0 additions & 2 deletions packages/ui-vue2/src/qrcode/src/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import QRCode from 'qrcode';
import useApp from '../../useApp';
export default defineComponent({
name: 'magic-ui-qrcode',
props: {
config: {
type: Object,
Expand Down
2 changes: 0 additions & 2 deletions packages/ui-vue2/src/text/Text.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import type { MComponent } from '@tmagic/schema';
import useApp from '../useApp';
export default defineComponent({
name: 'magic-ui-text',
props: {
config: {
type: Object as PropType<MComponent>,
Expand Down
2 changes: 0 additions & 2 deletions packages/ui/src/Component.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ import Core from '@tmagic/core';
import { toLine } from '@tmagic/utils';
export default defineComponent({
name: 'magic-ui-component',
props: {
config: {
type: Object,
Expand Down
1 change: 0 additions & 1 deletion packages/ui/src/button/src/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { MButton, MButtonInstance, MText } from '../../../src/types';
import useApp from '../../useApp';
export default defineComponent({
name: 'magic-ui-button',
props: {
config: {
type: Object as PropType<MButton>,
Expand Down
2 changes: 0 additions & 2 deletions packages/ui/src/container/src/Container.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ import useApp from '../../useApp';
import useCommonMethod from '../../useCommonMethod';
export default defineComponent({
name: 'magic-ui-container',
components: {
'magic-ui-component': Component,
},
Expand Down
1 change: 0 additions & 1 deletion packages/ui/src/img/src/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { MImg } from '../../types';
import useApp from '../../useApp';
export default defineComponent({
name: 'magic-ui-img',
props: {
config: {
type: Object as PropType<MImg>,
Expand Down
1 change: 0 additions & 1 deletion packages/ui/src/overlay/src/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import type { MNode } from '@tmagic/schema';
import useApp from '../../useApp';
export default defineComponent({
name: 'magic-ui-overlay',
props: {
config: {
type: Object,
Expand Down
2 changes: 0 additions & 2 deletions packages/ui/src/page/src/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import Component from '../../Component.vue';
import useApp from '../../useApp';
export default defineComponent({
name: 'magic-ui-page',
components: {
'magic-ui-component': Component,
},
Expand Down
2 changes: 0 additions & 2 deletions packages/ui/src/qrcode/src/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import { MQrcode } from '../../types';
import useApp from '../../useApp';
export default defineComponent({
name: 'magic-ui-qrcode',
props: {
config: {
type: Object as PropType<MQrcode>,
Expand Down
1 change: 0 additions & 1 deletion packages/ui/src/text/src/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { MComponentInstance, MText, MTextInstance } from '../../../src/types';
import useApp from '../../useApp';
export default defineComponent({
name: 'magic-ui-text',
props: {
config: {
type: Object as PropType<MText>,
Expand Down
2 changes: 1 addition & 1 deletion runtime/vue2/page/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const app = new Core({

Object.keys(components).forEach((type: string) => {
const component = components[type];
Vue.component(component.name, component);
Vue.component(`magic-ui-${type}`, component);
app.registerComponent(type, component);
});

Expand Down
4 changes: 2 additions & 2 deletions runtime/vue2/playground/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import Vue from 'vue';
import App from './App.vue';

Promise.all([import('../.tmagic/comp-entry'), import('../.tmagic/plugin-entry')]).then(([components, plugins]) => {
Object.values(components.default).forEach((component: any) => {
Vue.component(component.name, component);
Object.entries(components.default).forEach(([type, component]: [string, any]) => {
Vue.component(`magic-ui-${type}`, component);
});

Object.values(plugins.default).forEach((plugin: any) => {
Expand Down
4 changes: 2 additions & 2 deletions runtime/vue3/page/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ const magicApp = createApp(AppComponent);

magicApp.use(request);

Object.values(components).forEach((component: any) => {
magicApp.component(component.name, component);
Object.entries(components).forEach(([type, component]: [string, any]) => {
magicApp.component(`magic-ui-${type}`, component);
});

Object.values(plugins).forEach((plugin: any) => {
Expand Down
4 changes: 2 additions & 2 deletions runtime/vue3/playground/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import App from './App.vue';
Promise.all([import('../.tmagic/comp-entry'), import('../.tmagic/plugin-entry')]).then(([components, plugins]) => {
const magicApp = createApp(App);

Object.values(components.default).forEach((component: any) => {
magicApp.component(component.name, component);
Object.entries(components.default).forEach(([type, component]: [string, any]) => {
magicApp.component(`magic-ui-${type}`, component);
});

Object.values(plugins.default).forEach((plugin: any) => {
Expand Down

0 comments on commit de38035

Please sign in to comment.