Skip to content

Commit

Permalink
feat: add new subapp
Browse files Browse the repository at this point in the history
  • Loading branch information
zhoushaw committed May 24, 2021
1 parent 571dc0e commit 65f8380
Show file tree
Hide file tree
Showing 29 changed files with 660 additions and 58 deletions.
3 changes: 2 additions & 1 deletion dev/main/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import GarfishInstance, { Garfish } from '@garfish/core';
import GarfishInstance from '@garfish/core';

GarfishInstance.run({
basename: '/garfish_master',
Expand Down Expand Up @@ -57,6 +57,7 @@ document.getElementById('reactBtn').onclick = async () => {
}
};

export function provider() {}
// setTimeout(() => {
// throw new Error('main error');
// }, 3000);
23 changes: 23 additions & 0 deletions dev/subApp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.DS_Store
node_modules
/dist

# local env files
.env.local
.env.*.local

# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*

# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
package-lock.json
1 change: 1 addition & 0 deletions dev/subApp/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
registry = 'https://registry.npmjs.org'
24 changes: 24 additions & 0 deletions dev/subApp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# vue

## Project setup
```
npm install
```

### Compiles and hot-reloads for development
```
npm run serve
```

### Compiles and minifies for production
```
npm run build
```

### Lints and fixes files
```
npm run lint
```

### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).
3 changes: 3 additions & 0 deletions dev/subApp/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
presets: ['@vue/cli-plugin-babel/preset'],
};
21 changes: 21 additions & 0 deletions dev/subApp/linkdeps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const { exec } = require('child_process');

[
'@garfish/core',
'@garfish/router',
'@garfish/browser-snapshot',
'@garfish/browser-vm',
'@garfish/core',
'@garfish/loader',
'@garfish/cjs-app',
].forEach((item) => {
console.log(`link ${item}`);
exec(`yarn link ${item}`, (error, stdout, stderr) => {
if (error) {
console.error(`执行的错误: ${error}`);
return;
}
stdout && console.log(`stdout: ${stdout}`);
stderr && console.error(`stderr: ${stderr}`);
});
});
42 changes: 42 additions & 0 deletions dev/subApp/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"name": "vue",
"version": "0.1.0",
"private": true,
"scripts": {
"start": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"core-js": "^3.6.5",
"element-ui": "^2.14.1",
"vue": "^2.6.11",
"vue-router": "^3.4.3",
"vuex": "^3.5.1",
"@garfish/core": "0.0.8-alpha.5"
},
"devDependencies": {
"@vue/cli-plugin-babel": "~4.4.0",
"@vue/cli-plugin-eslint": "~4.4.0",
"@vue/cli-service": "~4.4.0",
"babel-eslint": "^10.1.0",
"eslint": "^6.7.2",
"eslint-plugin-vue": "^6.2.2",
"vue-template-compiler": "^2.6.11"
},
"eslintConfig": {
"root": true,
"env": {
"node": true,
"browser": true
},
"extends": [
"plugin:vue/essential",
"eslint:recommended"
],
"parserOptions": {
"parser": "babel-eslint"
},
"rules": {}
}
}
3 changes: 3 additions & 0 deletions dev/subApp/public/async.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
console.log('async');

throw 121;
4 changes: 4 additions & 0 deletions dev/subApp/public/css/xxx/xx.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
body {
margin: 10px;
background: url(../../favicon.ico) no-repeat;
}
Binary file added dev/subApp/public/favicon.ico
Binary file not shown.
69 changes: 69 additions & 0 deletions dev/subApp/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href=/asdf.png>
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<!-- <link rel="stylesheet" href="<%= BASE_URL %>/css/xxx/xx.css"> -->
<style>
#MainApp {
background-color: #5692ce;
}
</style>
<script>
window.addEventListener('unhandledrejection', event => {
event.promise.catch((e)=>{
if (e instanceof Error) {
console.log('vue app get error:', event); // 捕获后自定义处理
}else {
console.log(e);
}
})
console.log('vue app get error:', event);
}, true);
window.addEventListener('error', event => {
console.log('vue app get error:', event); // 捕获后自定义处理
}, true);
</script>
<script type="module">
import a from 'http://localhost:9090/module.js';
</script>
<!-- <title><%= htmlWebpackPlugin.options.title %></title> -->
</head>
<script>
// console.log(document.getElementById('subVue'), document.head, 'document.head');
</script>
<body>
<noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
<img src="xxx" />
<video src="1xxx" ></video>
<div>
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20">
<g fill="none" fill-rule="evenodd">
<path d="M0 0H20V20H0z"/>
<path fill="currentColor" d="M10 .833c5.063 0 9.167 4.104 9.167 9.167S15.063 19.167 10 19.167.833 15.063.833 10 4.937.833 10 .833zM10 2.5c-4.142 0-7.5 3.358-7.5 7.5 0 4.142 3.358 7.5 7.5 7.5 4.142 0 7.5-3.358 7.5-7.5 0-4.142-3.358-7.5-7.5-7.5zM8.14 5.69l1.768 1.768 1.767-1.768c.163-.162.427-.162.59 0l.589.59c.163.162.163.426 0 .589l-2.068 2.067h2.13c.23 0 .417.187.417.417v.833c0 .23-.186.417-.416.417h-2.084v1.064h2.084c.23 0 .416.186.416.416v.834c0 .23-.186.416-.416.416h-2.084v1.25c0 .23-.186.417-.416.417h-.834c-.23 0-.416-.187-.416-.417v-1.25H7.083c-.23 0-.416-.186-.416-.416v-.834c0-.23.186-.416.416-.416h2.084v-1.064H7.083c-.23 0-.416-.187-.416-.417v-.833c0-.23.186-.417.416-.417h1.945l-.004-.005L6.96 6.87c-.162-.163-.162-.427 0-.59l.59-.589c.162-.162.426-.162.589 0z"/>
</g>
</svg>
</div>
</body>
<script>
// console.log('test', document.currentScript);
// setTimeout(() => {
// console.log('test2', document.currentScript);
// })
// b = 2;
// window.onload = function(e) {
// console.log('onload', e);
// }
// window.onerror = function (...args) {
// console.log('vue app get error:', ...args);
// }
</script>
<!-- <script src="<%= BASE_URL %>xxxasync.js" async></script> -->
</html>
4 changes: 4 additions & 0 deletions dev/subApp/public/module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const a = {
esmodule: true,
};
export default a;
53 changes: 53 additions & 0 deletions dev/subApp/src/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<template>
<div id="app">
<img alt="Vue logo" src="./assets/logo.png">
<div>
<router-link to="/">Home </router-link><br />
<router-link to="/todo">Go to Foo</router-link>
</div>
<router-view />
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20">
<g fill="none" fill-rule="evenodd">
<path d="M0 0H20V20H0z"/>
<path fill="currentColor" d="M10 .833c5.063 0 9.167 4.104 9.167 9.167S15.063 19.167 10 19.167.833 15.063.833 10 4.937.833 10 .833zM10 2.5c-4.142 0-7.5 3.358-7.5 7.5 0 4.142 3.358 7.5 7.5 7.5 4.142 0 7.5-3.358 7.5-7.5 0-4.142-3.358-7.5-7.5-7.5zM8.14 5.69l1.768 1.768 1.767-1.768c.163-.162.427-.162.59 0l.589.59c.163.162.163.426 0 .589l-2.068 2.067h2.13c.23 0 .417.187.417.417v.833c0 .23-.186.417-.416.417h-2.084v1.064h2.084c.23 0 .416.186.416.416v.834c0 .23-.186.416-.416.416h-2.084v1.25c0 .23-.186.417-.416.417h-.834c-.23 0-.416-.187-.416-.417v-1.25H7.083c-.23 0-.416-.186-.416-.416v-.834c0-.23.186-.416.416-.416h2.084v-1.064H7.083c-.23 0-.416-.187-.416-.417v-.833c0-.23.186-.417.416-.417h1.945l-.004-.005L6.96 6.87c-.162-.163-.162-.427 0-.59l.59-.589c.162-.162.426-.162.589 0z"/>
</g>
</svg>
<el-button
plain
@click="open1">
可自动关闭
</el-button>
<div id="vueApp"></div>
</div>
</template>

<script>
export default {
name: 'App',
methods: {
open1() {
// const h = this.$createElement;
throw new Error('vue sub app error')
// this.$notify({
// title: '标题名称',
// message: h('i', { style: 'color: teal'}, '这是提示文案这是提示文案这是提示文案这是提示文案这是提示文案这是提示文案这是提示文案这是提示文案')
// });
}
},
components: {
}
}
</script>

<style>
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
</style>
Binary file added dev/subApp/src/assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions dev/subApp/src/components/HelloWorld.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<template>
<div class="hello">
<h1>{{ msg }}</h1>
<p>
Thank you for using Gar
</p>
</div>
</template>

<script>
export default {
name: 'HelloWorld',
props: {
msg: String
}
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
margin: 40px 0 0;
}
ul {
list-style-type: none;
padding: 0;
}
li {
display: inline-block;
margin: 0 10px;
}
a {
color: #42b983;
}
</style>
50 changes: 50 additions & 0 deletions dev/subApp/src/components/test.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<template>
<div>
<span >test</span>
<div>
<input v-model="item.text" placeholder="task desc"/><button @click="add" >添加任务----来自调试的模块</button>
</div>
<div>
<ul>
<li v-for="todo in todos" :key="todo.id">
{{ todo.text }}
{{ todo.done ? 'done' : 'undergoing' }}
<button v-if="!todo.done" @click="done(todo.id)">完成</button>
</li>
</ul>
</div>
</div>
</template>
<script>
import { mapState } from 'vuex'
export default {
data() {
return {
item: {
text: '',
done: false
}
}
},
computed: mapState([
// 映射 this.count 为 store.state.count
'todos'
]),
methods: {
add() {
this.$store.dispatch('add', this.item)
this.item = { text: '', done: false }
},
done(id) {
this.$store.dispatch('done', id)
}
}
}
</script>

<style>
li {
list-style-type: none;
}
</style>
Loading

0 comments on commit 65f8380

Please sign in to comment.