Skip to content

Commit

Permalink
Merge branch 'main' into feat/add_component
Browse files Browse the repository at this point in the history
  • Loading branch information
BoBoooooo committed May 16, 2024
2 parents 3dd6882 + 56d0877 commit c1c2c80
Show file tree
Hide file tree
Showing 23 changed files with 2,491 additions and 23,549 deletions.
2 changes: 1 addition & 1 deletion apps/playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"author": "Wells <ww.sun@outlook.com>",
"scripts": {
"dev": "HOST=local.netease.com PORT=8001 umi dev",
"dev": "cross-env HOST=local.netease.com PORT=8001 umi dev",
"build": "umi build",
"postinstall": "umi setup",
"setup": "umi setup",
Expand Down
24 changes: 24 additions & 0 deletions apps/playground/src/helpers/prototypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,30 @@ const prototypes: Dict<IComponentPrototype> = {
package: '@music163/antd',
hasChildren: true,
siblingNames: ['Box'],
props: [
{
name: 'aaa',
title: 'aaa',
setter: 'textSetter',
},
{
name: 'bbb',
title: 'bbb',
setter: 'textSetter',
deprecated: true,
},
{
name: 'ccc',
title: 'ccc',
setter: 'textSetter',
deprecated: true,
},
{
name: 'd',
title: 'd',
setter: 'textSetter',
},
],
},
Columns: {
name: 'Columns',
Expand Down
1 change: 1 addition & 0 deletions apps/playground/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const menuData = {
'Columns',
'Column',
'Box',
'Text',
'Space',
'Typography',
'Title',
Expand Down
22 changes: 22 additions & 0 deletions apps/storybook/src/setting-form.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { IComponentPrototype } from '@music163/tango-helpers';
import { BorderSetter, DisplaySetter } from '@music163/tango-designer/src/setters/style-setter';
import { JsxSetter } from '@music163/tango-designer/src/setters/jsx-setter';
import { RenderSetter, TableCellSetter } from '@music163/tango-designer/src/setters/render-setter';
import { NumberSetter } from '@music163/tango-designer/src/setters/number-setter';
import { Box } from 'coral-system';
import { JsonView } from '@music163/tango-ui';
import { toJS } from 'mobx';
Expand Down Expand Up @@ -37,6 +38,11 @@ register({
component: TableCellSetter,
});

register({
name: 'numberSetter',
component: NumberSetter,
});

createFromIconfontCN({
scriptUrl: '//at.alicdn.com/t/c/font_2891794_cxbtmzehxyi.js',
});
Expand Down Expand Up @@ -274,6 +280,22 @@ const prototype: IComponentPrototype = {
title: 'invalidSetter',
setter: 'invalidSetter',
},
{
name: 'validate',
title: 'validate',
setter: 'numberSetter',
validate: (value) => {
if (!value && value !== 0) {
return '必填';
}
if (value < 0) {
return '必须大于 0';
}
if (value > 10) {
return '必须小于等于 10';
}
},
},
],
};

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"@typescript-eslint/parser": "^6.13.2",
"conventional-changelog-cli": "^4.1.0",
"copyfiles": "^2.4.1",
"cross-env": "^7.0.3",
"eslint": "^8.55.0",
"eslint-config-ali": "^14.0.2",
"eslint-config-prettier": "^9.1.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/context/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@music163/tango-context",
"version": "1.0.1",
"version": "1.0.2",
"description": "react context for tango-apps",
"keywords": [
"react",
Expand Down Expand Up @@ -31,8 +31,8 @@
"react": ">= 16.8"
},
"dependencies": {
"@music163/tango-core": "^1.0.1",
"@music163/tango-helpers": "^1.0.0-alpha.7",
"@music163/tango-core": "^1.0.2",
"@music163/tango-helpers": "^1.0.0",
"mobx-react-lite": "4.0.5"
},
"publishConfig": {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@music163/tango-core",
"version": "1.0.1",
"version": "1.0.2",
"description": "tango core",
"author": "wwsun <ww.sun@outlook.com>",
"homepage": "",
Expand Down Expand Up @@ -28,7 +28,7 @@
"@babel/parser": "^7.23.5",
"@babel/traverse": "^7.23.5",
"@babel/types": "^7.23.5",
"@music163/tango-helpers": "^1.0.0-alpha.7",
"@music163/tango-helpers": "^1.0.0",
"@types/babel__generator": "^7.6.7",
"@types/babel__traverse": "^7.20.4",
"mobx": "6.12.0",
Expand Down
7 changes: 7 additions & 0 deletions packages/core/src/models/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,16 @@ export interface IWorkspace {
* 解析后的项目配置信息
*/
get projectConfig(): ITangoConfigJson;
/**
* 当前活动的视图文件
*/
get activeViewModule(): IViewFile;
get pages(): any[];
get bizComps(): string[];
get baseComps(): string[];
get localComps(): string[];
/**
* 是否是合法的项目
*/
get isValid(): boolean;
}
20 changes: 18 additions & 2 deletions packages/core/src/models/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,13 @@ export class Workspace extends EventTarget implements IWorkspace {
*/
private copyTempNodes: TangoNode[];

/**
* 是否是合法的项目
*/
get isValid() {
return !!this.tangoConfigJson && !!this.activeViewModule;
}

/**
* 项目配置,返回解析后的 tango.config.json 文件
*/
Expand Down Expand Up @@ -1244,8 +1251,17 @@ export class Workspace extends EventTarget implements IWorkspace {
let filename: string;
this.routeModule?.routes.forEach((route) => {
if (isPathnameMatchRoute(routePath, route.path) && route.importPath) {
const absolutePath = route.importPath.replace('.', '/src');
filename = this.getRealViewFilePath(absolutePath);
if (route.importPath.startsWith('@/')) {
filename = route.importPath;
const alias = this.tangoConfigJson.getValue('sandbox.alias') || {};
if (alias['@']) {
filename = filename.replace('@', alias['@']);
}
filename = this.getRealViewFilePath(filename);
} else {
const absolutePath = route.importPath.replace('.', '/src');
filename = this.getRealViewFilePath(absolutePath);
}
}
});
return filename;
Expand Down
Loading

0 comments on commit c1c2c80

Please sign in to comment.