Skip to content

Commit ae2ce50

Browse files
authored
Merge pull request #29 from wu-component/feature/ui-component-marvin
feat:add router package、router example
2 parents deec24f + 368735c commit ae2ce50

38 files changed

+1150
-4
lines changed

packages/web-core-plus/src/reactivity/component/Component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export interface CustomTagOptions {
55
name: string;
66
is?: ComponentEnums;
77
css?: string;
8+
isMountDom?: boolean;
89
options?: ElementDefinitionOptions;
910
}
1011

packages/web-core-plus/src/reactivity/component/WuComponent.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,12 @@ export class WuComponent extends HTMLElement implements BaseCustomComponent {
267267
this.beforeRender();
268268
const rendered = this.render(this.props, this.store);
269269
this.rootNode = diff(null, rendered, null, this);
270-
if (Array.isArray(this.rootNode)) {
271-
this.rootNode.forEach(item => shadowRoot.appendChild(item));
272-
} else {
273-
this.rootNode && shadowRoot.appendChild(this.rootNode);
270+
if (this.$options.isMountDom === true) {
271+
if (Array.isArray(this.rootNode)) {
272+
this.rootNode.forEach(item => shadowRoot.appendChild(item));
273+
} else {
274+
this.rootNode && shadowRoot.appendChild(this.rootNode);
275+
}
274276
}
275277
this.isInstalled = true;
276278
this.rendered();

packages/web-core-plus/src/reactivity/component/define.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import { CustomTagOptions } from "./Component";
22

33
export function define(options: CustomTagOptions, ctor: any) {
4+
// 默认挂载dom
5+
if (options.isMountDom === undefined) {
6+
options.isMountDom = true;
7+
}
48
if (customElements.get(options.name)) {
59
return;
610
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# EditorConfig is awesome: https://EditorConfig.org
2+
3+
root = true
4+
5+
[*]
6+
charset = utf-8
7+
indent_size = 4
8+
indent_style = space
9+
insert_final_newline = true
10+
trim_trailing_whitespace = true
11+
12+
[*.md]
13+
trim_trailing_whitespace = false
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
build/**
2+
dist/**
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
module.exports = {
2+
parser: '@typescript-eslint/parser',
3+
parserOptions: {
4+
sourceType: 'module',
5+
},
6+
plugins: [ '@typescript-eslint/eslint-plugin' ],
7+
extends: [
8+
'plugin:@typescript-eslint/eslint-recommended',
9+
'plugin:@typescript-eslint/recommended',
10+
'prettier',
11+
'prettier/@typescript-eslint',
12+
],
13+
root: true,
14+
env: {
15+
node: true,
16+
jest: true,
17+
'shared-node-browser': true,
18+
es6: true
19+
},
20+
rules: {
21+
'@typescript-eslint/no-empty-interface': 'off',
22+
'@typescript-eslint/no-namespace': 'off',
23+
'@typescript-eslint/ban-types': 'off',
24+
'@typescript-eslint/no-var-requires': 'off',
25+
'@typescript-eslint/interface-name-prefix': 'off',
26+
'@typescript-eslint/explicit-function-return-type': 'off',
27+
'@typescript-eslint/no-explicit-any': 'off',
28+
'@typescript-eslint/explicit-module-boundary-types': 'off',
29+
'@typescript-eslint/ban-ts-comment': 'off',
30+
'@typescript-eslint/no-empty-function': 'off',
31+
'@typescript-eslint/no-unused-vars': 'off',
32+
'prefer-rest-params': 'off',
33+
'@typescript-eslint/no-this-alias': 'off',
34+
'semi':[ 'error','always' ],
35+
'prefer-spread': 'off',
36+
"array-bracket-spacing": [ "error","always" ],
37+
"object-curly-spacing": [ "error","always" ]
38+
},
39+
};

packages/wu-core-router/.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist/bundle-analyzer-report.html

packages/wu-core-router/.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock=false
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "all",
4+
"printWidth": 300,
5+
}

packages/wu-core-router/css.d.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
declare module '*.css' {
2+
const css: string;
3+
export default css;
4+
}
5+
6+
declare module '*.svg' {
7+
const src: string;
8+
export default src;
9+
}
10+
11+
declare module '*.txt' {
12+
const src: string;
13+
export default src;
14+
}
15+
16+
declare module '*.frag' {
17+
const src: string;
18+
export default src;
19+
}
20+
21+
declare module '*.vert' {
22+
const src: string;
23+
export default src;
24+
}
25+
26+
declare module '*?worker' {
27+
export const worker: Worker;
28+
export const workerMsgId: string;
29+
export const workerName: string;
30+
export const workerPath: string;
31+
}
32+
33+
declare module '*?format=url' {
34+
const src: string;
35+
export default src;
36+
}
37+
38+
declare module '*?format=text' {
39+
const content: string;
40+
export default content;
41+
}

0 commit comments

Comments
 (0)