├── src ├── store │ ├── actions.js │ ├── getters.js │ ├── mutation-types.js │ ├── state.js │ ├── mutations.js │ └── index.js ├── assets │ ├── bg.jpg │ ├── Wechat.jpg │ ├── avatar.jpg │ ├── cl_1.png │ ├── logo.png │ └── selfInfo.jpg ├── components │ ├── front │ │ ├── TagCloud.vue │ │ ├── MaskScreen.vue │ │ ├── BottomFooter.vue │ │ ├── RightContent.vue │ │ ├── RightSearch.vue │ │ ├── BreadCrumb.vue │ │ ├── ArticleList.vue │ │ ├── TopHeader.vue │ │ └── LeftEntry.vue │ ├── Iconfont.vue │ └── admin │ │ ├── Aside.vue │ │ └── TopHeader.vue ├── views │ ├── admin │ │ ├── SelfInfo.vue │ │ ├── User.vue │ │ ├── Admin.vue │ │ ├── ArticleList.vue │ │ └── Markdown.vue │ └── front │ │ ├── Catalog.vue │ │ ├── Article.vue │ │ ├── Container.vue │ │ ├── Home.vue │ │ ├── About.vue │ │ └── Login.vue ├── common │ ├── css │ │ ├── variable.scss │ │ └── reset.scss │ └── js │ │ ├── tool.js │ │ └── mixin.js ├── App.vue ├── serviceAPI.config.js ├── main.js └── router.js ├── articles ├── 5bf38b09d2fad55e96a30fbb_666.md ├── 5d2c24b96345ec09e0d99d34_66666.md ├── 5bf38b09d2fad55e96a30fbb_666.html ├── 5d2c24b96345ec09e0d99d34_66666.html ├── vue+node+mysql搭建个人博客(二).md ├── vue+node+mysql搭建个人博客(一).md ├── 5d2c3ebf6345ec09e0d99d35_555.md └── 5d3aa128f6d6eb0c9404ac1d_aaaaaa.md ├── babel.config.js ├── public ├── favicon.ico ├── favicon-1.ico └── index.html ├── version └── version-1.zip ├── server ├── jsonData │ ├── user.js │ └── article.js ├── api │ ├── root.js │ ├── tag.js │ ├── tencentCloud.js │ ├── tool.js │ ├── email.js │ ├── user.js │ └── article.js ├── router.js ├── database │ ├── schema │ │ ├── tag.js │ │ ├── user.js │ │ └── article.js │ └── init.js └── index.js ├── .babelrc ├── .gitignore ├── README.md ├── vue.config.js └── package.json /src/store/actions.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /articles/5bf38b09d2fad55e96a30fbb_666.md: -------------------------------------------------------------------------------- 1 | 666 -------------------------------------------------------------------------------- /articles/5d2c24b96345ec09e0d99d34_66666.md: -------------------------------------------------------------------------------- 1 | 666666 -------------------------------------------------------------------------------- /articles/5bf38b09d2fad55e96a30fbb_666.html: -------------------------------------------------------------------------------- 1 |
666
2 | -------------------------------------------------------------------------------- /articles/5d2c24b96345ec09e0d99d34_66666.html: -------------------------------------------------------------------------------- 1 |666666
2 | -------------------------------------------------------------------------------- /src/store/getters.js: -------------------------------------------------------------------------------- 1 | export const mobileFlag = state => state.mobileFlag -------------------------------------------------------------------------------- /src/store/mutation-types.js: -------------------------------------------------------------------------------- 1 | export const SET_MOBILE_FLAG = 'SET_MOBILE_FLAG' -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | '@vue/app' 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /src/store/state.js: -------------------------------------------------------------------------------- 1 | const state = { 2 | mobileFlag: false 3 | } 4 | 5 | export default state -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Moon-Future/vue-node-blog/HEAD/public/favicon.ico -------------------------------------------------------------------------------- /src/assets/bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Moon-Future/vue-node-blog/HEAD/src/assets/bg.jpg -------------------------------------------------------------------------------- /public/favicon-1.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Moon-Future/vue-node-blog/HEAD/public/favicon-1.ico -------------------------------------------------------------------------------- /src/assets/Wechat.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Moon-Future/vue-node-blog/HEAD/src/assets/Wechat.jpg -------------------------------------------------------------------------------- /src/assets/avatar.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Moon-Future/vue-node-blog/HEAD/src/assets/avatar.jpg -------------------------------------------------------------------------------- /src/assets/cl_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Moon-Future/vue-node-blog/HEAD/src/assets/cl_1.png -------------------------------------------------------------------------------- /src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Moon-Future/vue-node-blog/HEAD/src/assets/logo.png -------------------------------------------------------------------------------- /version/version-1.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Moon-Future/vue-node-blog/HEAD/version/version-1.zip -------------------------------------------------------------------------------- /src/assets/selfInfo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Moon-Future/vue-node-blog/HEAD/src/assets/selfInfo.jpg -------------------------------------------------------------------------------- /server/jsonData/user.js: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "", 4 | "email": "", 5 | "password": "", 6 | "avatar": "", 7 | "website": "" 8 | } 9 | ] -------------------------------------------------------------------------------- /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": [ 3 | [ 4 | "component", 5 | { 6 | "libraryName": "element-ui", 7 | "styleLibraryName": "theme-chalk" 8 | } 9 | ] 10 | ] 11 | } -------------------------------------------------------------------------------- /src/store/mutations.js: -------------------------------------------------------------------------------- 1 | import * as types from './mutation-types' 2 | 3 | const mutations = { 4 | [types.SET_MOBILE_FLAG](state, flag) { 5 | state.mobileFlag = flag 6 | } 7 | } 8 | 9 | export default mutations -------------------------------------------------------------------------------- /server/api/root.js: -------------------------------------------------------------------------------- 1 | const checkRoot = function(ctx) { 2 | if (!ctx.session || !ctx.session.userInfo) { 3 | return {code: 500, message: '请先登陆'} 4 | } else { 5 | return {code: 200} 6 | } 7 | } 8 | 9 | module.exports = checkRoot -------------------------------------------------------------------------------- /server/jsonData/article.js: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | title: 'vue+node+mysql搭建个人博客(一)', 4 | summary: '', 5 | content: '', 6 | comment: [], 7 | user: 8023, 8 | tag: [1, 2, 3], 9 | createdTime: new Date().getTime(), 10 | } 11 | ] -------------------------------------------------------------------------------- /src/components/front/TagCloud.vue: -------------------------------------------------------------------------------- 1 | 2 |Hello, Nice to meet you !!!
4 |
15 |
16 |
6 |
10 | 码上有你,码上有我
13 |浏览量 {{ item.view }},最后编辑于 {{ item.updateTime }}
10 |' + sendMsg.email + ': ' + data.email + '
' 27 | + '' + sendMsg.name + ': ' + data.name + '
' 28 | + '' + sendMsg.website + ': ' + data.website + '
' 29 | + '' + sendMsg.time + ': ' + dateFormat(new Date, 'yyyy-MM-dd hh:mm:ss') + '
'; 30 | transporter.sendMail(mailOptions, (error, info) => { 31 | if (error) { 32 | return console.log(error); 33 | } 34 | }); 35 | } catch(err) { 36 | throw new Error(err) 37 | } 38 | }) 39 | 40 | router.get('/registerByJson', async (ctx) => { 41 | try { 42 | const fileContent = fs.readFileSync(__dirname, '../jsonData/user.js', 'utf-8') 43 | for (let i = 0, len = fileContent.length; i < len; i++) { 44 | const data = fileContent[i] 45 | const user = new User({ 46 | name: data.name, 47 | email: data.email, 48 | password: data.password, 49 | avatar: avatarDafault, 50 | website: data.website, 51 | createTime: new Date().getTime() 52 | }) 53 | user.save() 54 | } 55 | ctx.body = {code: 200, message: '注册成功'} 56 | } catch(err) { 57 | throw new Error(err) 58 | } 59 | }) 60 | 61 | router.post('/login', async (ctx) => { 62 | try { 63 | const data = ctx.request.body.data 64 | const email = data.email 65 | const password = data.password 66 | const result = await User.find({email: email}) 67 | if (result.length === 0) { 68 | ctx.body = {code: 500, message: '用户不存在'} 69 | } else if(result[0].password !== password) { 70 | ctx.body = {code: 500, message: '密码错误'} 71 | } else { 72 | ctx.session.userInfo = {id: result[0]._id, name: result[0].name, avatar: result[0].avatar, root: result[0].root} 73 | ctx.body = {code: 200, message: '登陆成功'} 74 | } 75 | } catch(err) { 76 | throw new Error(err) 77 | } 78 | }) 79 | 80 | router.post('/logout', async (ctx) => { 81 | try { 82 | ctx.session = null 83 | ctx.body = {code: 200, message: '已退出'} 84 | } catch(err) { 85 | throw new Error(err) 86 | } 87 | }) 88 | 89 | router.post('/getSession', async (ctx) => { 90 | try { 91 | const userInfo = ctx.session.userInfo 92 | if (userInfo) { 93 | ctx.body = {code: 200, message: userInfo} 94 | } else { 95 | ctx.body = {code: 500, message: '请先登陆'} 96 | } 97 | } catch(err) { 98 | throw new Error(err) 99 | } 100 | }) 101 | 102 | router.post('/upload', async (ctx) => { 103 | try { 104 | const userInfo = ctx.session.userInfo 105 | const {fields, files} = await formParse(ctx.req) 106 | const avatarData = files.avatar 107 | const filePath = avatarData.path 108 | const fileName = '/avatar/' + userInfo.id + '.jpg' 109 | const result = await cosUpload(fileName, filePath) 110 | ctx.session.userInfo.avatar = result.Location 111 | await User.update({_id: userInfo.id}, {avatar: result.Location}) 112 | ctx.body = {code: 200, message: {avatar: result.Location}} 113 | } catch(err) { 114 | throw new Error(err) 115 | } 116 | }) 117 | 118 | function formParse(req) { 119 | let form = new formidable.IncomingForm() 120 | return new Promise((resolve, reject) => { 121 | form.parse(req, (error, fields, files) => { 122 | if (error) { 123 | reject(error) 124 | } else { 125 | resolve({fields, files}) 126 | } 127 | }) 128 | }) 129 | } 130 | 131 | module.exports = router -------------------------------------------------------------------------------- /src/components/front/ArticleList.vue: -------------------------------------------------------------------------------- 1 | 2 |后台管理
9 |{{ currentTime }}
13 |{{ timeMessage }}
14 |
9 | {{ verseText }} |
11 |
8 |
9 |
12 |
13 |