({
26 | currentDirId: '/'
27 | });
28 |
29 | export const withContext = (
30 | Component: React.ComponentType
31 | ): React.FC> => props => (
32 |
33 | {({
34 | fileMap,
35 | currentDirId,
36 | isCombineEnabled,
37 | onMoveTo,
38 | onClickPreview,
39 | onToggleSwitch,
40 | onUpdateCurrentDir,
41 | renderAddFileElement
42 | }) => (
43 |
54 | )}
55 |
56 | );
57 |
--------------------------------------------------------------------------------
/packages/fm-components/src/elements/SvgIcon.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 |
3 | import { StyleObject } from '../types';
4 |
5 | export interface SvgIconProps {
6 | name?: 'close' | 'file' | 'folder' | 'png-file';
7 | size?: number;
8 | color?: string;
9 |
10 | style?: StyleObject;
11 | fill?: string;
12 | }
13 |
14 | export const SvgIcon = (props: SvgIconProps) => {
15 | const { size = 10, color } = props;
16 |
17 | switch (props.name) {
18 | case 'close': {
19 | return (
20 |
26 | );
27 | }
28 | case 'file': {
29 | return (
30 |
40 | );
41 | }
42 | case 'folder': {
43 | return (
44 |
54 | );
55 | }
56 | }
57 | };
58 |
--------------------------------------------------------------------------------
/packages/fm-components/src/elements/withModal.tsx:
--------------------------------------------------------------------------------
1 | import React, { Component, createRef } from 'react';
2 | import styled from 'styled-components';
3 |
4 | import { StyleObject } from '../types';
5 |
6 | import { SvgIcon } from './SvgIcon';
7 |
8 | export interface ModalProps {
9 | style?: StyleObject;
10 | isDraggale?: boolean;
11 | title?: string;
12 |
13 | onClose?: Function;
14 | }
15 |
16 | export interface IModalState {
17 | originalX: number;
18 | originalY: number;
19 | lastTranslateX: number;
20 | lastTranslateY: number;
21 | translateX: number;
22 | translateY: number;
23 | isDragging: boolean;
24 | }
25 |
26 | export const withModal = (WrappedComponent: React.ComponentType) => (
27 | params: ModalProps
28 | ) =>
29 | class Modal extends Component {
30 | _ref = createRef();
31 | state = {
32 | isDragging: false,
33 | originalX: 0,
34 | originalY: 0,
35 | translateX: 0,
36 | translateY: 0,
37 | lastTranslateX: 0,
38 | lastTranslateY: 0
39 | };
40 |
41 | componentDidMount() {}
42 |
43 | componentWillUnmount() {
44 | this._ref.current.removeEventListener('mousemove', this.handleMouseMove);
45 | this._ref.current.removeEventListener('mouseup', this.handleMouseUp);
46 | }
47 |
48 | handleMouseDown = ({ clientX, clientY }: MouseEvent) => {
49 | if (this.props.isDraggale) {
50 | return;
51 | }
52 |
53 | this._ref.current.addEventListener('mousemove', this.handleMouseMove);
54 | this._ref.current.addEventListener('mouseup', this.handleMouseUp);
55 |
56 | this.setState({
57 | originalX: clientX,
58 | originalY: clientY,
59 | isDragging: true
60 | });
61 | };
62 |
63 | handleMouseMove = ({ clientX, clientY }: MouseEvent) => {
64 | const { isDragging } = this.state;
65 | if (!isDragging) {
66 | return;
67 | }
68 |
69 | this.setState(prevState => ({
70 | translateX: clientX - prevState.originalX + prevState.lastTranslateX,
71 | translateY: clientY - prevState.originalY + prevState.lastTranslateY
72 | }));
73 | };
74 |
75 | handleMouseUp = () => {
76 | this._ref.current.removeEventListener('mousemove', this.handleMouseMove);
77 | this._ref.current.removeEventListener('mouseup', this.handleMouseUp);
78 |
79 | this.setState({
80 | originalX: 0,
81 | originalY: 0,
82 | lastTranslateX: this.state.translateX,
83 | lastTranslateY: this.state.translateY,
84 |
85 | isDragging: false
86 | });
87 | };
88 |
89 | render() {
90 | const { translateX, translateY } = this.state;
91 | const style = params.style ? params.style : this.props.style ? this.props.style : {};
92 | return (
93 |
103 |
104 | {this.props.title}
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 | );
113 | }
114 | };
115 |
116 | const Container = styled.div`
117 | width: 316px;
118 | position: relative;
119 | z-index: 4000;
120 | padding: 20px 0 44px;
121 | background: #fff;
122 | border: 1px solid rgba(221, 224, 228, 0.7);
123 | box-shadow: 0 16px 64px 0 rgba(0, 0, 0, 0.08);
124 | border-radius: 8px;
125 | `;
126 |
127 | const Title = styled.div`
128 | font-family: Lato, sans-serif;
129 | font-size: 18px;
130 | color: #2f363f;
131 | letter-spacing: 0;
132 | `;
133 |
134 | const Heading = styled.div`
135 | width: 100%;
136 | display: flex;
137 | justify-content: center;
138 | `;
139 |
140 | const Close = styled.div`
141 | position: absolute;
142 | top: 10px;
143 | right: 24px;
144 | padding: 13px;
145 | cursor: pointer;
146 | `;
147 |
--------------------------------------------------------------------------------
/packages/fm-components/src/i18n/index.ts:
--------------------------------------------------------------------------------
1 | export function i18n(messageId: string) {
2 | return messageId;
3 | }
4 |
--------------------------------------------------------------------------------
/packages/fm-components/src/index.less:
--------------------------------------------------------------------------------
1 | .container {
2 | position: relative;
3 | }
4 |
--------------------------------------------------------------------------------
/packages/fm-components/src/index.ts:
--------------------------------------------------------------------------------
1 | export * from './types';
2 | export * from './components';
3 |
--------------------------------------------------------------------------------
/packages/fm-components/src/types/FileType.ts:
--------------------------------------------------------------------------------
1 | export interface FileType {
2 | // ID
3 | id?: string;
4 | // 父文件夹 id
5 | parentId?: string | null;
6 |
7 | // 是否为目录
8 | isDir: boolean;
9 | // 文件类型
10 | ext?: string;
11 |
12 | // 名称
13 | name?: string;
14 | // 创建者
15 | creatorName?: string;
16 | // 路径,完整的文件路径
17 | path?: string;
18 | // 大小 in Bytes
19 | size?: number;
20 |
21 | // 创建、更新、删除的时间
22 | createdAt?: string;
23 | updatedAt?: string;
24 | deletedAt?: string;
25 |
26 | // 子路径,字符串或者文件类型
27 | childrenIds?: string[];
28 | children?: FileType[];
29 |
30 | // 用于记述原始对象
31 | originObj?: any;
32 | }
33 |
--------------------------------------------------------------------------------
/packages/fm-components/src/types/common.ts:
--------------------------------------------------------------------------------
1 | export type StyleObject = Record;
2 |
--------------------------------------------------------------------------------
/packages/fm-components/src/types/constants.ts:
--------------------------------------------------------------------------------
1 | export const classPrefix = 'fmc';
2 | export const LOCAL = '__local__';
3 | export const GLOBAL = '__global__';
4 |
5 | export type SearchType = 'LOCAL' | 'GLOBAL';
6 |
--------------------------------------------------------------------------------
/packages/fm-components/src/types/datetime.ts:
--------------------------------------------------------------------------------
1 | const monthNames = [
2 | 'Jan',
3 | 'Feb',
4 | 'Mar',
5 | 'Apr',
6 | 'May',
7 | 'Jun',
8 | 'Jul',
9 | 'Aug',
10 | 'Sep',
11 | 'Oct',
12 | 'Nov',
13 | 'Dec'
14 | ];
15 |
16 | const nth = (d: number) => {
17 | if (d > 3 && d < 21) return 'th';
18 | switch (d % 10) {
19 | case 1:
20 | return 'st';
21 | case 2:
22 | return 'nd';
23 | case 3:
24 | return 'rd';
25 | default:
26 | return 'th';
27 | }
28 | };
29 |
30 | /** 获取今日的时间字符串 */
31 | export const getTodayDate = () => {
32 | const d = new Date();
33 | let month = '' + (d.getMonth() + 1),
34 | day = '' + d.getDate();
35 | const year = d.getFullYear();
36 |
37 | if (month.length < 2) month = '0' + month;
38 | if (day.length < 2) day = '0' + day;
39 |
40 | return [year, month, day].join('-');
41 | };
42 |
43 | export const formatDate = (value: string | number) => {
44 | const date = new Date(value);
45 | const day = date.getDate(),
46 | monthIndex = date.getMonth(),
47 | year = date.getFullYear().toString();
48 | return `${day}${nth(day)} ${monthNames[monthIndex]}, ${year}`;
49 | };
50 |
--------------------------------------------------------------------------------
/packages/fm-components/src/types/index.ts:
--------------------------------------------------------------------------------
1 | export * from './common';
2 | export * from './constants';
3 | export * from './datetime';
4 | export * from './FileType';
5 | export * from './path';
6 | export * from './utils';
7 |
--------------------------------------------------------------------------------
/packages/fm-components/src/types/path.tsx:
--------------------------------------------------------------------------------
1 | import { FileType } from './FileType';
2 |
3 | /** 获取全部路径的集合 */
4 | export const getPathSet = (fileMap: Record) => {
5 | const pathSet = new Set();
6 |
7 | Object.keys(fileMap).forEach(id => {
8 | pathSet.add(fileMap[id].path);
9 | pathSet.add(id);
10 | });
11 |
12 | return pathSet;
13 | };
14 |
15 | /** 从 fileMap 中获取到根文件夹 id */
16 | export const getRootDirId = (fileMap: Record) => {
17 | let dirId: string | null = null;
18 |
19 | Object.keys(fileMap).forEach(id => {
20 | if (fileMap[id].path === '/') {
21 | dirId = id;
22 | }
23 | });
24 |
25 | return dirId;
26 | };
27 |
28 | export const getIdByPath = (path: string, fileMap: Record) => {
29 | let dirId: string | null = null;
30 |
31 | Object.keys(fileMap).forEach(id => {
32 | if (fileMap[id].path === path) {
33 | dirId = id;
34 | }
35 | });
36 |
37 | return dirId;
38 | };
39 |
40 | /** 获取返回的路径 */
41 | export const getGoBackPath = (path: string) => {
42 | const newPath = path.split('/');
43 |
44 | newPath.splice(newPath.length - 1, 1);
45 |
46 | return newPath.join('/') || '/';
47 | };
48 |
49 | /** 根据某个路径获取当前的文件列表 */
50 | export function getDirFiles(dirId: string, fileMap: Record) {
51 | const files: FileType[] = [];
52 |
53 | Object.keys(fileMap).forEach(id => {
54 | if (fileMap[id].parentId === dirId) {
55 | files.push(fileMap[id]);
56 | }
57 | });
58 |
59 | return files;
60 | }
61 |
--------------------------------------------------------------------------------
/packages/fm-components/src/types/utils.ts:
--------------------------------------------------------------------------------
1 | import { FileType } from './FileType';
2 |
3 | /** 复制某个对象 */
4 | export const cloneObj = (obj: T): T => {
5 | if (Object(obj) !== obj) return (obj as unknown) as T;
6 | else if (Array.isArray(obj)) return (obj.map(cloneObj) as unknown) as T;
7 |
8 | return Object.fromEntries(Object.entries(obj).map(([k, v]) => [k, cloneObj(v)]));
9 | };
10 |
11 | /** 获取文件后缀 */
12 | export const getFileExt = (file: FileType) => {
13 | const ext = file.name.split('.').filter(el => el);
14 |
15 | return ext.length >= 2 ? ext[ext.length - 1] : '';
16 | };
17 |
18 | /** 判断重名的文件数目 */
19 | export const getSameNameCnt = (fileMap: Record, entry: FileType) => {
20 | let no = 0;
21 |
22 | fileMap[entry.parentId].childrenIds.forEach((elementId: string) => {
23 | if (fileMap[elementId].name.includes(entry.name) && fileMap[elementId].isDir === entry.isDir) {
24 | no++;
25 | }
26 | });
27 |
28 | return no;
29 | };
30 |
31 | /** 从 Map 当中生成 Tree */
32 | export const generateTreeFromMap = (_fileMap: Record) => {
33 | const rootFiles: FileType[] = [];
34 |
35 | const fileMap: Record = cloneObj>(_fileMap); // create empty list to hold copy
36 |
37 | Object.keys(fileMap).forEach((nodeId: string) => {
38 | // 如果是根目录,则添加到根文件列表中
39 | if (!fileMap[nodeId].parentId) {
40 | return rootFiles.push(fileMap[nodeId]);
41 | }
42 |
43 | const parentId = fileMap[nodeId].parentId;
44 |
45 | if (fileMap[parentId]) {
46 | // 判断是否已存在父
47 | const index = fileMap[parentId].childrenIds.indexOf(nodeId);
48 | if (index > -1) {
49 | fileMap[parentId].children.splice(index, 1);
50 | } else if (fileMap[nodeId].isDir) {
51 | fileMap[parentId].children.push(fileMap[nodeId]);
52 | fileMap[parentId].childrenIds.push(nodeId);
53 | }
54 | }
55 | });
56 |
57 | return { rootFiles, fileMap };
58 | };
59 |
60 | /** 判断文件是否相同 */
61 | export const entriesAreSame = (x: any, y: any) => {
62 | for (const p in x) {
63 | if (x.hasOwnProperty(p) !== y.hasOwnProperty(p)) return false;
64 |
65 | if (x[p] === null && y[p] !== null) return false;
66 | if (x[p] === null && y[p] !== null) return false;
67 |
68 | if (typeof x[p] === 'object') {
69 | if (!entriesAreSame(x[p], y[p])) {
70 | return false;
71 | }
72 | } else if (x[p] != y[p]) return false;
73 | }
74 |
75 | return true;
76 | };
77 |
--------------------------------------------------------------------------------
/packages/fm-components/tsconfig.cjs.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./tsconfig.json",
3 | "compilerOptions": {
4 | "module": "commonjs",
5 | "outDir": "dist/cjs",
6 | "declaration": false
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/packages/fm-components/tsconfig.es.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./tsconfig.json",
3 | "compilerOptions": {
4 | "module": "es6",
5 | "outDir": "dist/es",
6 | "declaration": true,
7 | "declarationDir": "dist/types"
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/packages/fm-components/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "include": ["src/**/*"]
4 | }
5 |
--------------------------------------------------------------------------------
/packages/fm-components/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": ["../../tslint.json"]
3 | }
4 |
--------------------------------------------------------------------------------
/packages/fm-core/.eslintignore:
--------------------------------------------------------------------------------
1 | !/.*.js
2 | *.min.*
3 | *.production.*
4 | *.md
5 | *.js
6 | *.json
7 |
8 | coverage
9 | dist
10 | node_modules
11 | build
12 | scripts
13 |
--------------------------------------------------------------------------------
/packages/fm-core/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = require("../../.eslintrc.js")
--------------------------------------------------------------------------------
/packages/fm-core/.vscode/setting.json:
--------------------------------------------------------------------------------
1 | {
2 | "eslint.validate": [
3 | "javascript",
4 | "javascriptreact",
5 | {
6 | "language": "typescript",
7 | "autoFix": true
8 | },
9 | {
10 | "language": "typescriptreact",
11 | "autoFix": true
12 | }
13 | ]
14 | }
15 |
--------------------------------------------------------------------------------
/packages/fm-core/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | presets: [
3 | [
4 | '@wx-fc',
5 | {
6 | import: true,
7 | react: true,
8 | typescript: true,
9 | },
10 | ],
11 | ],
12 | };
13 |
--------------------------------------------------------------------------------
/packages/fm-core/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@m-fe/ts-lib",
3 | "version": "0.0.1",
4 | "description": "@m-fe/ts-lib",
5 | "repository": {
6 | "type": "git",
7 | "url": "https://github.com/wx-chevalier/fe-boilerplates"
8 | },
9 | "author": "wx-chevalier@github",
10 | "license": "MIT",
11 | "main": "dist/cjs/index.js",
12 | "module": "dist/es/index.js",
13 | "types": "dist/types/index.d.ts",
14 | "files": [
15 | "dist/"
16 | ],
17 | "keywords": [
18 | "webpack",
19 | "react"
20 | ],
21 | "scripts": {
22 | "build": "npm run build:es && npm run build:cjs && npm run build:umd",
23 | "build:cjs": "tsc --project ./tsconfig.cjs.json",
24 | "build:es": "tsc --project ./tsconfig.es.json",
25 | "build:umd": "cross-env NODE_ENV=production webpack -p --config ./scripts/webpack/webpack.config.umd.js",
26 | "clean": "rimraf dist",
27 | "dev": "tsc -w --project ./tsconfig.cjs.json",
28 | "lint": "run-p lint:*",
29 | "lint:es": "cross-env PARSER_NO_WATCH=true eslint . --cache --ext js,md,ts,tsx -f friendly --max-warnings 10",
30 | "lint:ts": "tslint -p . -t stylish",
31 | "lint:tsc": "tsc -p tsconfig.json --incremental false --noEmit",
32 | "test": "jest --config ./scripts/jest/jest.config.js",
33 | "test:cov": "npm run cleanCov && npm test -- --coverage",
34 | "test:watch": "npm test -- --watch"
35 | },
36 | "dependencies": {},
37 | "devDependencies": {
38 | "@wx-fc/app-config": "^0.3.3",
39 | "cross-env": "^6.0.3",
40 | "webpack": "^4.41.2"
41 | },
42 | "browserslist": [
43 | "extends @wx-fc/browserslist-config/modern"
44 | ],
45 | "commitlint": {
46 | "extends": [
47 | "@wx-fc"
48 | ]
49 | },
50 | "prettier": "@wx-fc/prettier-config/semi",
51 | "remarkConfig": {
52 | "plugins": [
53 | "@wx-fc/remark-config"
54 | ]
55 | },
56 | "stylelint": {
57 | "extends": [
58 | "@wx-fc/stylelint-config",
59 | "@wx-fc/stylelint-config/modules"
60 | ],
61 | "rules": {
62 | "font-family-no-missing-generic-family-keyword": null,
63 | "no-descending-specificity": null,
64 | "plugin/no-unsupported-browser-features": null,
65 | "plugin/no-low-performance-animation-properties": null
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/packages/fm-core/scripts/jest/jest.config.js:
--------------------------------------------------------------------------------
1 | const baseConfig = require('../../../../scripts/jest/jest.config');
2 |
3 | module.exports = baseConfig;
4 |
--------------------------------------------------------------------------------
/packages/fm-core/scripts/webpack/webpack.config.umd.js:
--------------------------------------------------------------------------------
1 | const path = require('path');
2 | const merge = require('webpack-merge');
3 |
4 | const umdConfig = require('../../../../scripts/webpack/webpack.config')
5 | .umdConfig;
6 |
7 | const rootPath = process.cwd();
8 |
9 | module.exports = merge(umdConfig, {
10 | output: {
11 | library: 'rtwCore',
12 | },
13 | entry: {
14 | index: path.resolve(rootPath, './src/index.ts'),
15 | },
16 | });
17 |
--------------------------------------------------------------------------------
/packages/fm-core/src/constant/types.ts:
--------------------------------------------------------------------------------
1 | export interface IBasicModule {
2 | // 模块编号
3 | id: string;
4 | // 模块的加载文件路径
5 | module: string;
6 | // 版本
7 | version?: string;
8 | }
9 |
10 | export interface IAppModule extends IBasicModule {
11 | // 模块标题
12 | name: string;
13 | // 引入的 CSS 路径
14 | css?: string | string[];
15 | }
16 |
17 | /** 初始化参数 */
18 | export interface IInitOption {
19 | apps: IAppModule[];
20 | vendors?: IBasicModule[];
21 | }
22 |
--------------------------------------------------------------------------------
/packages/fm-core/src/func/__test__/sum.test.ts:
--------------------------------------------------------------------------------
1 | import { sum } from '../sum';
2 |
3 | test('sum', () => {
4 | expect(sum(1, 2)).toBe(3);
5 | });
6 |
--------------------------------------------------------------------------------
/packages/fm-core/src/func/sum.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * 计算两个值之和
3 | * @param num1
4 | * @param num2
5 | */
6 | export function sum(num1: number, num2: number) {
7 | return num1 + num2;
8 | }
9 |
--------------------------------------------------------------------------------
/packages/fm-core/src/index.ts:
--------------------------------------------------------------------------------
1 | export * from './constant/types';
2 | export { sum } from './func/sum';
3 | export * from './utils/log';
4 |
5 | export const library = 'rtwCore';
6 |
--------------------------------------------------------------------------------
/packages/fm-core/src/registry/Registry.ts:
--------------------------------------------------------------------------------
1 | /** 默认的核心注册类 */
2 | export class Registry {
3 | localMap: Map = new Map();
4 |
5 | set(key: string, value: object) {
6 | this.localMap.set(key, value);
7 | }
8 | }
9 |
10 | export default new Registry();
11 |
--------------------------------------------------------------------------------
/packages/fm-core/src/utils/log.ts:
--------------------------------------------------------------------------------
1 | export function logError(...args: object[]) {
2 | // tslint:disable-next-line
3 | console.log(...args);
4 | }
5 |
--------------------------------------------------------------------------------
/packages/fm-core/tsconfig.cjs.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./tsconfig.json",
3 | "compilerOptions": {
4 | "module": "commonjs",
5 | "outDir": "dist/cjs",
6 | "declaration": false
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/packages/fm-core/tsconfig.es.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./tsconfig.json",
3 | "compilerOptions": {
4 | "module": "es6",
5 | "outDir": "dist/es",
6 | "declaration": true,
7 | "declarationDir": "dist/types"
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/packages/fm-core/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "include": ["src/**/*"]
4 | }
5 |
--------------------------------------------------------------------------------
/packages/fm-core/tsconfig.test.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./tsconfig.json",
3 | "compilerOptions": {
4 | "module": "commonjs"
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/packages/fm-core/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": ["../../tslint.json"]
3 | }
4 |
--------------------------------------------------------------------------------
/scripts/jest/jest.config.js:
--------------------------------------------------------------------------------
1 | module.exports = require('@wx-fc/jest-config/jest.config');
2 |
--------------------------------------------------------------------------------
/scripts/tools/publish_pkgs.sh:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wx-chevalier/web-file-manager/4b2e2cea85dc9ca2496036701a2116c1dcfd46bd/scripts/tools/publish_pkgs.sh
--------------------------------------------------------------------------------
/scripts/tools/release_pkgs.sh:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wx-chevalier/web-file-manager/4b2e2cea85dc9ca2496036701a2116c1dcfd46bd/scripts/tools/release_pkgs.sh
--------------------------------------------------------------------------------
/scripts/tools/start_micro.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -ex
3 |
4 | (cd packages/rtw-host-app && npm start)
--------------------------------------------------------------------------------
/scripts/tools/start_mono.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -ex
3 |
4 | (cd packages/rtw-host-app && npm start)
--------------------------------------------------------------------------------
/scripts/tools/upgrade_pkgs.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -ex
3 |
4 | ncu -u
5 |
6 | (cd ./packages/rtw-core && ncu -u)
7 | (cd ./packages/rtw-bootstrap && ncu -u)
8 | (cd ./packages/rtw-host-app && ncu -u)
9 | (cd ./packages/rtw-mobx-app && ncu -u)
10 |
--------------------------------------------------------------------------------
/scripts/webpack/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = require('@wx-fc/webpack-config')({
2 | useCssModule: false,
3 | themeVars: {
4 | 'primary-color': '#5d4bff',
5 | },
6 | extendedBaseConfig: {
7 | module: {
8 | rules: [
9 | // svg 的加载交于应用自身决定
10 | {
11 | test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
12 | oneOf: [
13 | {
14 | issuer: /\.[jt]sx?$/,
15 | use: [
16 | {
17 | loader: '@svgr/webpack',
18 | // loader: 'svg-inline-loader',
19 | },
20 | ],
21 | },
22 | {
23 | loader: 'url-loader',
24 | },
25 | ],
26 | },
27 | ],
28 | },
29 | resolve: {
30 | alias: {
31 | dayjs: 'dayjs/esm',
32 | moment$: 'dayjs/esm',
33 | systemjs$: 'systemjs/dist/system.js',
34 | },
35 | },
36 | },
37 | });
38 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "@wx-fc/tsconfig/tsconfig.json",
3 | "compilerOptions": {
4 | "baseUrl": ".",
5 | "paths": {
6 | "@/*": ["packages/rtw-host-app/src/*"]
7 | },
8 | "strictFunctionTypes": false,
9 | "strictNullChecks": false,
10 | "suppressImplicitAnyIndexErrors": true
11 | },
12 | "include": ["**/*.ts", "**/*.tsx"]
13 | }
14 |
--------------------------------------------------------------------------------
/tsconfig.test.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./tsconfig.json",
3 | "compilerOptions": {
4 | "module": "commonjs"
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": ["@wx-fc/tslint-config/react", "tslint-config-eslint/prettier"],
3 | "rules": {
4 | "jsx-no-lambda": false,
5 | "ordered-imports": [
6 | true,
7 | {
8 | "grouped-imports": true,
9 | "import-sources-order": "lowercase-first",
10 | "named-imports-order": "lowercase-last",
11 | "groups": [
12 | "^(?!rtw-)(@[^/]|[^@.])",
13 | "^(@/|rtw-)",
14 | "^(../)+",
15 | "^(?!\\./.*\\.less)"
16 | ]
17 | }
18 | ]
19 | },
20 | "linterOptions": {
21 | "exclude": ["**/*.d.ts"]
22 | }
23 | }
24 |
--------------------------------------------------------------------------------