Skip to content

Commit 4f1d9e2

Browse files
committed
feat: add simple layout example
1 parent bcf9cc7 commit 4f1d9e2

File tree

8 files changed

+89
-2
lines changed

8 files changed

+89
-2
lines changed

app/controller/test.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
'usestrict';
2+
const egg = require('egg');
3+
module.exports = class TestController extends egg.Controller {
4+
5+
async index() {
6+
await this.ctx.render('test.js', {
7+
meta: {
8+
title: 'Egg Vue SSR',
9+
keywords: 'egg,vue,vue sse,easyjs',
10+
description: '基于 Egg + Vue + Webpack SSR 服务端渲染和 CSR 前端渲染工程骨架项目,包括前台系统(SSR MPA)和后台管理系统(SSR SPA)'
11+
},
12+
site: {
13+
name: 'easyjs',
14+
url: 'https://easyjs.cn'
15+
}
16+
});
17+
}
18+
19+
};

app/router.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module.exports = app => {
88
router.get('/category', controller.category.category.index);
99
router.get('/login', controller.admin.admin.login);
1010
router.get('/about', controller.admin.admin.login);
11+
router.get('/test', controller.test.index);
1112
router.post('/admin/api/article/list', controller.admin.admin.list);
1213
router.post('/admin/api/article/add', controller.admin.admin.add);
1314
router.get('/admin/api/article/del/:id', controller.admin.admin.del);

app/web/component/layout/index/header/header.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
<li>
2323
<a href="/admin">{{$t('menu.admin')}}</a>
2424
</li>
25+
<li>
26+
<a href="/test">{{$t('menu.test')}}</a>
27+
</li>
2528
</ul>
2629
</div>
2730
</div>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<template>
2+
<html v-if="isNode">
3+
<head>
4+
<title>{{meta.title}}</title>
5+
<meta name="keywords" :content="meta.keywords">
6+
<meta name="description" :content="meta.description">
7+
<meta http-equiv="content-type" content="text/html;charset=utf-8">
8+
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui">
9+
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
10+
</head>
11+
<body>
12+
<div id="app" data-server-rendered="true"><slot></slot></div>
13+
</body>
14+
</html>
15+
<div v-else-if="!isNode" id="app"><slot></slot></div>
16+
</template>
17+
<style>
18+
</style>
19+
<script type='babel'>
20+
export default {
21+
props: ['meta'],
22+
data() {
23+
return {
24+
isNode: EASY_ENV_IS_NODE
25+
}
26+
}
27+
}
28+
</script>

app/web/framework/i18n/site/cn.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ export default {
44
home: '首页',
55
category: '分类',
66
about: '关于',
7-
admin: '管理'
7+
admin: '管理',
8+
test: 'easyjs'
89
},
910
lang: {
1011
href: '/?locale=en',

app/web/framework/i18n/site/en.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ export default {
33
home: 'Home',
44
category: 'Catetory',
55
about: 'About',
6-
admin: 'Admin'
6+
admin: 'Admin',
7+
test: 'easyjs'
78
},
89
lang: {
910
href: '/?locale=cn',

app/web/page/test/test.vue

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<template>
2+
<SimpleLayout :meta="meta">
3+
<div>
4+
<h1 style="text-align:center; display:none">{{site.name}}</h1>
5+
<iframe width="100%" height="800px" frameborder="no" :src="site.url"></iframe>
6+
</div>
7+
</SimpleLayout>
8+
</template>
9+
<style>
10+
</style>
11+
<script type='babel'>
12+
import SimpleLayout from 'component/layout/simple/index.vue';
13+
export default {
14+
components: {
15+
SimpleLayout
16+
},
17+
data(){
18+
return {
19+
20+
}
21+
},
22+
computed: {
23+
24+
},
25+
methods: {
26+
27+
},
28+
mounted() {
29+
30+
}
31+
}
32+
</script>
33+

webpack.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module.exports = {
88
'about/about': 'app/web/page/about/about.vue',
99
'admin/home/home': 'app/web/page/admin/home/home.vue',
1010
'admin/login/login': 'app/web/page/admin/login/login.vue',
11+
'test': 'app/web/page/test/test.vue'
1112
},
1213
plugins: [
1314
{ imagemini: false }

0 commit comments

Comments
 (0)