Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Leobanado
Egg-vue-ssr-blog
提交
4e4d2672
E
Egg-vue-ssr-blog
项目概览
Leobanado
/
Egg-vue-ssr-blog
与 Fork 源项目一致
Fork自
inscode / NodeJS
通知
1
Star
1
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
Egg-vue-ssr-blog
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
4e4d2672
编写于
5月 06, 2023
作者:
6
62973268dda6dd3cbb7cce9b
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Auto commit
上级
53d5f274
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
53 addition
and
12 deletion
+53
-12
app/controller/index/index.js
app/controller/index/index.js
+2
-2
app/extend/application.js
app/extend/application.js
+1
-1
app/lib/db/config.js
app/lib/db/config.js
+10
-0
app/lib/db/file.js
app/lib/db/file.js
+6
-6
app/lib/db/mysql.js
app/lib/db/mysql.js
+29
-1
app/web/page/index/index.vue
app/web/page/index/index.vue
+4
-2
package.json
package.json
+1
-0
未找到文件。
app/controller/index/index.js
浏览文件 @
4e4d2672
...
...
@@ -3,8 +3,8 @@ const egg = require('egg');
module
.
exports
=
class
IndexController
extends
egg
.
Controller
{
async
ssr
()
{
const
result
=
this
.
service
.
article
.
getArtilceList
();
await
this
.
ctx
.
render
(
'
index/index.js
'
,
result
);
const
result
=
await
this
.
service
.
article
.
getArtilceList
();
await
this
.
ctx
.
render
(
'
index/index.js
'
,
{
list
:
result
}
);
}
async
csr
()
{
...
...
app/extend/application.js
浏览文件 @
4e4d2672
...
...
@@ -4,7 +4,7 @@ const DBSymbol = Symbol('Application#db');
module
.
exports
=
{
get
db
()
{
if
(
!
this
[
DBSymbol
])
{
this
[
DBSymbol
]
=
Factory
();
this
[
DBSymbol
]
=
Factory
(
'
mysql
'
);
}
return
this
[
DBSymbol
];
},
...
...
app/lib/db/config.js
0 → 100644
浏览文件 @
4e4d2672
const
db
=
{
mysql
:
{
host
:
'
mysql.inscode.run
'
,
user
:
'
root
'
,
password
:
'
inscode
'
,
database
:
'
blog
'
}
}
exports
=
module
.
exports
=
{
db
};
app/lib/db/file.js
浏览文件 @
4e4d2672
...
...
@@ -11,27 +11,27 @@ module.exports = class FileDB extends Base {
this
.
instance
.
_
.
mixin
(
lodashid
);
this
.
create
();
}
create
()
{
async
create
()
{
this
.
instance
.
defaults
({
article
:
[],
user
:
{}
}).
write
();
}
get
(
collectionName
)
{
async
get
(
collectionName
)
{
return
this
.
instance
.
get
(
collectionName
);
}
add
(
collectionName
,
json
)
{
a
sync
a
dd
(
collectionName
,
json
)
{
return
this
.
get
(
collectionName
)
.
push
(
json
)
.
write
();
}
update
(
collectionName
,
where
,
json
)
{
async
update
(
collectionName
,
where
,
json
)
{
return
this
.
get
(
collectionName
).
find
(
where
).
assign
(
json
).
write
();
}
delete
(
collectionName
,
field
)
{
async
delete
(
collectionName
,
field
)
{
return
this
.
get
(
collectionName
).
remove
(
field
).
write
();
}
getPager
(
collectionName
,
json
)
{
async
getPager
(
collectionName
,
json
)
{
const
{
where
,
like
,
...
...
app/lib/db/mysql.js
浏览文件 @
4e4d2672
'
use strict
'
;
const
mysql
=
require
(
'
mysql
'
);
const
Base
=
require
(
'
./base
'
);
module
.
exports
=
class
MySQLDB
extends
Base
{};
const
config
=
require
(
'
./config
'
)
module
.
exports
=
class
MySQLDB
extends
Base
{
constructor
()
{
super
();
this
.
connection
=
mysql
.
createConnection
({
...
config
.
db
.
mysql
});
this
.
connection
.
connect
();
}
getUserById
(
id
)
{
const
sql
=
`select * from user where id =
${
id
}
`
;
return
new
Promise
((
resolve
,
reject
)
=>
{
this
.
connection
.
query
(
sql
,
function
(
err
,
results
,
fields
)
{
err
?
reject
(
err
)
:
resolve
(
results
);
});
});
}
getPager
(
collectionName
,
json
)
{
return
this
.
getUserById
(
1
);
}
};
app/web/page/index/index.vue
浏览文件 @
4e4d2672
...
...
@@ -6,9 +6,9 @@
<div
class=
"post-preview"
>
<div
:href=
"item.url"
>
<h2
class=
"post-title"
>
<a
:href=
"item.url"
target=
"_blank"
style=
"font-size: 26px;"
>
{{
item
.
titl
e
}}
</a>
<a
:href=
"item.url"
target=
"_blank"
style=
"font-size: 26px;"
>
{{
item
.
nam
e
}}
</a>
</h2>
<div
class=
"post-content-preview"
>
{{
item
.
summary
}}
</div>
<div
class=
"post-content-preview"
>
{{
item
.
id
}}
</div>
</div>
<div
class=
"post-meta"
>
Posted by hubcarl on 17-09-24
</div>
</div>
...
...
@@ -69,6 +69,8 @@
window
.
addEventListener
(
'
scroll
'
,
()
=>
{
this
.
loadPage
();
},
false
);
console
.
log
(
400
,
this
)
}
}
</
script
>
...
...
package.json
浏览文件 @
4e4d2672
...
...
@@ -32,6 +32,7 @@
"
lowdb
"
:
"
^1.0.0
"
,
"
mockjs
"
:
"
^1.0.1-beta3
"
,
"
moment
"
:
"
^2.17.1
"
,
"
mysql
"
:
"
^2.18.1
"
,
"
shortid
"
:
"
^2.2.8
"
,
"
showdown
"
:
"
^1.8.6
"
,
"
simplemde
"
:
"
^1.11.2
"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录