├── .gitignore ├── 19.gif ├── LICENSE ├── README.md ├── juejin ├── .editorconfig ├── .eslintrc.js ├── .gitignore ├── README.md ├── assets │ ├── README.md │ ├── font │ │ ├── iconfont.eot │ │ ├── iconfont.svg │ │ ├── iconfont.ttf │ │ └── iconfont.woff │ ├── img │ │ └── default.jpg │ └── less │ │ ├── define.less │ │ ├── iconfont.less │ │ ├── main.less │ │ └── reset.less ├── backpack.config.js ├── build │ ├── main.js │ └── main.map ├── components │ ├── Alert.vue │ ├── Footer.vue │ ├── Header.vue │ ├── PostCell.vue │ ├── README.md │ └── loading.vue ├── config │ ├── default.js │ ├── development.js │ ├── index.js │ └── production.js ├── layouts │ ├── README.md │ ├── add.vue │ ├── default.vue │ ├── error.vue │ └── regist.vue ├── middleware │ ├── README.md │ └── adminAuth.js ├── nuxt.config.js ├── package-lock.json ├── package.json ├── pages │ ├── README.md │ ├── index.vue │ ├── posts │ │ ├── _id.vue │ │ ├── add.vue │ │ └── index.vue │ ├── regist │ │ └── index.vue │ └── user │ │ └── _id.vue ├── plugins │ ├── README.md │ ├── axios.js │ └── vue-notification.js ├── server │ ├── api │ │ ├── index.js │ │ ├── posts.js │ │ ├── signin.js │ │ ├── signout.js │ │ └── signup.js │ ├── index.js │ ├── lib │ │ ├── sql.js │ │ └── util.date.js │ ├── middlewares │ │ └── check.js │ ├── models │ │ ├── comments.js │ │ ├── posts.js │ │ └── users.js │ └── views │ │ ├── error.jade │ │ ├── index.jade │ │ └── layout.jade ├── static │ ├── README.md │ ├── assets │ │ └── postImages │ │ │ ├── 2016120801.png │ │ │ ├── 2016121601.png │ │ │ ├── 2016121602.png │ │ │ ├── 2016121603.png │ │ │ ├── 2016121604.png │ │ │ ├── 2016121605.png │ │ │ ├── 2017010401.png │ │ │ ├── 2017010402.png │ │ │ ├── 2017010403.png │ │ │ ├── 2017010404.png │ │ │ ├── 2017010405.png │ │ │ ├── 2017010406.png │ │ │ ├── 2017010407.png │ │ │ ├── 2017011201.png │ │ │ ├── 2017011202.png │ │ │ ├── 2017040501.png │ │ │ ├── 2017042601.png │ │ │ ├── 2017042602.png │ │ │ ├── 2017042603.png │ │ │ ├── 2017050201.png │ │ │ ├── 2017050202.png │ │ │ └── home.jpg │ ├── img │ │ ├── 1.png │ │ ├── 1515725808511.png │ │ ├── 1515727064963.png │ │ ├── 1515727090471.png │ │ ├── 1515727141161.png │ │ ├── 1515727186354.png │ │ ├── 1515729594563.png │ │ ├── 1515731040539.png │ │ ├── 1515731077974.png │ │ ├── 1515731207859.png │ │ ├── 1515733291930.png │ │ ├── 1515733415909.png │ │ ├── 1515824367994.png │ │ ├── 1515824455722.png │ │ ├── 1515824668934.png │ │ ├── 1516001084211.png │ │ ├── 1516003699246.png │ │ ├── 1516005815970.png │ │ ├── 1516023012260.png │ │ ├── 1516085175539.png │ │ ├── 1516199442057.png │ │ ├── 1516242571904.png │ │ ├── favicon.ico │ │ ├── headIcon.png │ │ ├── upload_07bb571b7706cc09df03adef334ceac6.png │ │ ├── upload_67b102bc50907f58c8318f50fc208416.jpg │ │ └── upload_866d2b77767777d2563aa882200af1ca.png │ ├── javascripts │ │ ├── prism.js │ │ └── screen.js │ └── stylesheets │ │ ├── github-markdown.css │ │ ├── prism.css │ │ └── style.css ├── util │ ├── api.config.js │ ├── assist.js │ ├── cUtil.js │ ├── cookieSessionStorate.js │ ├── device.js │ ├── userloginUtil.js │ └── util.date.js └── 命令列表.txt └── 数据库表.sql /.gitignore: -------------------------------------------------------------------------------- 1 | # Build and Release Folders 2 | bin/ 3 | bin-debug/ 4 | bin-release/ 5 | [Oo]bj/ # FlashDevelop obj 6 | [Bb]in/ # FlashDevelop bin 7 | 8 | node_modules/ 9 | coverage/ 10 | logs/ 11 | test/ 12 | 13 | # Other files and folders 14 | .settings/ 15 | 16 | # Executables 17 | *.swf 18 | *.air 19 | *.ipa 20 | *.apk 21 | 22 | # Project files, i.e. `.project`, `.actionScriptProperties` and `.flexProperties` 23 | # should NOT be excluded as they contain compiler settings and other important 24 | # information for Eclipse / Flash Builder. 25 | -------------------------------------------------------------------------------- /19.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/ExpressNuxtMysqlNginxBlog/3392ea52107993b0bb7773a2601d61a50e0cc04a/19.gif -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## 项目说明 2 | 3 | 1项目使用Express+mysql+nuxt+nginx写的一个项目。nuxt用于实现服务端渲染。nginx做代理服务器对静态资源代理
4 | 2项目环境是node的8.5。
5 | 3详情页使用markdown语法,使用ejs模板来渲染。兼容移动端和桌面端
6 | 4项目线上部署地址: www.huangchengdu.com 。欢迎访问。
7 | 5整个项目的配置在config目录下面。可以根据自己的情况修改配置。比如端口号、域名等等。
8 | 6这个项目是我玩node一年以来的结晶。O(∩_∩)O~。
9 | 7整个项目布局都是less写的,没有使用任何第三方框架。
10 | 11 | 12 | ## 项目运行 13 | 14 | ````javascript 15 | //部署,具体细节看下面 16 | npm install 17 | npm run build 18 | npm run start 19 | //开发 20 | npm run dev 21 | ```` 22 | 23 | ## 关于nginx代理配置 24 | 25 | nginx的配置文件如下:
26 | 27 | ````javascript 28 | user www www; 29 | worker_processes 2;#设置值和CPU核心数一致 30 | error_log /usr/local/webserver/nginx/logs/nginx_error.log crit; #日志位置和日志级别 31 | pid /usr/local/webserver/nginx/nginx.pid; 32 | #Specifies the value for maximum file descriptors that can be opened by this process. 33 | worker_rlimit_nofile 65535; 34 | events 35 | { 36 | use epoll; 37 | worker_connections 65535; 38 | } 39 | http 40 | { 41 | include mime.types; 42 | default_type application/octet-stream; 43 | log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 44 | '$status $body_bytes_sent "$http_referer" ' 45 | '"$http_user_agent" $http_x_forwarded_for'; 46 | 47 | #charset gb2312; 48 | 49 | server_names_hash_bucket_size 128; 50 | client_header_buffer_size 32k; 51 | large_client_header_buffers 4 32k; 52 | client_max_body_size 8m; 53 | 54 | sendfile on; 55 | tcp_nopush on; 56 | keepalive_timeout 60; 57 | tcp_nodelay on; 58 | fastcgi_connect_timeout 300; 59 | fastcgi_send_timeout 300; 60 | fastcgi_read_timeout 300; 61 | fastcgi_buffer_size 64k; 62 | fastcgi_buffers 4 64k; 63 | fastcgi_busy_buffers_size 128k; 64 | fastcgi_temp_file_write_size 128k; 65 | gzip on; 66 | gzip_min_length 1k; 67 | gzip_buffers 4 16k; 68 | gzip_http_version 1.0; 69 | gzip_comp_level 2; 70 | gzip_types text/plain application/x-javascript text/css application/xml; 71 | gzip_vary on; 72 | 73 | #limit_zone crawler $binary_remote_addr 10m; 74 | upstream sample { 75 | server localhost:5389; 76 | #server 127.0.0.1:5389; 77 | #server 127.0.0.1:3001; 78 | keepalive 64; 79 | } 80 | #下面是server虚拟主机的配置 81 | server 82 | { 83 | listen 80;#监听端口 84 | server_name www.huangchengdu.com; 85 | rewrite ^(.*)$ https://$host$1 permanent; 86 | } 87 | server 88 | { 89 | listen 443;#监听端口 90 | server_name www.huangchengdu.com; 91 | ssl on; 92 | index index.html index.htm index.php; 93 | root /usr/local/webserver/nginx/html;#站点目录 94 | ssl_certificate cert/214353122570188.pem; 95 | ssl_certificate_key cert/214353122570188.key; 96 | ssl_session_timeout 5m; 97 | ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; 98 | ssl_protocols TLSv1 TLSv1.1 TLSv1.2; 99 | ssl_prefer_server_ciphers on; 100 | location / { 101 | proxy_redirect off; 102 | proxy_set_header X-Real-IP $remote_addr; 103 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 104 | proxy_set_header X-Forwarded-Proto $scheme; 105 | proxy_set_header Host $http_host; 106 | proxy_set_header X-NginX-Proxy true; 107 | proxy_set_header Connection ""; 108 | proxy_http_version 1.1; 109 | proxy_pass http://sample; 110 | } 111 | location ~ .*\.(gif|jpg|JPG|jpeg|png|bmp|swf|ico)$ 112 | { 113 | root /usr/local/webserver/nginx/static; 114 | expires 30d; 115 | #access_log off; 116 | } 117 | location ~ .*\.(js|css)?$ 118 | { 119 | root /usr/local/webserver/nginx/static; 120 | expires 15d; 121 | #access_log off; 122 | } 123 | location ~ .*\.(html|htm)?$ 124 | { 125 | root /usr/local/webserver/nginx/static; 126 | expires 30d; 127 | # #access_log off; 128 | } 129 | access_log off; 130 | } 131 | 132 | } 133 | ```` 134 | 135 | `npm run build`以后,然后`npm run start`启动服务器。最后需要把`.nuxt/dist/`(build以后生成的)目录下面的所有文件和static(我这里是`/usr/local/webserver/nginx/static`)目录下的所有文件都放到代理服务器的静态资源根目录。
136 | 这样才能完整的使用样式表,如果不使用代理服务器就不用了。 137 | 138 | 139 | ## 关于nuxt 140 | 141 | nuxt是vue官方的服务端渲染框架。犹豫还是比较新颖的东西,坑比较多,我做的过程中也是踩坑不段。
142 | 本来还有一些功能想添加进去,精力有限暂且搞一个段落。
143 | 144 | ## 演示 145 | 146 | ![](https://github.com/huang303513/ExpressNuxtMysqlNginxBlog/blob/master/19.gif) 147 | 148 | 149 | 150 | 151 | -------------------------------------------------------------------------------- /juejin/.editorconfig: -------------------------------------------------------------------------------- 1 | # editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_size = 4 6 | indent_style = space 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | [*.md] 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /juejin/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | parser: 'babel-eslint', 4 | env: { 5 | browser: true, 6 | node: true 7 | }, 8 | extends: 'standard', 9 | // required to lint *.vue files 10 | plugins: [ 11 | 'html' 12 | ], 13 | // add your custom rules here 14 | rules: {}, 15 | globals: {} 16 | } 17 | -------------------------------------------------------------------------------- /juejin/.gitignore: -------------------------------------------------------------------------------- 1 | # dependencies 2 | node_modules 3 | 4 | # logs 5 | npm-debug.log 6 | 7 | # Nuxt build 8 | .nuxt 9 | 10 | # Nuxt generate 11 | dist 12 | build/ 13 | .nuxt 14 | -------------------------------------------------------------------------------- /juejin/README.md: -------------------------------------------------------------------------------- 1 | # juejin 2 | 3 | > Nuxt.js project 4 | 5 | ## Build Setup 6 | 7 | ``` bash 8 | # install dependencies 9 | $ npm install # Or yarn install 10 | 11 | # serve with hot reload at localhost:3000 12 | $ npm run dev 13 | 14 | # build for production and launch server 15 | $ npm run build 16 | $ npm start 17 | 18 | # generate static project 19 | $ npm run generate 20 | ``` 21 | 22 | For detailed explanation on how things work, checkout the [Nuxt.js docs](https://github.com/nuxt/nuxt.js). 23 | -------------------------------------------------------------------------------- /juejin/assets/README.md: -------------------------------------------------------------------------------- 1 | # ASSETS 2 | 3 | This directory contains your un-compiled assets such as LESS, SASS, or JavaScript. 4 | 5 | More information about the usage of this directory in the documentation: 6 | https://nuxtjs.org/guide/assets#webpacked 7 | 8 | **This directory is not required, you can delete it if you don't want to use it.** 9 | -------------------------------------------------------------------------------- /juejin/assets/font/iconfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/ExpressNuxtMysqlNginxBlog/3392ea52107993b0bb7773a2601d61a50e0cc04a/juejin/assets/font/iconfont.eot -------------------------------------------------------------------------------- /juejin/assets/font/iconfont.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | Created by iconfont 9 | 10 | 11 | 12 | 13 | 21 | 22 | 23 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /juejin/assets/font/iconfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/ExpressNuxtMysqlNginxBlog/3392ea52107993b0bb7773a2601d61a50e0cc04a/juejin/assets/font/iconfont.ttf -------------------------------------------------------------------------------- /juejin/assets/font/iconfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/ExpressNuxtMysqlNginxBlog/3392ea52107993b0bb7773a2601d61a50e0cc04a/juejin/assets/font/iconfont.woff -------------------------------------------------------------------------------- /juejin/assets/img/default.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/huang303513/ExpressNuxtMysqlNginxBlog/3392ea52107993b0bb7773a2601d61a50e0cc04a/juejin/assets/img/default.jpg -------------------------------------------------------------------------------- /juejin/assets/less/define.less: -------------------------------------------------------------------------------- 1 | @headerHeight: 4rem; 2 | @defaultWidth: 1080px; 3 | @defaultBGColor:#f1f2f2; 4 | @defaultDarkColor:#5e6469; 5 | @defaultBlue:#0b66fe; 6 | @darkTextColor:#999999; 7 | .page{ 8 | width: 100%; 9 | margin: 4rem auto; 10 | background: #fff; 11 | border-radius: 4px; 12 | box-shadow: 0 0 6px rgba(100,100,100,0.4); 13 | transition: all ease-in 0.3s; 14 | padding: 0 2rem; 15 | } 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /juejin/assets/less/iconfont.less: -------------------------------------------------------------------------------- 1 | 2 | @font-face {font-family: "iconfont"; 3 | src: url('../font/iconfont.eot?t=1515681059050'); /* IE9*/ 4 | src: url('../font/iconfont.eot?t=1515681059050#iefix') format('embedded-opentype'), /* IE6-IE8 */ 5 | url('data:application/x-font-woff;charset=utf-8;base64,d09GRgABAAAAAAyUAAsAAAAAEuwAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABHU1VCAAABCAAAADMAAABCsP6z7U9TLzIAAAE8AAAAQwAAAFZW70pfY21hcAAAAYAAAADhAAACou8h35tnbHlmAAACZAAAB7QAAAro9WgWRmhlYWQAAAoYAAAALwAAADYQknBDaGhlYQAACkgAAAAgAAAAJAhXBAhobXR4AAAKaAAAABcAAABERGAAAGxvY2EAAAqAAAAAJAAAACQUOhbKbWF4cAAACqQAAAAfAAAAIAEiAHJuYW1lAAAKxAAAAUUAAAJtPlT+fXBvc3QAAA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xjYWBgYH7JwMDCQAIuR+UDAEnkAaQAAAAAAAB2AKABCgE0AbYB3gIGAi4CjgMKAzIDyAQgBKQFHgV0eJxjYGRgYBBkSGNgZwABJiDmAkIGhv9gPgMAFKwBlQB4nGWPTU7DMBCFX/oHpBKqqGCH5AViASj9EatuWFRq911036ZOmyqJI8et1ANwHo7ACTgC3IA78EgnmzaWx9+8eWNPANzgBx6O3y33kT1cMjtyDRe4F65TfxBukF+Em2jjVbhF/U3YxzOmwm10YXmD17hi9oR3YQ8dfAjXcI1P4Tr1L+EG+Vu4iTv8CrfQ8erCPuZeV7iNRy/2x1YvnF6p5UHFockikzm/gple75KFrdLqnGtbxCZTg6BfSVOdaVvdU+zXQ+ciFVmTqgmrOkmMyq3Z6tAFG+fyUa8XiR6EJuVYY/62xgKOcQWFJQ6MMUIYZIjK6Og7VWb0r7FDwl57Vj3N53RbFNT/c4UBAvTPXFO6stJ5Ok+BPV8bUnV0K27LnpQ0kV7NSRKyQl7WtlRC6gE2ZVeOEXpc0Yk/KGdI/wAJWm7IAAAAeJxtyFkSgjAQRdE8CKM44D5cVEw6QBlpqhun3VuUv56vW9dk5qc1//XIkMOiQIkKNRq02KHDHgcccUKPs8HbXp2/We9kLXxipTJQopVsItX2zkKPOXIKdstKKArpWCo58WPuQrCel08T3ZNlWknrxam+WLYfqBuYwyVOKU3zYMwXjJMm+gAAAA==') format('woff'), 6 | url('../font/iconfont.ttf?t=1515681059050') format('truetype'), /* chrome, firefox, opera, Safari, Android, iOS 4.2+*/ 7 | url('../font/iconfont.svg?t=1515681059050#iconfont') format('svg'); /* iOS 4.1- */ 8 | } 9 | 10 | .iconfont { 11 | font-family:"iconfont" !important; 12 | font-size:16px; 13 | font-style:normal; 14 | -webkit-font-smoothing: antialiased; 15 | -moz-osx-font-smoothing: grayscale; 16 | } 17 | 18 | .icon-back:before { content: "\e697"; } 19 | 20 | .icon-cart:before { content: "\e698"; } 21 | 22 | .icon-close:before { content: "\e69a"; } 23 | 24 | .icon-delete:before { content: "\e69d"; } 25 | 26 | .icon-less:before { content: "\e6a5"; } 27 | 28 | .icon-moreunfold:before { content: "\e6a6"; } 29 | 30 | .icon-more:before { content: "\e6a7"; } 31 | 32 | .icon-refresh:before { content: "\e6aa"; } 33 | 34 | .icon-search:before { content: "\e6ac"; } 35 | 36 | .icon-add:before { content: "\e6b9"; } 37 | 38 | .icon-copy:before { content: "\e744"; } 39 | 40 | .icon-favorites:before { content: "\e7ce"; } 41 | 42 | .icon-password:before { content: "\e82b"; } 43 | 44 | .icon-code:before { content: "\e842"; } 45 | 46 | .icon-good-filling:before { content: "\e866"; } 47 | 48 | -------------------------------------------------------------------------------- /juejin/assets/less/main.less: -------------------------------------------------------------------------------- 1 | @import 'reset'; 2 | @import 'define'; 3 | 4 | html { 5 | font-family: "Source Sans Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; 6 | // font-size: 16px; 7 | word-spacing: 1px; 8 | -ms-text-size-adjust: 100%; 9 | -webkit-text-size-adjust: 100%; 10 | -moz-osx-font-smoothing: grayscale; 11 | -webkit-font-smoothing: antialiased; 12 | box-sizing: border-box; 13 | } 14 | 15 | *, 16 | *:before, 17 | *:after { 18 | box-sizing: border-box; 19 | margin: 0; 20 | } 21 | #__nuxt { 22 | // width: @defaultWidth; 23 | width:100%; 24 | max-width: @defaultWidth; 25 | margin: 5rem auto 0 auto; 26 | height: 100%; 27 | } 28 | #__layout{ 29 | width: 100%; 30 | height: 100%; 31 | } 32 | body{ 33 | background-color: @defaultBGColor; 34 | } 35 | -------------------------------------------------------------------------------- /juejin/assets/less/reset.less: -------------------------------------------------------------------------------- 1 | @charset "utf-8"; 2 | html, 3 | body { 4 | height: 100%; 5 | } 6 | 7 | body, 8 | div, 9 | dl, 10 | dt, 11 | dd, 12 | ul, 13 | ol, 14 | li, 15 | h1, 16 | h2, 17 | h3, 18 | h4, 19 | h5, 20 | h6, 21 | pre, 22 | code, 23 | form, 24 | fieldset, 25 | legend, 26 | input, 27 | textarea, 28 | p, 29 | blockquote, 30 | th, 31 | td, 32 | hr, 33 | button, 34 | article, 35 | aside, 36 | details, 37 | figcaption, 38 | figure, 39 | footer, 40 | header, 41 | hgroup, 42 | menu, 43 | nav, 44 | section { 45 | margin: 0; 46 | padding: 0; 47 | } 48 | 49 | body, 50 | button, 51 | input, 52 | select, 53 | textarea { 54 | font: 400 0.75rem/1.5 Arial, 'Lucida Grande', Verdana, 'Microsoft YaHei', hei; 55 | } 56 | 57 | article, 58 | aside, 59 | details, 60 | figcaption, 61 | figure, 62 | footer, 63 | header, 64 | hgroup, 65 | menu, 66 | nav, 67 | section, 68 | iframe { 69 | display: block; 70 | } 71 | 72 | h1, 73 | h2, 74 | h3, 75 | h4, 76 | h5, 77 | h6 { 78 | font-size: 100%; 79 | font-weight: 500; 80 | } 81 | 82 | address, 83 | cite, 84 | dfn, 85 | em, 86 | var, 87 | i { 88 | font-style: normal; 89 | font-weight: 400; 90 | } 91 | 92 | dfn { 93 | font-family: Arial; 94 | } 95 | 96 | ul, 97 | ol { 98 | list-style: none; 99 | } 100 | 101 | a { 102 | color: #000; 103 | text-decoration: none; 104 | } 105 | 106 | a:hover { 107 | transition: color 0.2s linear; 108 | } 109 | 110 | fieldset, 111 | img, 112 | button, 113 | input { 114 | border: 0; 115 | } 116 | 117 | button, 118 | input, 119 | select, 120 | textarea { 121 | font-size: 100%; 122 | } 123 | 124 | table { 125 | border-collapse: collapse; 126 | border-spacing: 0; 127 | } 128 | 129 | input { 130 | -webkit-appearance: none; 131 | border-radius: 0; 132 | } 133 | 134 | body { 135 | // min-width: 16rem; 136 | // background: green; 137 | overflow-x: hidden; 138 | -webkit-text-size-adjust: none; 139 | -webkit-tap-highlight-color: rgba(0, 0, 0, 0); 140 | -webkit-font-smoothing: antialiased; 141 | -moz-user-select: none; 142 | color: #000; 143 | } 144 | 145 | :focus { 146 | outline: 0; 147 | } 148 | 149 | .clearfix:after { 150 | clear: both; 151 | content: '.'; 152 | display: block; 153 | height: 0; 154 | visibility: hidden; 155 | line-height: 0; 156 | } 157 | 158 | .clearfix { 159 | *zoom: 1; 160 | } 161 | 162 | .fl { 163 | float: left; 164 | } 165 | 166 | .fr { 167 | float: right; 168 | } 169 | 170 | .clear { 171 | clear: both; 172 | } 173 | 174 | .overflow { 175 | overflow: hidden; 176 | } 177 | 178 | .ellips { 179 | white-space: nowrap; 180 | overflow: hidden; 181 | text-overflow: ellipsis; 182 | } -------------------------------------------------------------------------------- /juejin/backpack.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | webpack: (config, options, webpack) => { 3 | config.entry.main = './server/index.js' 4 | return config 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /juejin/components/Alert.vue: -------------------------------------------------------------------------------- 1 | 10 | 11 | 32 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /juejin/components/Footer.vue: -------------------------------------------------------------------------------- 1 | white 22 | 23 | 56 | -------------------------------------------------------------------------------- /juejin/components/Header.vue: -------------------------------------------------------------------------------- 1 | 39 | 40 | 175 | 176 | 304 | 305 | -------------------------------------------------------------------------------- /juejin/components/PostCell.vue: -------------------------------------------------------------------------------- 1 | 25 | 26 | 42 | 43 | 133 | 134 | 135 | 136 | -------------------------------------------------------------------------------- /juejin/components/README.md: -------------------------------------------------------------------------------- 1 | # COMPONENTS 2 | 3 | The components directory contains your Vue.js Components. 4 | Nuxt.js doesn't supercharge these components. 5 | 6 | **This directory is not required, you can delete it if you don't want to use it.** 7 | -------------------------------------------------------------------------------- /juejin/components/loading.vue: -------------------------------------------------------------------------------- 1 | 12 | 13 | 27 | 28 | 104 | 105 | -------------------------------------------------------------------------------- /juejin/config/default.js: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: huangchengdu 3 | * @Date: 2017-01-13 16:19:01 4 | * @Last Modified by: huangchengdu 5 | * @Last Modified time: 2017-01-16 11:00:33 6 | */ 7 | 8 | let devConfig = { 9 | port: 443, 10 | sslModel: false, 11 | session: { 12 | secret: 'session', 13 | key: 'session', 14 | maxAge: 2592000 15 | }, 16 | dbConfig: { 17 | connectionLimit: 30, 18 | host: '47.96.6.227', 19 | user: 'huang303513', 20 | password: 'huang303513', 21 | port: '3306', 22 | database: 'myblog' 23 | }, 24 | devEnv: true 25 | }; 26 | 27 | export default devConfig; 28 | 29 | //这两个文件必须写成comment.js规范。引用他们的第三方库只支持这个规范。 -------------------------------------------------------------------------------- /juejin/config/development.js: -------------------------------------------------------------------------------- 1 | import {default as devConfig} from './default.js'; 2 | 3 | let proConfig = { 4 | devEnv: true, 5 | port: 5389, 6 | apiPort:5389, 7 | apiHost:"http://localhost", 8 | sslModel: false, 9 | uploadPath:'/../../static/img/' 10 | } 11 | let disConfig = Object.assign({}, devConfig, proConfig); 12 | 13 | export default disConfig; -------------------------------------------------------------------------------- /juejin/config/index.js: -------------------------------------------------------------------------------- 1 | import development from './development.js' 2 | import production from './production.js' 3 | 4 | export default function getConfig(name="production") { 5 | if (name=='production') { 6 | return production; 7 | } else { 8 | return development; 9 | } 10 | } -------------------------------------------------------------------------------- /juejin/config/production.js: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: huangchengdu 3 | * @Date: 2017-01-14 18:47:32 4 | * @Last Modified by: huangchengdu 5 | * @Last Modified time: 2017-01-15 08:18:01 6 | */ 7 | import {default as devConfig} from './development.js'; 8 | 9 | let proConfig = { 10 | devEnv: false, 11 | port: 5389,//如果package.json里面不一样,以这里为准 12 | apiPort:443, 13 | apiHost:"https://www.huangchengdu.com", 14 | sslModel: false, 15 | uploadPath:'/usr/local/webserver/nginx/static/img/' 16 | } 17 | let disConfig = Object.assign({}, devConfig, proConfig); 18 | 19 | export default disConfig; -------------------------------------------------------------------------------- /juejin/layouts/README.md: -------------------------------------------------------------------------------- 1 | # LAYOUTS 2 | 3 | This directory contains your Application Layouts. 4 | 5 | More information about the usage of this directory in the documentation: 6 | https://nuxtjs.org/guide/views#layouts 7 | 8 | **This directory is not required, you can delete it if you don't want to use it.** 9 | -------------------------------------------------------------------------------- /juejin/layouts/add.vue: -------------------------------------------------------------------------------- 1 | 10 | 33 | 44 | -------------------------------------------------------------------------------- /juejin/layouts/default.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | 33 | 34 | 41 | -------------------------------------------------------------------------------- /juejin/layouts/error.vue: -------------------------------------------------------------------------------- 1 | 8 | 9 | -------------------------------------------------------------------------------- /juejin/layouts/regist.vue: -------------------------------------------------------------------------------- 1 | 8 | 31 | 38 | -------------------------------------------------------------------------------- /juejin/middleware/README.md: -------------------------------------------------------------------------------- 1 | # MIDDLEWARE 2 | 3 | This directory contains your Application Middleware. 4 | The middleware lets you define custom function to be ran before rendering a page or a group of pages (layouts). 5 | 6 | More information about the usage of this directory in the documentation: 7 | https://nuxtjs.org/guide/routing#middleware 8 | 9 | **This directory is not required, you can delete it if you don't want to use it.** 10 | -------------------------------------------------------------------------------- /juejin/middleware/adminAuth.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | export default function ({ isClient, isServer, route, req, res, redirect }) { 4 | res.header('Access-Control-Allow-Origin', '*'); 5 | res.header('Access-Control-Allow-Headers', 'Content-Type,Content-Length, Authorization,\'Origin\',Accept,X-Requested-With'); 6 | res.header('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE'); 7 | res.header('Access-Control-Allow-Credentials', true); 8 | res.header('X-Powered-By', ' 3.2.1'); 9 | //在服务端判读是否需要登陆(如果直接输地址,在客户端是判断不到的) 10 | console.log("============呵呵----",req.session,"====时间=====",new Date()); 11 | } -------------------------------------------------------------------------------- /juejin/nuxt.config.js: -------------------------------------------------------------------------------- 1 | // var session = require('express-session'); 2 | // var MySQLStore = require('express-mysql-session')(session); 3 | // import bodyParser from 'body-parser' 4 | 5 | module.exports = { 6 | /* 7 | ** Headers of the page 8 | */ 9 | head: { 10 | script: [{ 11 | src: 'https://www.huangchengdu.com/javascripts/screen.js' 12 | },{ 13 | src: 'https://hm.baidu.com/hm.js?96b0d09e8d132a6e61f66ea86b479b70' 14 | },{ 15 | src:'https://www.huangchengdu.com/javascripts/googleAsys.js' 16 | }], 17 | title: '黄成都的技术博客', 18 | meta: [{ 19 | charset: 'utf-8' 20 | }, 21 | { 22 | name: 'viewport', 23 | content: 'width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no,minimal-ui' 24 | }, 25 | { 26 | hid: 'description', 27 | name: 'description', 28 | content: '黄成都的技术博客' 29 | }, 30 | { 31 | name:"keywords", 32 | content:"黄成都,技术博客,黄成都的技术博客,iOS,Vue,Nuxt,Vue开发,AFNetWorking源码,SDWebImage源码,AFNetWorking,SDWebImage,JSONP,JavaScript,JavascriptCoreBridge,SSR,服务端渲染" 33 | }, 34 | { 35 | name:'subject', 36 | content:'技术博客' 37 | }, 38 | { 39 | name:'robots', 40 | content:'index,follow' 41 | }, 42 | { 43 | name:'googlebot', 44 | content:'index,follow' 45 | }, 46 | { 47 | name:'owner', 48 | content:"黄成都" 49 | }, 50 | // /*优先使用 IE 最新版本和 Chrome */ 51 | { 52 | name: 'renderer', 53 | content: 'webkit' 54 | }, 55 | { 56 | 'http-equiv': 'X-UA-Compatible', 57 | content: 'IE=edge' 58 | }, 59 | /* iOS 设备 */ 60 | { 61 | name: 'author', 62 | content: '黄成都' 63 | }, 64 | { 65 | name: 'apple-mobile-web-app-title', 66 | content: '黄成都的技术博客' 67 | }, 68 | { 69 | name: 'apple-mobile-web-app-capable', 70 | content: 'yes' 71 | }, 72 | { 73 | name: 'apple-mobile-web-app-status-bar-style', 74 | content: '#263238' 75 | }, 76 | /*fullscreen and app mode*/ 77 | { 78 | name: 'screen-orientation', 79 | content: 'portrait' 80 | }, 81 | { 82 | name: 'x5-orientation', 83 | content: 'portrait' 84 | }, 85 | { 86 | name: 'full-screen', 87 | content: 'yes' 88 | }, 89 | { 90 | name: 'x5-fullscreen', 91 | content: 'true' 92 | }, 93 | { 94 | name: 'browsermode', 95 | content: 'application' 96 | }, 97 | { 98 | name: 'x5-page-mode', 99 | content: 'app' 100 | }, 101 | /*webkit*/ 102 | { 103 | name: 'theme-color', 104 | content: '#263238' 105 | } 106 | ], 107 | link: [{ 108 | rel: 'icon', 109 | type: 'image/x-icon', 110 | href: '/img/favicon.ico' 111 | }] 112 | }, 113 | css: [{ 114 | src: '~assets/less/main.less', 115 | lang: 'less' 116 | }], 117 | /* 118 | ** Build configuration 119 | */ 120 | build: { 121 | vendor: ['axios', 'vue-notification'], 122 | /* 123 | ** Run ESLint on save 124 | */ 125 | // extend(config, ctx) { 126 | // if (ctx.dev && ctx.isClient) { 127 | // config.module.rules.push({ 128 | // enforce: 'pre', 129 | // test: /\.(js|vue)$/, 130 | // loader: 'eslint-loader', 131 | // exclude: /(node_modules)/ 132 | // }) 133 | // } 134 | // } 135 | }, 136 | loading: { 137 | // color: '#04acf7', 138 | // height: '4px', 139 | // failedColor: 'red' 140 | // loading: '~/components/loading.vue' 141 | }, 142 | //页面的过渡效果 143 | transition: { 144 | name: 'page' 145 | }, 146 | //配置路由 147 | router: { 148 | middleware: 'adminAuth' 149 | }, 150 | //插件 151 | plugins: [{ 152 | src: '~plugins/axios' 153 | }, 154 | { 155 | src: '~plugins/vue-notification', 156 | ssr: false 157 | } 158 | ], 159 | serverMiddleware: [ 160 | // body-parser middleware 161 | // bodyParser.json(), 162 | // session middleware 163 | // session({ 164 | // secret: 'super-secret-key', 165 | // resave: false, 166 | // saveUninitialized: false, 167 | // cookie: { maxAge: 60000 } 168 | // }), 169 | // Api middleware 170 | // We add /api/login & /api/logout routes 171 | // '~/api' 172 | ], 173 | render: { 174 | bundleRenderer: { 175 | cache: require('lru-cache')({ 176 | max: 1000, 177 | maxAge: 1000 * 60 * 10 178 | }) 179 | } 180 | } 181 | } 182 | -------------------------------------------------------------------------------- /juejin/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "juejin", 3 | "version": "1.0.0", 4 | "description": "Nuxt.js project", 5 | "author": "huangchengdu <394042583@qq.com>", 6 | "private": true, 7 | "config": { 8 | "nuxt": { 9 | "port": "5389" 10 | } 11 | }, 12 | "scripts": { 13 | "dev": "cross-env NODE_ENV=development backpack dev", 14 | "local-build": "cross-env NODE_ENV=development nuxt build && backpack build", 15 | "build": "cross-env NODE_ENV=production nuxt build && backpack build", 16 | "start": "cross-env NODE_ENV=production pm2 start build/main.js", 17 | "local-start": "cross-env NODE_ENV=development pm2 start build/main.js", 18 | "generate": "cross-env NODE_ENV=production nuxt generate", 19 | "nuxt": "cross-env NODE_ENV=development nuxt", 20 | "nuxt-build": "cross-env NODE_ENV=production nuxt build", 21 | "nuxt-start": "cross-env NODE_ENV=production nuxt start", 22 | "lint": "cross-env NODE_ENV=development eslint --ext .js,.vue --ignore-path .gitignore .", 23 | "precommit": "cross-env NODE_ENV=development npm run lint" 24 | }, 25 | "dependencies": { 26 | "axios": "^0.17.1", 27 | "backpack-core": "^0.4.3", 28 | "body-parser": "^1.18.2", 29 | "cookie-parser": "^1.4.3", 30 | "cross-env": "^5.1.1", 31 | "crypto-js": "^3.1.9-1", 32 | "express": "^4.16.2", 33 | "express-formidable": "^1.0.0", 34 | "express-mysql-session": "^1.2.3", 35 | "express-session": "^1.15.6", 36 | "express-winston": "^2.4.0", 37 | "jade": "^1.11.0", 38 | "less": "^2.7.3", 39 | "less-loader": "^4.0.5", 40 | "marked": "^0.3.7", 41 | "multer": "^1.3.0", 42 | "mysql": "^2.15.0", 43 | "nuxt": "^1.0.0-rc11", 44 | "sha1": "^1.1.1", 45 | "vue-notification": "^1.3.4", 46 | "winston": "^2.4.0" 47 | }, 48 | "devDependencies": { 49 | "babel-eslint": "^7.2.3", 50 | "eslint": "^4.3.0", 51 | "eslint-config-standard": "^10.2.1", 52 | "eslint-loader": "^1.9.0", 53 | "eslint-plugin-html": "^3.1.1", 54 | "eslint-plugin-import": "^2.7.0", 55 | "eslint-plugin-node": "^5.1.1", 56 | "eslint-plugin-promise": "^3.5.0", 57 | "eslint-plugin-standard": "^3.0.1", 58 | "lru-cache": "^4.1.1", 59 | "xss": "^0.3.7" 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /juejin/pages/README.md: -------------------------------------------------------------------------------- 1 | # PAGES 2 | 3 | This directory contains your Application Views and Routes. 4 | The framework reads all the .vue files inside this directory and create the router of your application. 5 | 6 | More information about the usage of this directory in the documentation: 7 | https://nuxtjs.org/guide/routing 8 | -------------------------------------------------------------------------------- /juejin/pages/index.vue: -------------------------------------------------------------------------------- 1 | 5 | 6 | 10 | 11 | 16 | 17 | -------------------------------------------------------------------------------- /juejin/pages/posts/_id.vue: -------------------------------------------------------------------------------- 1 | 38 | 39 | 103 | 104 | 261 | 262 | 263 | -------------------------------------------------------------------------------- /juejin/pages/posts/add.vue: -------------------------------------------------------------------------------- 1 | 13 | 14 | 65 | 66 | 132 | 133 | 134 | -------------------------------------------------------------------------------- /juejin/pages/posts/index.vue: -------------------------------------------------------------------------------- 1 | 9 | 10 | 94 | 95 | 111 | 112 | -------------------------------------------------------------------------------- /juejin/pages/regist/index.vue: -------------------------------------------------------------------------------- 1 | 53 | 54 | 156 | 157 | 269 | 270 | -------------------------------------------------------------------------------- /juejin/pages/user/_id.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 46 | 47 | 53 | 54 | -------------------------------------------------------------------------------- /juejin/plugins/README.md: -------------------------------------------------------------------------------- 1 | # PLUGINS 2 | 3 | This directory contains your Javascript plugins that you want to run before instantiating the root vue.js application. 4 | 5 | More information about the usage of this directory in the documentation: 6 | https://nuxtjs.org/guide/plugins 7 | 8 | **This directory is not required, you can delete it if you don't want to use it.** 9 | -------------------------------------------------------------------------------- /juejin/plugins/axios.js: -------------------------------------------------------------------------------- 1 | import * as axios from 'axios' 2 | import { 3 | getCookieInClient 4 | } from '../util/assist' 5 | import getConfig from '../config'; 6 | let config = getConfig(process.env.NODE_ENV); 7 | axios.defaults.baseURL = config.apiHost + ":" + config.apiPort; 8 | 9 | axios.defaults.withCredentials = true 10 | axios.interceptors.response.use(response => { 11 | if (response && response.status && (response.status == 200)) { 12 | return Promise.resolve({ 13 | error: null, 14 | data: response.data 15 | }); 16 | } else { 17 | if (config.devEnv) { 18 | return Promise.resolve({ 19 | error: null, 20 | data: response.data 21 | }); 22 | } else { 23 | return Promise.reject({ 24 | error: { 25 | message: "出错了" 26 | }, 27 | data: response 28 | }); 29 | } 30 | } 31 | }); 32 | -------------------------------------------------------------------------------- /juejin/plugins/vue-notification.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Notification from 'vue-notification' 3 | import userLoginUtil from "../util/userLoginUtil.js"; 4 | 5 | 6 | Vue.use(Notification) 7 | Vue.prototype.$eventHub= Vue.prototype.$eventHub || new Vue(); 8 | 9 | Vue.prototype.$showLoading = function() { 10 | this.$eventHub.$emit("SHOWLOADING", { 11 | loading: true 12 | }); 13 | } 14 | Vue.prototype.$hiddenLoading = function() { 15 | this.$eventHub.$emit("SHOWLOADING", { 16 | loading: false 17 | }); 18 | } 19 | Vue.prototype.$showAlert = function(params) { 20 | if (typeof(params) == 'string') { 21 | params = { 22 | message:params 23 | }; 24 | } 25 | this.$eventHub.$emit("SHOWALERT", params); 26 | } 27 | Vue.prototype.$hiddenAlert = function() { 28 | this.$eventHub.$emit("HIDDENALERT", {}); 29 | } 30 | Vue.prototype.$userLoginUtil = userLoginUtil; 31 | -------------------------------------------------------------------------------- /juejin/server/api/index.js: -------------------------------------------------------------------------------- 1 | import PostModule from './posts.js'; 2 | import SigninModule from './signin.js'; 3 | import SignoutModule from './signout.js'; 4 | import SignupModule from './signup.js'; 5 | 6 | export function startRouter(app) { 7 | app.get('/', function(req, res) { 8 | res.redirect('/posts'); 9 | }); 10 | app.use('/api/posts', PostModule); 11 | app.use('/api/login', SigninModule); 12 | app.use('/api/signup', SignupModule); 13 | app.use('/api/signout', SignoutModule); 14 | } -------------------------------------------------------------------------------- /juejin/server/api/posts.js: -------------------------------------------------------------------------------- 1 | let express = require('express'); 2 | let router = express.Router(); 3 | import PostModel from '../models/posts'; 4 | var xss = require('xss'); 5 | import { 6 | postToSQLUpdate 7 | } from '../../util/assist'; 8 | import CommentModel from '../models/comments'; 9 | let checkLogin = require('../middlewares/check').checkLogin; 10 | 11 | //GET /posts 所有用户或者特定用户的文章页 12 | // eg: GET /posts?author=xxx 13 | router.get('/', function (req, res, next) { 14 | let authorId = req.query && req.query.author; 15 | let pageIndex = req.query && req.query.pageIndex; 16 | PostModel.getPosts(authorId, pageIndex).then(posts => { 17 | res.json(posts); 18 | }).catch(error => { 19 | res.json(error) 20 | }); 21 | }); 22 | // POST /posts 发表一篇文章 23 | router.post('/create', checkLogin, function (req, res, next) { 24 | let author = req.session.user; 25 | let title = req.body.title; 26 | let content = req.body.content; 27 | try { 28 | if (!title.length) { 29 | throw new Error('请填写标题'); 30 | } 31 | if (!content.length) { 32 | throw new Error('请填写内容'); 33 | } 34 | } catch (e) { 35 | res.json({ 36 | err: { 37 | message: e.message || "发布失败" 38 | }, 39 | post: null 40 | }); 41 | } 42 | let post = { 43 | author: author, 44 | title: title, 45 | content: content, 46 | pv: 0 47 | }; 48 | PostModel.create(post).then(post => { 49 | res.json({ 50 | err: null, 51 | post: post 52 | }); 53 | }).catch(e => { 54 | res.json({ 55 | err: { 56 | message: e.message || "添加出错" 57 | }, 58 | post: null 59 | }); 60 | }); 61 | }); 62 | 63 | // GET /posts/:postId 单独一篇的文章页 64 | router.get('/:postId', function (req, res, next) { 65 | let postId = req.params.postId; 66 | Promise.all([ 67 | PostModel.getPostById(postId), //获取文章 68 | CommentModel.getComments(postId), //获取评论 69 | PostModel.incPv(postId) //添加访问次数 70 | ]).then(result => { 71 | let post = result[0]; 72 | let comments = result[1]; 73 | post.content = post.content.replace("