Skip to content

Commit

Permalink
feat: 将createApp改名为setupApp (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
yiludege authored Aug 16, 2022
1 parent a093062 commit 8aa3218
Show file tree
Hide file tree
Showing 15 changed files with 44 additions and 44 deletions.
14 changes: 7 additions & 7 deletions examples/main-react/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ import credentialsFetch from "./fetch";
import lifecycles from "./lifecycle";
import plugins from "./plugin";

const { createApp, preloadApp, bus } = WujieReact;
const { setupApp, preloadApp, bus } = WujieReact;
const isProduction = process.env.NODE_ENV === "production";
bus.$on("click", (msg) => window.alert(msg));

const degrade = window.localStorage.getItem("degrade") === "true" || !window.Proxy || !window.CustomElementRegistry;
// 创建应用,主要是设置配置,preloadApp、startApp的配置基于这个配置做覆盖
createApp({
setupApp({
name: "react16",
url: hostMap("//localhost:7600/"),
attrs: isProduction ? { src: hostMap("//localhost:7600/") } : {},
Expand All @@ -32,7 +32,7 @@ createApp({
...lifecycles,
});

createApp({
setupApp({
name: "react17",
url: hostMap("//localhost:7100/"),
attrs: isProduction ? { src: hostMap("//localhost:7100/") } : {},
Expand All @@ -44,7 +44,7 @@ createApp({
...lifecycles,
});

createApp({
setupApp({
name: "vue2",
url: hostMap("//localhost:7200/"),
attrs: isProduction ? { src: hostMap("//localhost:7200/") } : {},
Expand All @@ -55,7 +55,7 @@ createApp({
...lifecycles,
});

createApp({
setupApp({
name: "vue3",
url: hostMap("//localhost:7300/"),
attrs: isProduction ? { src: hostMap("//localhost:7300/") } : {},
Expand All @@ -70,7 +70,7 @@ createApp({
...lifecycles,
});

createApp({
setupApp({
name: "angular12",
url: hostMap("//localhost:7400/"),
attrs: isProduction ? { src: hostMap("//localhost:7400/") } : {},
Expand All @@ -81,7 +81,7 @@ createApp({
...lifecycles,
});

createApp({
setupApp({
name: "vite",
url: hostMap("//localhost:7500/"),
attrs: isProduction ? { src: hostMap("//localhost:7500/") } : {},
Expand Down
14 changes: 7 additions & 7 deletions examples/main-vue/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import lifecycles from "./lifecycle";
import plugins from "./plugin";

const isProduction = process.env.NODE_ENV === "production";
const { createApp, preloadApp, bus } = WujieVue;
const { setupApp, preloadApp, bus } = WujieVue;
Vue.use(WujieVue).use(Switch).use(Tooltip).use(button).use(Icon);

Vue.config.productionTip = false;
Expand All @@ -31,7 +31,7 @@ const props = {
},
};
// 创建应用,主要是设置配置,preloadApp、startApp的配置基于这个配置做覆盖
createApp({
setupApp({
name: "react16",
url: hostMap("//localhost:7600/"),
attrs: isProduction ? { src: hostMap("//localhost:7600/") } : {},
Expand All @@ -46,7 +46,7 @@ createApp({
...lifecycles,
});

createApp({
setupApp({
name: "react17",
url: hostMap("//localhost:7100/"),
attrs: isProduction ? { src: hostMap("//localhost:7100/") } : {},
Expand All @@ -59,7 +59,7 @@ createApp({
...lifecycles,
});

createApp({
setupApp({
name: "vue2",
url: hostMap("//localhost:7200/"),
attrs: isProduction ? { src: hostMap("//localhost:7200/") } : {},
Expand All @@ -71,7 +71,7 @@ createApp({
...lifecycles,
});

createApp({
setupApp({
name: "vue3",
url: hostMap("//localhost:7300/"),
attrs: isProduction ? { src: hostMap("//localhost:7300/") } : {},
Expand All @@ -87,7 +87,7 @@ createApp({
...lifecycles,
});

createApp({
setupApp({
name: "angular12",
url: hostMap("//localhost:7400/"),
attrs: isProduction ? { src: hostMap("//localhost:7400/") } : {},
Expand All @@ -99,7 +99,7 @@ createApp({
...lifecycles,
});

createApp({
setupApp({
name: "vite",
url: hostMap("//localhost:7500/"),
attrs: isProduction ? { src: hostMap("//localhost:7500/") } : {},
Expand Down
2 changes: 1 addition & 1 deletion packages/wujie-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ if (!wujieSupport) warn(WUJIE_TIPS_NOT_SUPPORTED);
/**
* 缓存子应用配置
*/
export function createApp(options: cacheOptions): void {
export function setupApp(options: cacheOptions): void {
if (options.name) addSandboxCacheWithOptions(options.name, options);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/wujie-doc/docs/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ module.exports = {
sidebarDepth: 2,
children: [
'bus.md',
'createApp.md',
'setupApp.md',
'startApp.md',
'preloadApp.md',
'destroyApp.md'
Expand Down
4 changes: 2 additions & 2 deletions packages/wujie-doc/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ footer: Copyright © 2021-present yiludege
---

```javascript
import { bus, createApp, preloadApp, startApp, destroyAPP } from "wujie";
import { bus, setupApp, preloadApp, startApp, destroyAPP } from "wujie";

createApp({ name: "唯一id", url: "子应用路径", exec: true, el: "容器", sync: true });
setupApp({ name: "唯一id", url: "子应用路径", exec: true, el: "容器", sync: true });

preloadApp({ name: "唯一id" });

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# createApp
# setupApp

- **类型:** `Function`

Expand Down Expand Up @@ -51,5 +51,5 @@ type cacheOptions {
};
```

- **详情:** `createApp`创建子应用,主要作用是设置子应用默认属性[startApp](/api/startApp.html)[preloadApp](/api/preloadApp.html) 会从这里获取子应用默认属性,如果有相同的属性则会直接覆盖
- **详情:** `setupApp`设置子应用默认属性[startApp](/api/startApp.html)[preloadApp](/api/preloadApp.html) 会从这里获取子应用默认属性,如果有相同的属性则会直接覆盖

4 changes: 2 additions & 2 deletions packages/wujie-doc/docs/guide/start.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ collapsable: false
### 引入

```javascript
import { bus, createApp, preloadApp, startApp, destroyApp } from "wujie";
import { bus, setupApp, preloadApp, startApp, destroyApp } from "wujie";
```

::: tip 提示
Expand All @@ -18,7 +18,7 @@ import { bus, createApp, preloadApp, startApp, destroyApp } from "wujie";
### 创建主应用

```javascript
createApp({{ name: "唯一id", url: "子应用地址", exec: true, el: "容器", sync: true }})
setupApp({{ name: "唯一id", url: "子应用地址", exec: true, el: "容器", sync: true }})
```

### 预加载
Expand Down
10 changes: 5 additions & 5 deletions packages/wujie-doc/docs/pack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import WujieVue from "wujie-vue2";
// vue3
import WujieVue from "wujie-vue3";

const { bus, createApp, preloadApp, destroyApp } = WujieVue;
const { bus, setupApp, preloadApp, destroyApp } = WujieVue;

Vue.use(WujieVue);
```
Expand Down Expand Up @@ -53,9 +53,9 @@ Vue.use(WujieVue);

[同 API](/api/bus.html)

### createApp
### setupApp

[同 API](/api/createApp.html)
[同 API](/api/setupApp.html)

### preloadApp

Expand All @@ -69,7 +69,7 @@ Vue.use(WujieVue);

```javascript
import Vue from "vue";
import { bus, preloadApp, startApp, destroyApp } from "wujie";
import { bus, setupApp, preloadApp, startApp, destroyApp } from "wujie";
import { createApp, h, defineComponent } from "vue";
const vue3Flag = !!createApp;

Expand Down Expand Up @@ -164,7 +164,7 @@ const wujieVueOptions = {

const WujieVue = vue3Flag ? defineComponent(wujieVueOptions) : Vue.extend(wujieVueOptions);

WujieVue.createApp = createApp;
WujieVue.setupApp = setupApp;
WujieVue.preloadApp = preloadApp;
WujieVue.bus = bus;
WujieVue.destroyApp = destroyApp;
Expand Down
10 changes: 5 additions & 5 deletions packages/wujie-doc/docs/pack/react.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ npm i wujie-react -S
```javascript
import WujieReact from "wujie-react";

const { bus, createApp, preloadApp, destroyApp } = WujieReact;
const { bus, setupApp, preloadApp, destroyApp } = WujieReact;
```

## 使用
Expand All @@ -42,9 +42,9 @@ const { bus, createApp, preloadApp, destroyApp } = WujieReact;

[同 API](/api/bus.html)

### createApp
### setupApp

[同 API](/api/createApp.html)
[同 API](/api/setupApp.html)

### preloadApp

Expand All @@ -59,7 +59,7 @@ const { bus, createApp, preloadApp, destroyApp } = WujieReact;
```javascript
import React from "react";
import PropTypes from "prop-types";
import { bus, preloadApp, startApp, destroyApp } from "wujie";
import { bus, setupApp ,preloadApp, startApp, destroyApp } from "wujie";

export default class WujieReact extends React.PureComponent {
static propTypes = {
Expand All @@ -86,7 +86,7 @@ export default class WujieReact extends React.PureComponent {
loadError: PropTypes.func,
};
static bus = bus;
static createApp = createApp;
static setupApp = setupApp;
static preloadApp = preloadApp;
static destroyApp = destroyApp;

Expand Down
4 changes: 2 additions & 2 deletions packages/wujie-react/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { bus, preloadApp, destroyApp, createApp } from "wujie";
import { bus, preloadApp, destroyApp, setupApp } from "wujie";
import PropTypes from "prop-types";
import React from "react";

Expand Down Expand Up @@ -27,7 +27,7 @@ export default class WujieReact extends React.PureComponent {
loadError: typeof PropTypes.func,
};
static bus: typeof bus;
static createApp: typeof createApp;
static setupApp: typeof setupApp;
static preloadApp: typeof preloadApp;
static destroyApp: typeof destroyApp;
}
4 changes: 2 additions & 2 deletions packages/wujie-react/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import PropTypes from "prop-types";
import { bus, preloadApp, startApp, destroyApp, createApp } from "wujie";
import { bus, preloadApp, startApp, destroyApp, setupApp } from "wujie";

export default class WujieReact extends React.PureComponent {
static propTypes = {
Expand Down Expand Up @@ -28,7 +28,7 @@ export default class WujieReact extends React.PureComponent {
loadError: PropTypes.func,
};
static bus = bus;
static createApp = createApp;
static setupApp = setupApp;
static preloadApp = preloadApp;
static destroyApp = destroyApp;

Expand Down
4 changes: 2 additions & 2 deletions packages/wujie-vue2/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import Vue from "vue";
import { bus, preloadApp, destroyApp, createApp } from "wujie";
import { bus, preloadApp, destroyApp, setupApp } from "wujie";

declare const WujieVue: {
bus: typeof bus;
createApp: typeof createApp;
setupApp: typeof setupApp;
preloadApp: typeof preloadApp;
destroyApp: typeof destroyApp;
install: (Vue: Vue) => void;
Expand Down
4 changes: 2 additions & 2 deletions packages/wujie-vue2/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Vue from "vue";
import { bus, preloadApp, startApp, destroyApp, createApp } from "wujie";
import { bus, preloadApp, startApp, destroyApp, setupApp } from "wujie";

const wujieVueOptions = {
name: "WujieVue",
Expand Down Expand Up @@ -93,7 +93,7 @@ const wujieVueOptions = {

const WujieVue = Vue.extend(wujieVueOptions);

WujieVue.createApp = createApp;
WujieVue.setupApp = setupApp;
WujieVue.preloadApp = preloadApp;
WujieVue.bus = bus;
WujieVue.destroyApp = destroyApp;
Expand Down
4 changes: 2 additions & 2 deletions packages/wujie-vue3/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { bus, preloadApp, destroyApp, createApp } from "wujie";
import { bus, preloadApp, destroyApp, setupApp } from "wujie";
import { App } from "vue";

declare const WujieVue: {
bus: typeof bus;
createApp: typeof createApp;
setupApp: typeof setupApp;
preloadApp: typeof preloadApp;
destroyApp: typeof destroyApp;
install: (app: App) => any;
Expand Down
4 changes: 2 additions & 2 deletions packages/wujie-vue3/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { bus, preloadApp, startApp, destroyApp, createApp } from "wujie";
import { bus, preloadApp, startApp, destroyApp, setupApp } from "wujie";
import { h, defineComponent } from "vue";

const wujieVueOptions = {
Expand Down Expand Up @@ -93,7 +93,7 @@ const wujieVueOptions = {

const WujieVue = defineComponent(wujieVueOptions);

WujieVue.createApp = createApp;
WujieVue.setupApp = setupApp;
WujieVue.preloadApp = preloadApp;
WujieVue.bus = bus;
WujieVue.destroyApp = destroyApp;
Expand Down

0 comments on commit 8aa3218

Please sign in to comment.