Skip to content

Commit f97410a

Browse files
committed
1、详情页代码高亮 Bug fixed
2、数据库连接池参数添加 3、前端添加环境配置文件
1 parent 59bba6b commit f97410a

File tree

13 files changed

+80
-22
lines changed

13 files changed

+80
-22
lines changed

weblog-springboot/weblog-web/src/main/java/com/quanxiaoha/weblog/web/service/impl/ArchiveServiceImpl.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public Response queryArchive(QueryArchivePageListReqVO queryArchivePageListReqVO
7474
class MonthKeyComparator implements Comparator<String> {
7575
@Override
7676
public int compare(String o1, String o2) {
77-
// 使用YearMonth类将字符串解析成日期,并根据日期进行倒序排序
77+
// 使用 YearMonth 类将字符串解析成日期,并根据日期进行倒序排序
7878
YearMonth ym1 = YearMonth.parse(o1);
7979
YearMonth ym2 = YearMonth.parse(o2);
8080
return ym2.compareTo(ym1);

weblog-springboot/weblog-web/src/main/resources/application-dev.yaml

+9
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,14 @@ spring:
44
url: jdbc:p6spy:mysql://127.0.0.1:3306/weblog?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&zeroDateTimeBehavior=convertToNull
55
username: root
66
password: 123456
7+
hikari:
8+
minimum-idle: 5
9+
maximum-pool-size: 9
10+
auto-commit: true
11+
idle-timeout: 30000
12+
pool-name: Weblog-HikariCP
13+
max-lifetime: 1800000
14+
connection-timeout: 30000
15+
connection-test-query: SELECT 1
716

817

weblog-springboot/weblog-web/src/main/resources/application-prod.yaml

+9
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ spring:
44
url: jdbc:mysql://172.17.0.1:3306/weblog?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&zeroDateTimeBehavior=convertToNull
55
username: root
66
password: qwe123
7+
hikari:
8+
minimum-idle: 5
9+
maximum-pool-size: 9
10+
auto-commit: true
11+
idle-timeout: 30000
12+
pool-name: Weblog-HikariCP
13+
max-lifetime: 1800000
14+
connection-timeout: 30000
15+
connection-test-query: SELECT 1
716

817
#=================================================================
918
# log

weblog-vue3/.env.development

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
VITE_APP_BASE_API='/api'

weblog-vue3/.env.production

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
VITE_APP_BASE_API='/api'

weblog-vue3/package-lock.json

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

weblog-vue3/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"universal-cookie": "^4.0.4",
3030
"v-viewer": "^3.0.11",
3131
"vue": "^3.2.47",
32+
"vue-highlightjs": "^1.3.3",
3233
"vue-router": "^4.1.6",
3334
"vue3-highlightjs": "^1.0.5",
3435
"vuex": "^4.0.2"

weblog-vue3/src/App.vue

+2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66

77
<script setup>
88
import { defineComponent } from 'vue'
9+
910
import zhCn from 'element-plus/lib/locale/lang/zh-cn'
1011
let locale = zhCn
12+
1113
</script>
1214

1315
<style>

weblog-vue3/src/axios.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import store from "@/store";
55
import { Console } from "windicss/utils";
66

77
const instance = axios.create({
8-
baseURL: '/api',
8+
baseURL: import.meta.env.VITE_APP_BASE_API,
99
// baseURL: '/',
1010
timeout: 7000
1111
});

weblog-vue3/src/main.js

+10-5
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ import * as ElementPlusIconsVue from '@element-plus/icons-vue'
88
import store from './store'
99
import "@/permission"
1010

11-
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
11+
// import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
1212
// 代码高亮
13-
import VueHighlightJS from 'vue3-highlightjs'
14-
import 'vue3-highlightjs/styles/monokai-sublime.css'
13+
import hljs from 'highlight.js'
14+
import 'highlight.js/styles/tokyo-night-dark.css'
1515

16-
// 富文本图片预览
16+
// 富文本图片点击预览
1717
import "viewerjs/dist/viewer.css";
1818
import Viewer from "v-viewer";
1919

@@ -22,7 +22,12 @@ const app = createApp(App)
2222
app.use(store)
2323
app.use(router)
2424

25-
app.use(VueHighlightJS)
25+
app.directive('highlight',function (el) {
26+
let highlight = el.querySelectorAll('pre code');
27+
highlight.forEach((block)=>{
28+
hljs.highlightBlock(block)
29+
})
30+
});
2631

2732
// 引入图标
2833
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {

weblog-vue3/src/pages/frontend/archive-list.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<!-- 左边栏 -->
77
<div class="col-span-4 px-3 md:col-span-3 sm:col-span-4">
88
<div v-for="(item, index) in archives" :key="index"
9-
class="p-5 mb-4 border border-gray-200 rounded-lg bg-gray-50 dark:bg-gray-800 dark:border-gray-700">
9+
class="p-5 mb-4 border border-gray-200 rounded-lg bg-white dark:bg-gray-800 dark:border-gray-700">
1010
<time class="text-lg font-semibold text-gray-900 dark:text-white">{{ item.month }}</time>
1111
<ol class="mt-3 divide-y divider-gray-200 dark:divide-gray-700">
1212
<li v-for="(item2, index2) in item.articles" :key="index2">

weblog-vue3/src/pages/frontend/article-detail.vue

+34-13
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<ol class="inline-flex items-center space-x-1 md:space-x-3">
1313
<li class="inline-flex items-center">
1414
<a @click="router.push('/')"
15-
class="cursor-pointer inline-flex items-center text-sm font-medium text-gray-700 hover:text-blue-600 dark:text-gray-400 dark:hover:text-white">
15+
class="cursor-pointer inline-flex items-center text-sm font-medium text-gray-500 hover:text-blue-600 dark:text-gray-400 dark:hover:text-white">
1616
<svg class="w-3 h-3 mr-2.5" aria-hidden="true" xmlns="http://www.w3.org/2000/svg"
1717
fill="currentColor" viewBox="0 0 20 20">
1818
<path
@@ -66,8 +66,9 @@
6666
</svg> 阅读量 {{ article.readNum }}
6767
</div>
6868

69-
<div class="article-content" v-viewer v-html="article.content" v-highlightjs>
69+
<div class="article-content" v-viewer v-html="article.content" v-highlight>
7070
</div>
71+
7172
<!-- 标签 -->
7273
<div class="mt-5 mb-5">
7374
<div @click="goTagArticleListPage(item.id, item.name)" v-for="(item, index) in article.tags"
@@ -262,7 +263,7 @@ const goTagArticleListPage = (id, name) => {
262263
color: #f8f8f2;
263264
border-radius: 5px;
264265
padding: 32px 0 0;
265-
font-size: 16px;
266+
font-size: 17px;
266267
}
267268
268269
:deep(pre:before) {
@@ -287,6 +288,20 @@ const goTagArticleListPage = (id, name) => {
287288
font-family: -apple-system, BlinkMacSystemFont, PingFang SC, Hiragino Sans GB, Microsoft Yahei, Arial, sans-serif;
288289
}
289290
291+
:deep(.article-content h1, .article-content h2, .article-content h3, .article-content h4, .article-content h5, .article-content h6) {
292+
margin: 30px 0 10px 0;
293+
color: #292525;
294+
line-height: 150%;
295+
font-family: PingFang SC,Helvetica Neue,Helvetica,Hiragino Sans GB,Microsoft YaHei,"\5FAE\8F6F\96C5\9ED1",Arial,sans-serif;
296+
}
297+
298+
:deep(.article-content h3) {
299+
font-size: 20px;
300+
margin-top: 40px;
301+
margin-bottom: 16px;
302+
font-weight: 600;
303+
}
304+
290305
:deep(.image-caption) {
291306
min-width: 20%;
292307
max-width: 80%;
@@ -306,11 +321,22 @@ const goTagArticleListPage = (id, name) => {
306321
padding-bottom: 10px;
307322
}
308323
309-
:deep(code) {
310-
display: inline;
324+
:deep(code:not(pre code)) {
325+
padding: 2px 4px;
326+
margin: 0 2px;
327+
font-size: 95%!important;
328+
border-radius: 4px;
329+
color: rgb(41, 128, 185);
330+
background-color: rgba(27, 31, 35, 0.05);
311331
font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;
312-
border-radius: 2px;
313-
padding: 5px;
332+
}
333+
334+
:deep(pre code) {
335+
display: block;
336+
font-size: 95% !important;
337+
background-color: rgba(27, 31, 35, 0.05);
338+
font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;
339+
/* color: #fff; */
314340
}
315341
316342
:deep(article ul) {
@@ -324,12 +350,7 @@ const goTagArticleListPage = (id, name) => {
324350
font-size: 16px;
325351
}
326352
327-
:deep(pre code) {
328-
display: block;
329-
font-size: 95% !important;
330-
background-color: rgba(27, 31, 35, 0.05);
331-
font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;
332-
}
353+
333354
334355
:deep(blockquote) {
335356
/* margin: 20px 0; */

weblog-vue3/tailwind.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module.exports = {
99
extend: {},
1010
},
1111
plugins: [
12-
require('flowbite/plugin')
12+
require('flowbite/plugin'),
1313
],
1414
corePlugins: {
1515
// 取消 tailwindcss 的默认样式

0 commit comments

Comments
 (0)