1010 </a >
1111 <span class =" tk-tag tk-tag-green" v-if =" comment.master" >博主</span >
1212 <small class =" tk-time" >{{ displayCreated }}</small >
13- <div class =" tk-tag" >{{ comment.os }}</div >
14- <div class =" tk-tag" >{{ comment.browser }}</div >
1513 </div >
1614 <tk-action :liked =" comment.liked"
1715 :like-count =" comment.like"
2321 <span v-if =" comment.pid" >回复 <a :href =" `#${comment.pid}`" >@{{ comment.ruser }}</a > :</span >
2422 <span v-html =" comment.comment" ></span >
2523 </div >
24+ <div class =" tk-extras" >
25+ <div class =" tk-extra" ><span class =" tk-icon" v-html =" iconOs" ></span >  ; {{ comment.os }}</div >
26+ <div class =" tk-extra" ><span class =" tk-icon" v-html =" iconBrowser" ></span >  ; {{ comment.browser }}</div >
27+ </div >
2628 <!-- 回复列表 -->
2729 <div class =" tk-replies" :class =" { 'tk-replies-expand': isExpanded }" ref =" tk-replies" >
2830 <tk-comment v-for =" reply in comment.replies"
@@ -47,6 +49,37 @@ import { timeago } from '../../js/utils'
4749import TkAction from ' ./TkAction.vue'
4850import TkAvatar from ' ./TkAvatar.vue'
4951import TkSubmit from ' ./TkSubmit.vue'
52+ import iconWindows from ' @fortawesome/fontawesome-free/svgs/brands/windows.svg'
53+ import iconApple from ' @fortawesome/fontawesome-free/svgs/brands/apple.svg'
54+ import iconAndroid from ' @fortawesome/fontawesome-free/svgs/brands/android.svg'
55+ import iconLinux from ' @fortawesome/fontawesome-free/svgs/brands/linux.svg'
56+ import iconUbuntu from ' @fortawesome/fontawesome-free/svgs/brands/ubuntu.svg'
57+ import iconChrome from ' @fortawesome/fontawesome-free/svgs/brands/chrome.svg'
58+ import iconFirefox from ' @fortawesome/fontawesome-free/svgs/brands/firefox-browser.svg'
59+ import iconSafari from ' @fortawesome/fontawesome-free/svgs/brands/safari.svg'
60+ import iconIe from ' @fortawesome/fontawesome-free/svgs/brands/internet-explorer.svg'
61+ import iconEdge from ' @fortawesome/fontawesome-free/svgs/brands/edge.svg'
62+ import iconOther from ' @fortawesome/fontawesome-free/svgs/regular/window-maximize.svg'
63+
64+
65+ const osList = {
66+ win: iconWindows,
67+ mac: iconApple,
68+ ipad: iconApple,
69+ iphone: iconApple,
70+ android: iconAndroid,
71+ ubuntu: iconUbuntu,
72+ linux: iconLinux
73+ }
74+
75+ const browserList = {
76+ edge: iconEdge,
77+ chrome: iconChrome,
78+ firefox: iconFirefox,
79+ safari: iconSafari,
80+ explorer: iconIe,
81+ ie: iconIe
82+ }
5083
5184export default {
5285 name: ' tk-comment' , // 允许组件模板递归地调用自身
@@ -70,11 +103,24 @@ export default {
70103 displayCreated () {
71104 return timeago (this .comment .created )
72105 },
106+ iconOs () {
107+ return this .getIconBy (this .comment .os , osList)
108+ },
109+ iconBrowser () {
110+ return this .getIconBy (this .comment .browser , browserList)
111+ },
73112 showExpand () {
74113 return this .hasExpand && ! this .isExpanded
75114 }
76115 },
77116 methods: {
117+ getIconBy (name , list ) {
118+ const lowerCaseName = name .toLowerCase ()
119+ for (let key in list) {
120+ if (lowerCaseName .indexOf (key) !== - 1 ) return list[key]
121+ }
122+ return iconOther
123+ },
78124 showExpandIfNeed () {
79125 if (this .comment .replies && this .comment .replies .length > 0 && this .$refs [' tk-replies' ]) {
80126 this .hasExpand = this .$refs [' tk-replies' ].scrollHeight > 200
@@ -141,6 +187,25 @@ export default {
141187.tk-nick-link :hover {
142188 color : #409eff ;
143189}
190+ .tk-extras {
191+ color : #999999 ;
192+ font-size : 0.875em ;
193+ display : flex ;
194+ margin-top : 0.5rem ;
195+ }
196+ .tk-extra {
197+ margin-right : 0.75rem ;
198+ }
199+ .tk-icon {
200+ display : inline-block ;
201+ height : 1em ;
202+ width : 1em ;
203+ line-height : 0 ;
204+ vertical-align : text-top ;
205+ }
206+ .tk-icon /deep/ svg {
207+ fill : currentColor ;
208+ }
144209.tk-tag {
145210 display : inline-block ;
146211 padding : 0 0.5rem ;
0 commit comments