Skip to content

Commit 64e4998

Browse files
author
chibing.fy
committed
feat: 初步跑起来
1 parent 75d790c commit 64e4998

File tree

14 files changed

+11307
-442
lines changed

14 files changed

+11307
-442
lines changed

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ test$.js
66
packages/esbuild-import-plugin
77
packages/transform-project
88
packages/gogocode-vue-playground
9+
packages/gogocode-element-playground
910
packages/gogocode-core/umd

packages/gogocode-element-playground/package.json

+7-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,13 @@
1010
"start:vue2": "yarn workspace vue2 run start",
1111
"start:vue3": "yarn workspace vue3 run start"
1212
},
13-
"workspaces": [
14-
"packages/*"
15-
],
13+
"workspaces": {
14+
"packages": ["packages/*"],
15+
"nohoist": ["**/vue", "**/vue/**",
16+
"**/vuex", "**/vuex/**",
17+
"**/vue-router", "**/vue-router/**",
18+
"**/@vue/cli-service", "**/@vue/cli-service/**"]
19+
},
1620
"repository": "[email protected]:mm/gogocode-vue-playground.git",
1721
"author": "chibing.fy",
1822
"license": "MIT",

packages/gogocode-element-playground/packages/main/index.html

+8-4
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,14 @@ <h2 class="tc mt20 mb10">
5050
>
5151
</div>
5252
</div>
53-
</div>
54-
<div class="compare">
55-
<div id="vue2">Vue2 loading...</div>
56-
<div id="vue3">Vue3 loading...</div>
53+
<div class="compare">
54+
<div id="vue2">
55+
<iframe :src="'//localhost:7102'+ selected" frameborder="0"></iframe>
56+
</div>
57+
<div id="vue3">
58+
<iframe :src="'//localhost:7103'+ selected" frameborder="0"></iframe>
59+
</div>
60+
</div>
5761
</div>
5862
</body>
5963
</html>

packages/gogocode-element-playground/packages/main/index.js

+18-22
Original file line numberDiff line numberDiff line change
@@ -28,26 +28,22 @@ new Vue({
2828
},
2929
});
3030

31-
const vue2App = loadMicroApp({
32-
name: 'vue2',
33-
entry: '//localhost:7102',
34-
container: '#vue2',
35-
});
36-
37-
const vue3App = loadMicroApp({
38-
name: 'vue3',
39-
entry: '//localhost:7103',
40-
container: '#vue3',
41-
});
31+
// const vue2App = loadMicroApp({
32+
// name: 'vue2',
33+
// entry: '//localhost:7102',
34+
// container: '#vue2',
35+
// }, {
36+
// sandbox: {
37+
// strictStyleIsolation: true
38+
// }
39+
// });
4240

43-
class TestEle extends HTMLElement {
44-
constructor() {
45-
super();
46-
}
47-
connectedCallback() {
48-
const div = document.createElement('div');
49-
div.innerText = 'haha';
50-
this.append(div);
51-
}
52-
}
53-
window.customElements.define('test-ele', TestEle);
41+
// const vue3App = loadMicroApp({
42+
// name: 'vue3',
43+
// entry: '//localhost:7103',
44+
// container: '#vue3',
45+
// }, {
46+
// sandbox: {
47+
// strictStyleIsolation: true
48+
// }
49+
// });

packages/gogocode-element-playground/packages/main/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"webpack-dev-server": "^3.9.0"
2525
},
2626
"dependencies": {
27-
"qiankun": "^2.4.0",
27+
"qiankun": "2.6.3",
2828
"react": "^16.13.1",
2929
"react-dom": "^16.13.1",
3030
"vue": "^2.6.11",

packages/gogocode-element-playground/packages/vue2/src/components/icon/Comp.vue

+3-26
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22
<div>
33
<p>迁移:{{ name }}</p>
44
<p>Vue版本:{{ version }}</p>
5-
<button v-on:click="add">Add</button>
6-
<button v-on:click="remove">Remove</button>
7-
<ul>
8-
<li v-for="(item,index) in items" v-bind:key="index">{{ item }}</li>
9-
</ul>
5+
<el-button type="primary" icon="el-icon-search">Search</el-button>
106
</div>
117
</template>
128

@@ -15,35 +11,16 @@ import Vue from 'vue';
1511
/* 迁移指南: https://v3.cn.vuejs.org/guide/migration/watch.html */
1612
// vue2 https://cn.vuejs.org/v2/guide/list.html#%E6%95%B0%E7%BB%84%E6%9B%B4%E6%96%B0%E6%A3%80%E6%B5%8B
1713
export default {
18-
name: 'Watch on Arrays',
14+
name: 'icon',
1915
props: {
2016
msg: String,
2117
},
2218
data() {
2319
return {
24-
name: 'Watch on Arrays',
20+
name: 'icon',
2521
version: Vue.version,
26-
items: [1, 2, 3, 4, 5]
2722
};
2823
},
29-
methods: {
30-
randomIndex: function () {
31-
return Math.floor(Math.random() * this.items.length);
32-
},
33-
add: function () {
34-
this.items.push(this.randomIndex());
35-
},
36-
remove: function () {
37-
this.items.splice(this.randomIndex(), 1);
38-
},
39-
},
40-
watch: {
41-
items: {
42-
handler(val, oldVal) {
43-
console.log('items list changed');
44-
},
45-
},
46-
},
4724
};
4825
</script>
4926

packages/gogocode-element-playground/packages/vue2/src/router/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const routes = [
1010
component: () => import(/* webpackChunkName: "home" */ '@/components/Home.vue'),
1111
},
1212
{
13-
path: '/',
13+
path: '/icon',
1414
name: 'icon',
1515
component: () => import(/* webpackChunkName: "icon" */ '@/components/icon/Comp.vue'),
1616
},

packages/gogocode-element-playground/packages/vue3/package.json

+9-8
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,19 @@
99
"lint": "vue-cli-service lint"
1010
},
1111
"dependencies": {
12+
"@element-plus/icons": "^0.0.11",
1213
"core-js": "^3.6.5",
14+
"element-plus": "^2.0.2",
1315
"mitt": "^2.1.0",
14-
"vue": "^3.0.9",
15-
"vue-router": "^4.0.0-beta.11",
16-
"vuex": "^4.0.0-beta.4",
17-
"tiny-emitter": "^2.1.0"
16+
"tiny-emitter": "^2.1.0",
17+
"vue": "^3.2.31",
18+
"vue-router": "^4.0.12",
19+
"vuex": "^4.0.2"
1820
},
1921
"devDependencies": {
20-
"@vue/cli-plugin-babel": "~4.5.0",
21-
"@vue/cli-plugin-eslint": "~4.5.0",
22-
"@vue/cli-service": "~4.5.0",
23-
"@vue/compiler-sfc": "^3.0.9",
22+
"@vue/cli-plugin-babel": "5.0.1",
23+
"@vue/cli-plugin-eslint": "5.0.1",
24+
"@vue/cli-service": "5.0.1",
2425
"babel-eslint": "^10.1.0",
2526
"eslint": "^7.23.0",
2627
"eslint-plugin-vue": "^7.8.0"

packages/gogocode-element-playground/packages/vue3/src/components/icon/Comp.vue

+6-29
Original file line numberDiff line numberDiff line change
@@ -2,49 +2,26 @@
22
<div>
33
<p>迁移:{{ name }}</p>
44
<p>Vue版本:{{ version }}</p>
5-
<button v-on:click="add">Add</button>
6-
<button v-on:click="remove">Remove</button>
7-
<ul>
8-
<li v-for="(item,index) in items" v-bind:key="index">{{ item }}</li>
9-
</ul>
5+
<el-button type="primary" :icon="ElIconSearch">Search</el-button>
106
</div>
117
</template>
128

139
<script>
1410
import { version } from 'vue';
15-
/* 迁移指南: https://v3.cn.vuejs.org/guide/migration/watch.html */
11+
import { Search as ElIconSearch } from '@element-plus/icons'
12+
1613
export default {
17-
name: 'Watch on Arrays',
14+
name: 'icon',
1815
props: {
1916
msg: String,
2017
},
2118
data() {
2219
return {
23-
name: 'Watch on Arrays',
20+
name: 'icon',
2421
version: version,
25-
items: [1, 2, 3, 4, 5],
22+
ElIconSearch,
2623
};
2724
},
28-
methods: {
29-
randomIndex: function () {
30-
return Math.floor(Math.random() * this.items.length);
31-
},
32-
add: function () {
33-
this.items.push(this.randomIndex());
34-
},
35-
remove: function () {
36-
this.items.splice(this.randomIndex(), 1);
37-
},
38-
},
39-
watch: {
40-
//如何知道items是数组类型?
41-
items: {
42-
handler(val, oldVal) {
43-
console.log('items list changed');
44-
},
45-
deep: true,
46-
},
47-
},
4825
};
4926
</script>
5027

packages/gogocode-element-playground/packages/vue3/src/main.js

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import './public-path';
22
import { createApp } from 'vue';
3+
import ElementPlus from 'element-plus'
4+
import 'element-plus/dist/index.css'
35
import { createRouter, createWebHistory } from 'vue-router';
46
import App from './App.vue';
57
import routes from './router';
@@ -22,6 +24,7 @@ function render(props = {}) {
2224
window.$vueApp = instance;
2325
instance.use(router);
2426
instance.use(store);
27+
instance.use(ElementPlus);
2528
instance.mount(container ? container.querySelector('#app') : '#app');
2629
}
2730

packages/gogocode-element-playground/packages/vue3/vue.config.js

-6
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,7 @@ module.exports = {
1414
lintOnSave: false,
1515
devServer: {
1616
hot: true,
17-
disableHostCheck: true,
1817
port,
19-
overlay: {
20-
warnings: false,
21-
errors: true,
22-
},
2318
headers: {
2419
'Access-Control-Allow-Origin': '*',
2520
},
@@ -35,7 +30,6 @@ module.exports = {
3530
// 把子应用打包成 umd 库格式
3631
library: `${name}-[name]`,
3732
libraryTarget: 'umd',
38-
jsonpFunction: `webpackJsonp_${name}`,
3933
},
4034
},
4135
chainWebpack: config => {

0 commit comments

Comments
 (0)