From d95882e507736a9737fee92a9944f3a73bd39ade Mon Sep 17 00:00:00 2001 From: ronnie Date: Fri, 1 Jan 2021 22:18:36 +0800 Subject: [PATCH 01/11] =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E6=94=B9=E7=94=A8nestj?= =?UTF-8?q?s+mysql?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 47 +++++- package.json | 3 +- public/index.html | 38 ++--- src/ajax/request.js | 3 +- src/components/loading.vue | 10 +- src/layout/admin/index.vue | 1 - src/layout/home/components/app-footer.vue | 41 ++++++ src/layout/home/index.vue | 3 + src/router/index.js | 2 +- src/settings.js | 2 +- src/utils/gitee-api.js | 128 ---------------- src/views/admin/category/index.vue | 75 +++++----- src/views/admin/post-list/detail.vue | 138 ++++-------------- src/views/admin/post-list/index.vue | 75 ++-------- .../article/components/index-secondary.vue | 13 +- .../home/article/components/post-list.vue | 6 +- src/views/home/article/index.vue | 23 +-- src/views/home/article/post-detail.vue | 41 ++---- vue.config.js | 18 ++- 19 files changed, 259 insertions(+), 408 deletions(-) create mode 100644 src/layout/home/components/app-footer.vue delete mode 100644 src/utils/gitee-api.js diff --git a/package-lock.json b/package-lock.json index 4043866..53c7f2b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "Gitee-Blog", + "name": "blog", "version": "0.1.0", "lockfileVersion": 1, "requires": true, @@ -6528,6 +6528,14 @@ "integrity": "sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA=", "dev": true }, + "linkify-it": { + "version": "3.0.2", + "resolved": "https://registry.npm.taobao.org/linkify-it/download/linkify-it-3.0.2.tgz", + "integrity": "sha1-9V7ri8HTrnVASeEkqzu1bZd5f7g=", + "requires": { + "uc.micro": "^1.0.1" + } + }, "load-json-file": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-1.1.0.tgz", @@ -6718,6 +6726,30 @@ "object-visit": "^1.0.0" } }, + "markdown-it": { + "version": "12.0.4", + "resolved": "https://registry.npm.taobao.org/markdown-it/download/markdown-it-12.0.4.tgz?cache=0&sync_timestamp=1608478523224&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fmarkdown-it%2Fdownload%2Fmarkdown-it-12.0.4.tgz", + "integrity": "sha1-7sgkfSljJ+rDupdGve7Jz8x1HjM=", + "requires": { + "argparse": "^2.0.1", + "entities": "~2.1.0", + "linkify-it": "^3.0.1", + "mdurl": "^1.0.1", + "uc.micro": "^1.0.5" + }, + "dependencies": { + "argparse": { + "version": "2.0.1", + "resolved": "https://registry.npm.taobao.org/argparse/download/argparse-2.0.1.tgz", + "integrity": "sha1-JG9Q88p4oyQPbJl+ipvR6sSeSzg=" + }, + "entities": { + "version": "2.1.0", + "resolved": "https://registry.npm.taobao.org/entities/download/entities-2.1.0.tgz?cache=0&sync_timestamp=1602897029273&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fentities%2Fdownload%2Fentities-2.1.0.tgz", + "integrity": "sha1-mS0xKc999ocLlsV4WMJJoSD4uLU=" + } + } + }, "mavon-editor": { "version": "2.9.0", "resolved": "https://registry.npm.taobao.org/mavon-editor/download/mavon-editor-2.9.0.tgz", @@ -6745,6 +6777,11 @@ "integrity": "sha512-iV3XNKw06j5Q7mi6h+9vbx23Tv7JkjEVgKHW4pimwyDGWm0OIQntJJ+u1C6mg6mK1EaTv42XQ7w76yuzH7M2cA==", "dev": true }, + "mdurl": { + "version": "1.0.1", + "resolved": "https://registry.npm.taobao.org/mdurl/download/mdurl-1.0.1.tgz", + "integrity": "sha1-/oWy7HWlkDfyrf7BAP1sYBdhFS4=" + }, "media-typer": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", @@ -7866,7 +7903,8 @@ "version": "2.2.2", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.2.tgz", "integrity": "sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==", - "dev": true + "dev": true, + "optional": true }, "pify": { "version": "4.0.1", @@ -10483,6 +10521,11 @@ "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", "dev": true }, + "uc.micro": { + "version": "1.0.6", + "resolved": "https://registry.npm.taobao.org/uc.micro/download/uc.micro-1.0.6.tgz", + "integrity": "sha1-nEEagCpAmpH8bPdAgbq6NLJEmaw=" + }, "uglify-js": { "version": "3.4.10", "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.4.10.tgz", diff --git a/package.json b/package.json index 82fb454..570ced8 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "element-ui": "^2.13.2", "github-markdown-css": "^4.0.0", "js-cookie": "^2.2.1", + "markdown-it": "^12.0.4", "mavon-editor": "^2.9.0", "vssue": "^1.4.6", "vue": "^2.6.11", @@ -31,4 +32,4 @@ "last 2 versions", "not dead" ] -} \ No newline at end of file +} diff --git a/public/index.html b/public/index.html index 797d6e3..4d18030 100644 --- a/public/index.html +++ b/public/index.html @@ -1,22 +1,24 @@ - - - - - - <%= htmlWebpackPlugin.options.title %> - - - +
+ + + + \ No newline at end of file diff --git a/src/ajax/request.js b/src/ajax/request.js index 9cc80e1..0475b24 100644 --- a/src/ajax/request.js +++ b/src/ajax/request.js @@ -1,7 +1,8 @@ import axios from 'axios' const service = axios.create({ - // baseURL: 'https://gitee.com/', + baseURL: 'http://47.113.180.205:3000/', + // baseURL: 'http://localhost:3000/', timeout: 10000, withCredentials: false }) diff --git a/src/components/loading.vue b/src/components/loading.vue index 6e32c38..9ecf54d 100644 --- a/src/components/loading.vue +++ b/src/components/loading.vue @@ -11,13 +11,13 @@ export default { name: 'Loading', props: { - show: Boolean + show: Boolean, }, data() { return { - text: '正在加载...' + text: '正在加载...', } - } + }, } \ No newline at end of file diff --git a/src/layout/home/index.vue b/src/layout/home/index.vue index 1a1d47f..55cfade 100644 --- a/src/layout/home/index.vue +++ b/src/layout/home/index.vue @@ -2,17 +2,20 @@
+
diff --git a/src/router/index.js b/src/router/index.js index 0c4c928..a0baf68 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -27,7 +27,7 @@ const routes = [ } }, { - path: 'article/:name*', + path: 'article/:id*', component: _ => import('@/views/home/article/post-detail'), }, { diff --git a/src/settings.js b/src/settings.js index f1446ce..017731f 100644 --- a/src/settings.js +++ b/src/settings.js @@ -15,7 +15,7 @@ module.exports = { '/article': '文章', 'https://coolshell.cn': '友情链接', // '/works': '作品', - '/article/关于本站': '关于本站' + '/about': '关于本站' }, skills: ['Vue', 'React', 'JavaScript', 'Css', 'Java', 'C#', 'MySql', 'Sql Server', 'MongoDB'], }, diff --git a/src/utils/gitee-api.js b/src/utils/gitee-api.js deleted file mode 100644 index 2bd79ff..0000000 --- a/src/utils/gitee-api.js +++ /dev/null @@ -1,128 +0,0 @@ -import axios from '@/ajax/request' -import { getToken } from '@/utils/cookie-util' -import { to, utf8ToBase64, base64ToUtf8 } from '@/utils/common' - -const { giteeApiOptions } = require('@/settings') -const { baseApiURL, owner, repo } = giteeApiOptions - -const baseRepoURL = `${baseApiURL}/repos/${owner}/${repo}` - -const giteeApi = { - getFileSha: async (fileName) => { - const [err, res] = await to(axios.get(`${baseRepoURL}/contents/${fileName}`)) - if (err) { - return '' - } - if (!res.data.sha) { - return '' - } - return res.data.sha - }, - - getFile: async (fileName) => { - const [err, res] = await to(axios.get(`${baseRepoURL}/contents/${fileName}`)) - if (err) { - return null - } - if (res.data.length) { - return res.data - } - if (res.data.sha) { - return { - sha: res.data.sha, - name: res.data.name, - path: res.data.path, - content: base64ToUtf8(res.data.content) - } - } - return null - }, - - addFile: async (fileName, content) => { - const sha = await giteeApi.getFileSha(fileName) - if (sha) { - return { - status: 'Fail', - msg: `已经存在 ${fileName}` - } - } - content = utf8ToBase64(content) - const data = { access_token: getToken(), message: `add ${fileName}`, content } - const [err, res] = await to(axios.post(`${baseRepoURL}/contents/${fileName}`, data)) - if (err) { - return { - status: 'Fail', - msg: `添加失败: ${err}` - } - } - return { - status: 'OK', - msg: `添加成功: ${fileName}`, - } - }, - - removeFile: async (fileName) => { - const sha = await giteeApi.getFileSha(fileName) - if (!sha) { - return { - status: 'Fail', - msg: `不存在 ${fileName}` - } - } - let params = { access_token: getToken(), message: `remove ${fileName}`, sha } - const [err, res] = await to(axios.delete(`${baseRepoURL}/contents/${fileName}`, { params })) - - if (err) { - return { - status: 'Fail', - msg: `删除失败: ${err}` - } - } - return { - status: 'OK', - msg: `删除成功: ${fileName}` - } - }, - - updateFile: async (fileName, sha, content) => { - content = utf8ToBase64(content) - const data = { access_token: getToken(), message: `update ${fileName}`, content, sha } - const [err, res] = await to(axios.put(`${baseRepoURL}/contents/${fileName}`, data)) - if (err) { - return { - status: "Fail", - msg: `更新失败: ${err}` - } - } - return { - status: 'OK', - msg: `更新成功: ${fileName}` - } - }, - - checkRepo: async _ => { - const params = { access_token: getToken() } - const [err, res] = await to(axios.get(baseRepoURL, { params })) - if (err) { - return false - } - return true - }, - - forkRepo: async _ => { - const data = { access_token: getToken() } - const [err, res] = await to(axios.post(`${baseApiURL}/repos/zclzone/gitee-db/forks`, data)) - if (err) { - return { - status: 'Fail' - } - } - return { - status: 'OK' - } - }, -} - -export { - giteeApi -} \ No newline at end of file diff --git a/src/views/admin/category/index.vue b/src/views/admin/category/index.vue index 50398f8..768f50f 100644 --- a/src/views/admin/category/index.vue +++ b/src/views/admin/category/index.vue @@ -1,24 +1,44 @@ diff --git a/src/views/admin/post-list/detail.vue b/src/views/admin/post-list/detail.vue index 6df998a..b1ffe4e 100644 --- a/src/views/admin/post-list/detail.vue +++ b/src/views/admin/post-list/detail.vue @@ -16,29 +16,34 @@ - + - - + + - + - + - + @@ -50,8 +55,6 @@ diff --git a/src/views/home/article/components/index-secondary.vue b/src/views/home/article/components/index-secondary.vue index 5caf4db..19c19f8 100644 --- a/src/views/home/article/components/index-secondary.vue +++ b/src/views/home/article/components/index-secondary.vue @@ -51,24 +51,24 @@ @@ -134,15 +134,12 @@ export default { categories[item.category] = item.category }) return categories - // return this.postListData.map(item => { - // return item.category - // }) }, recentList() { return this.postListData.slice(0, 10) }, recommendList() { - return this.postListData.filter((item) => !!item.isRecommend) + return this.postListData.filter((item) => item.isRecommend) }, }, } diff --git a/src/views/home/article/components/post-list.vue b/src/views/home/article/components/post-list.vue index 10138cd..45e5ed6 100644 --- a/src/views/home/article/components/post-list.vue +++ b/src/views/home/article/components/post-list.vue @@ -2,8 +2,8 @@ diff --git a/src/views/home/article/index.vue b/src/views/home/article/index.vue index ece9ccd..66a9c22 100644 --- a/src/views/home/article/index.vue +++ b/src/views/home/article/index.vue @@ -21,8 +21,6 @@ import Secondary from './components/index-secondary' import { setPageTitle } from '@/utils/page-title-util' -import { giteeApi } from '@/utils/gitee-api' - const { siteOptions } = require('@/settings.js') export default { @@ -39,14 +37,14 @@ export default { }, async mounted() { this.$loading.show() - const file = await giteeApi.getFile(`db/_post/postList.json`) + const { data } = await this.$axios.get('/post') this.$loading.hide() - if (!file) { + if (!data || !data.length) { this.$message.error('No data') return } - this.postListData = JSON.parse(file.content) - .content.data.filter((item) => !!item.isPublish) + this.postListData = data + .filter((item) => item.isPublish) .sort((a, b) => new Date(b.date) - new Date(a.date)) this.filterPostList() }, @@ -69,11 +67,14 @@ export default { this.headerTitle = `"${keyword}" 的搜索结果` setPageTitle(`搜索结果 | ${keyword}`) return (this.postList = this.postListData.filter((post) => { - return [post.author, post.name, post.category, post.description].some( - (item) => { - return item.toLowerCase().indexOf(keyword.toLowerCase()) !== -1 - } - ) + return [ + post.author, + post.title, + post.category, + post.description, + ].some((item) => { + return item.toLowerCase().indexOf(keyword.toLowerCase()) !== -1 + }) })) } this.headerTitle = '所有文章' diff --git a/src/views/home/article/post-detail.vue b/src/views/home/article/post-detail.vue index 7298855..ff2464f 100644 --- a/src/views/home/article/post-detail.vue +++ b/src/views/home/article/post-detail.vue @@ -1,13 +1,13 @@ @@ -15,8 +15,7 @@ @@ -69,7 +60,7 @@ export default { padding: 50px; position: relative; &::before { - content: ""; + content: ''; position: absolute; left: 0; top: 0; diff --git a/vue.config.js b/vue.config.js index d52be51..d433b29 100644 --- a/vue.config.js +++ b/vue.config.js @@ -2,12 +2,26 @@ const settings = require('./src/settings.js') const title = settings.title || '奇思笔记' module.exports = { - // publicPath: './', - publicPath: process.env.NODE_ENV === 'production' ? `/${settings.pagesRepo}/` : './', + publicPath: './', + // publicPath: process.env.NODE_ENV === 'production' ? `/${settings.pagesRepo}/` : './', chainWebpack: config => { config.plugin('html').tap(args => { args[0].title = title return args }) + }, + configureWebpack: config => { + if (process.env.NODE_ENV === 'production') { + config.mode = 'production' + //打包文件大小配置 + config['performance'] = { + maxEntrypointSize: 10000000, + maxAssetSize: 30000000 + } + } + }, + devServer: { + // proxy: 'http://localhost:3000' + // proxy: 'http://47.113.180.205:3000' } } From 4da7ccc77620f25229062a9263d901e7d1fc2d21 Mon Sep 17 00:00:00 2001 From: ronnie Date: Fri, 1 Jan 2021 22:32:52 +0800 Subject: [PATCH 02/11] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ajax/request.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ajax/request.js b/src/ajax/request.js index 0475b24..0508f4d 100644 --- a/src/ajax/request.js +++ b/src/ajax/request.js @@ -1,7 +1,8 @@ import axios from 'axios' const service = axios.create({ - baseURL: 'http://47.113.180.205:3000/', + // baseURL: 'http://47.113.180.205:3000/', + baseURL: 'http:api.qszone.com/', // baseURL: 'http://localhost:3000/', timeout: 10000, withCredentials: false From ab9b7ddf70dcaaf48bc358c1b2a8c046151ce20c Mon Sep 17 00:00:00 2001 From: ronnie Date: Fri, 1 Jan 2021 22:43:04 +0800 Subject: [PATCH 03/11] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ajax/request.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ajax/request.js b/src/ajax/request.js index 0508f4d..5c5bc38 100644 --- a/src/ajax/request.js +++ b/src/ajax/request.js @@ -2,7 +2,7 @@ import axios from 'axios' const service = axios.create({ // baseURL: 'http://47.113.180.205:3000/', - baseURL: 'http:api.qszone.com/', + baseURL: 'http://api.qszone.com/', // baseURL: 'http://localhost:3000/', timeout: 10000, withCredentials: false From 53e8025d1c492eb040946d6485c4369b39ca3d85 Mon Sep 17 00:00:00 2001 From: ronnie Date: Sat, 2 Jan 2021 12:44:30 +0800 Subject: [PATCH 04/11] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E5=9F=BA=E7=A1=80=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ajax/request.js | 2 +- src/views/admin/post-list/index.vue | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ajax/request.js b/src/ajax/request.js index 5c5bc38..c181b43 100644 --- a/src/ajax/request.js +++ b/src/ajax/request.js @@ -2,7 +2,7 @@ import axios from 'axios' const service = axios.create({ // baseURL: 'http://47.113.180.205:3000/', - baseURL: 'http://api.qszone.com/', + // baseURL: 'http://www.qszone.com/', // baseURL: 'http://localhost:3000/', timeout: 10000, withCredentials: false diff --git a/src/views/admin/post-list/index.vue b/src/views/admin/post-list/index.vue index 4ef9852..7694896 100644 --- a/src/views/admin/post-list/index.vue +++ b/src/views/admin/post-list/index.vue @@ -24,7 +24,7 @@ v-for="(item, index) in columns" >