Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
beyond-clouds-front
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
beyond-clouds-front
Commits
4ace35b9
Commit
4ace35b9
authored
Mar 30, 2020
by
yanju
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
文章代码添加行号
parent
ac00a2c5
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
490 additions
and
19 deletions
+490
-19
assets/base.scss
+39
-0
components/pc/highlightjs-line-numbers.js
+302
-0
nuxt.config.js
+2
-1
package-lock.json
+109
-0
pages/answer/detail/_id.vue
+6
-1
pages/blog/detail/_id.vue
+11
-3
pages/dynamic/index.vue
+0
-12
pages/news/detail/_id.vue
+6
-1
pages/project/detail/_id.vue
+6
-1
plugins/highlight.js
+9
-0
No files found.
assets/base.scss
View file @
4ace35b9
...
...
@@ -530,5 +530,44 @@
}
}
.hljs-ln
{
tr
{
border
:none
;
td
{
background-color
:
#fcfcfc
;
border
:none
;
.hljs-ln-numbers
{
text-align
:
center
;
color
:
#ccc
;
border-right
:
1px
solid
#999
;
vertical-align
:
top
;
padding-right
:
5px
;
-webkit-touch-callout
:
none
;
-webkit-user-select
:
none
;
-khtml-user-select
:
none
;
-moz-user-select
:
none
;
-ms-user-select
:
none
;
user-select
:
none
;
}
.hljs-ln-code
{
padding-left
:
10px
;
}
/* .hljs-ln-code,
.hljs-ln-numbers {
line-height: 14px;
} */
code
{
white-space
:
pre-wrap
;
overflow
:
auto
;
}
}
}
}
}
components/pc/highlightjs-line-numbers.js
0 → 100644
View file @
4ace35b9
// jshint multistr:true
export
default
function
highlight
(
w
=
window
,
d
=
document
,
n
=
this
)
{
var
TABLE_NAME
=
'hljs-ln'
,
LINE_NAME
=
'hljs-ln-line'
,
CODE_BLOCK_NAME
=
'hljs-ln-code'
,
NUMBERS_BLOCK_NAME
=
'hljs-ln-numbers'
,
NUMBER_LINE_NAME
=
'hljs-ln-n'
,
DATA_ATTR_NAME
=
'data-line-number'
,
BREAK_LINE_REGEXP
=
/
\r\n
|
\r
|
\n
/g
;
if
(
n
.
$hljs
)
{
n
.
$hljs
.
initLineNumbersOnLoad
=
initLineNumbersOnLoad
;
n
.
$hljs
.
lineNumbersBlock
=
lineNumbersBlock
;
n
.
$hljs
.
lineNumbersValue
=
lineNumbersValue
;
addStyles
();
}
else
{
w
.
console
.
error
(
'highlight.js not detected!'
);
}
function
isHljsLnCodeDescendant
(
domElt
)
{
var
curElt
=
domElt
;
while
(
curElt
)
{
if
(
curElt
.
className
&&
curElt
.
className
.
indexOf
(
'hljs-ln-code'
)
!==
-
1
)
{
return
true
;
}
curElt
=
curElt
.
parentNode
;
}
return
false
;
}
function
getHljsLnTable
(
hljsLnDomElt
)
{
var
curElt
=
hljsLnDomElt
;
while
(
curElt
.
nodeName
!==
'TABLE'
)
{
curElt
=
curElt
.
parentNode
;
}
return
curElt
;
}
// Function to workaround a copy issue with Microsoft Edge.
// Due to hljs-ln wrapping the lines of code inside a <table> element,
// itself wrapped inside a <pre> element, window.getSelection().toString()
// does not contain any line breaks. So we need to get them back using the
// rendered code in the DOM as reference.
function
edgeGetSelectedCodeLines
(
selection
)
{
// current selected text without line breaks
var
selectionText
=
selection
.
toString
();
// get the <td> element wrapping the first line of selected code
var
tdAnchor
=
selection
.
anchorNode
;
while
(
tdAnchor
.
nodeName
!==
'TD'
)
{
tdAnchor
=
tdAnchor
.
parentNode
;
}
// get the <td> element wrapping the last line of selected code
var
tdFocus
=
selection
.
focusNode
;
while
(
tdFocus
.
nodeName
!==
'TD'
)
{
tdFocus
=
tdFocus
.
parentNode
;
}
// extract line numbers
var
firstLineNumber
=
parseInt
(
tdAnchor
.
dataset
.
lineNumber
);
var
lastLineNumber
=
parseInt
(
tdFocus
.
dataset
.
lineNumber
);
// multi-lines copied case
if
(
firstLineNumber
!=
lastLineNumber
)
{
var
firstLineText
=
tdAnchor
.
textContent
;
var
lastLineText
=
tdFocus
.
textContent
;
// if the selection was made backward, swap values
if
(
firstLineNumber
>
lastLineNumber
)
{
var
tmp
=
firstLineNumber
;
firstLineNumber
=
lastLineNumber
;
lastLineNumber
=
tmp
;
tmp
=
firstLineText
;
firstLineText
=
lastLineText
;
lastLineText
=
tmp
;
}
// discard not copied characters in first line
while
(
selectionText
.
indexOf
(
firstLineText
)
!==
0
)
{
firstLineText
=
firstLineText
.
slice
(
1
);
}
// discard not copied characters in last line
while
(
selectionText
.
lastIndexOf
(
lastLineText
)
===
-
1
)
{
lastLineText
=
lastLineText
.
slice
(
0
,
-
1
);
}
// reconstruct and return the real copied text
var
selectedText
=
firstLineText
;
var
hljsLnTable
=
getHljsLnTable
(
tdAnchor
);
for
(
var
i
=
firstLineNumber
+
1
;
i
<
lastLineNumber
;
++
i
)
{
var
codeLineSel
=
format
(
'.{0}[{1}="{2}"]'
,
[
CODE_BLOCK_NAME
,
DATA_ATTR_NAME
,
i
]);
var
codeLineElt
=
hljsLnTable
.
querySelector
(
codeLineSel
);
selectedText
+=
'
\
n'
+
codeLineElt
.
textContent
;
}
selectedText
+=
'
\
n'
+
lastLineText
;
return
selectedText
;
// single copied line case
}
else
{
return
selectionText
;
}
}
// ensure consistent code copy/paste behavior across all browsers
// (see https://github.com/wcoder/highlightjs-line-numbers.js/issues/51)
document
.
addEventListener
(
'copy'
,
function
(
e
)
{
// get current selection
var
selection
=
window
.
getSelection
();
// override behavior when one wants to copy line of codes
if
(
isHljsLnCodeDescendant
(
selection
.
anchorNode
))
{
var
selectionText
;
// workaround an issue with Microsoft Edge as copied line breaks
// are removed otherwise from the selection string
if
(
window
.
navigator
.
userAgent
.
indexOf
(
"Edge"
)
!==
-
1
)
{
selectionText
=
edgeGetSelectedCodeLines
(
selection
);
}
else
{
// other browsers can directly use the selection string
selectionText
=
selection
.
toString
();
}
e
.
clipboardData
.
setData
(
'text/plain'
,
selectionText
);
e
.
preventDefault
();
}
});
function
addStyles
()
{
var
css
=
d
.
createElement
(
'style'
);
css
.
type
=
'text/css'
;
css
.
innerHTML
=
format
(
'.{0}{border-collapse:collapse}'
+
'.{0} td{padding:0}'
+
'.{1}:before{content:attr({2})}'
,
[
TABLE_NAME
,
NUMBER_LINE_NAME
,
DATA_ATTR_NAME
]);
d
.
getElementsByTagName
(
'head'
)[
0
].
appendChild
(
css
);
}
function
initLineNumbersOnLoad
(
options
)
{
if
(
d
.
readyState
===
'interactive'
||
d
.
readyState
===
'complete'
)
{
documentReady
(
options
);
}
else
{
w
.
addEventListener
(
'DOMContentLoaded'
,
function
()
{
documentReady
(
options
);
});
}
}
function
documentReady
(
options
)
{
try
{
var
blocks
=
d
.
querySelectorAll
(
'code.hljs,code.nohighlight'
);
for
(
var
i
in
blocks
)
{
if
(
blocks
.
hasOwnProperty
(
i
))
{
lineNumbersBlock
(
blocks
[
i
],
options
);
}
}
}
catch
(
e
)
{
w
.
console
.
error
(
'LineNumbers error: '
,
e
);
}
}
function
lineNumbersBlock
(
element
,
options
)
{
if
(
typeof
element
!==
'object'
)
return
;
async
(
function
()
{
element
.
innerHTML
=
lineNumbersInternal
(
element
,
options
);
});
}
function
lineNumbersValue
(
value
,
options
)
{
if
(
typeof
value
!==
'string'
)
return
;
var
element
=
document
.
createElement
(
'code'
)
element
.
innerHTML
=
value
return
lineNumbersInternal
(
element
,
options
);
}
function
lineNumbersInternal
(
element
,
options
)
{
// define options or set default
options
=
options
||
{
singleLine
:
false
};
// convert options
var
firstLineIndex
=
!!
options
.
singleLine
?
0
:
1
;
duplicateMultilineNodes
(
element
);
return
addLineNumbersBlockFor
(
element
.
innerHTML
,
firstLineIndex
);
}
function
addLineNumbersBlockFor
(
inputHtml
,
firstLineIndex
)
{
var
lines
=
getLines
(
inputHtml
);
// if last line contains only carriage return remove it
if
(
lines
[
lines
.
length
-
1
].
trim
()
===
''
)
{
lines
.
pop
();
}
if
(
lines
.
length
>
firstLineIndex
)
{
var
html
=
''
;
for
(
var
i
=
0
,
l
=
lines
.
length
;
i
<
l
;
i
++
)
{
html
+=
format
(
'<tr>'
+
'<td class="{0} {1}" {3}="{5}">'
+
'<div class="{2}" {3}="{5}"></div>'
+
'</td>'
+
'<td class="{0} {4}" {3}="{5}">'
+
'{6}'
+
'</td>'
+
'</tr>'
,
[
LINE_NAME
,
NUMBERS_BLOCK_NAME
,
NUMBER_LINE_NAME
,
DATA_ATTR_NAME
,
CODE_BLOCK_NAME
,
i
+
1
,
lines
[
i
].
length
>
0
?
lines
[
i
]
:
' '
]);
}
return
format
(
'<table class="{0}">{1}</table>'
,
[
TABLE_NAME
,
html
]);
}
return
inputHtml
;
}
/**
* Recursive method for fix multi-line elements implementation in highlight.js
* Doing deep passage on child nodes.
* @param {HTMLElement} element
*/
function
duplicateMultilineNodes
(
element
)
{
var
nodes
=
element
.
childNodes
;
for
(
var
node
in
nodes
)
{
if
(
nodes
.
hasOwnProperty
(
node
))
{
var
child
=
nodes
[
node
];
if
(
getLinesCount
(
child
.
textContent
)
>
0
)
{
if
(
child
.
childNodes
.
length
>
0
)
{
duplicateMultilineNodes
(
child
);
}
else
{
duplicateMultilineNode
(
child
.
parentNode
);
}
}
}
}
}
/**
* Method for fix multi-line elements implementation in highlight.js
* @param {HTMLElement} element
*/
function
duplicateMultilineNode
(
element
)
{
var
className
=
element
.
className
;
if
(
!
/hljs-/
.
test
(
className
))
return
;
var
lines
=
getLines
(
element
.
innerHTML
);
for
(
var
i
=
0
,
result
=
''
;
i
<
lines
.
length
;
i
++
)
{
var
lineText
=
lines
[
i
].
length
>
0
?
lines
[
i
]
:
' '
;
result
+=
format
(
'<span class="{0}">{1}</span>
\
n'
,
[
className
,
lineText
]);
}
element
.
innerHTML
=
result
.
trim
();
}
function
getLines
(
text
)
{
if
(
text
.
length
===
0
)
return
[];
return
text
.
split
(
BREAK_LINE_REGEXP
);
}
function
getLinesCount
(
text
)
{
return
(
text
.
trim
().
match
(
BREAK_LINE_REGEXP
)
||
[]).
length
;
}
function
async
(
func
)
{
w
.
setTimeout
(
func
,
0
);
}
/**
* {@link https://wcoder.github.io/notes/string-format-for-string-formating-in-javascript}
* @param {string} format
* @param {array} args
*/
function
format
(
format
,
args
)
{
return
format
.
replace
(
/
\{(\d
+
)\}
/g
,
function
(
m
,
n
){
return
args
[
n
]
?
args
[
n
]
:
m
;
});
}
};
nuxt.config.js
View file @
4ace35b9
...
...
@@ -19,7 +19,7 @@ module.exports = {
],
link
:
[
{
rel
:
'icon'
,
type
:
'image/x-icon'
,
href
:
'/favicon.ico'
}
]
]
,
},
/*
** Customize the progress-bar color
...
...
@@ -46,6 +46,7 @@ module.exports = {
plugins
:
[
'~/plugins/axios'
,
{
src
:
'~/plugins/baidu.js'
,
ssr
:
false
},
{
src
:
'~/plugins/highlight.js'
,
ssr
:
false
},
{
src
:
'~/plugins/websocket.js'
,
ssr
:
false
},
{
src
:
'~/plugins/notifications.js'
,
ssr
:
false
},
{
src
:
'~/plugins/mavonEditor.js'
,
ssr
:
false
},
...
...
package-lock.json
View file @
4ace35b9
...
...
@@ -7456,6 +7456,14 @@
"type-check"
:
"~0.3.2"
}
},
"linkify-it"
:
{
"version"
:
"2.2.0"
,
"resolved"
:
"https://registry.npm.taobao.org/linkify-it/download/linkify-it-2.2.0.tgz"
,
"integrity"
:
"sha1-47VGl+eL+RXHCjis14/QngBYsc8="
,
"requires"
:
{
"uc.micro"
:
"^1.0.1"
}
},
"load-json-file"
:
{
"version"
:
"4.0.0"
,
"resolved"
:
"https://registry.npm.taobao.org/load-json-file/download/load-json-file-4.0.0.tgz"
,
...
...
@@ -7656,6 +7664,88 @@
"object-visit"
:
"^1.0.0"
}
},
"markdown-it"
:
{
"version"
:
"10.0.0"
,
"resolved"
:
"https://registry.npm.taobao.org/markdown-it/download/markdown-it-10.0.0.tgz"
,
"integrity"
:
"sha1-q/xk8UGxci1mNAIETkOSfx9QqNw="
,
"requires"
:
{
"argparse"
:
"^1.0.7"
,
"entities"
:
"~2.0.0"
,
"linkify-it"
:
"^2.0.0"
,
"mdurl"
:
"^1.0.1"
,
"uc.micro"
:
"^1.0.5"
}
},
"markdown-it-abbr"
:
{
"version"
:
"1.0.4"
,
"resolved"
:
"https://registry.npm.taobao.org/markdown-it-abbr/download/markdown-it-abbr-1.0.4.tgz"
,
"integrity"
:
"sha1-1mtTZFIcuz3Yqlna37ovtoZcj9g="
},
"markdown-it-container"
:
{
"version"
:
"2.0.0"
,
"resolved"
:
"https://registry.npm.taobao.org/markdown-it-container/download/markdown-it-container-2.0.0.tgz"
,
"integrity"
:
"sha1-ABm0P9Au7+zi8ZYKKJX7qBpARpU="
},
"markdown-it-deflist"
:
{
"version"
:
"2.0.3"
,
"resolved"
:
"https://registry.npm.taobao.org/markdown-it-deflist/download/markdown-it-deflist-2.0.3.tgz"
,
"integrity"
:
"sha1-VyfbBBhNPLK8buSpZB46EJHV/W8="
},
"markdown-it-emoji"
:
{
"version"
:
"1.4.0"
,
"resolved"
:
"https://registry.npm.taobao.org/markdown-it-emoji/download/markdown-it-emoji-1.4.0.tgz"
,
"integrity"
:
"sha1-m+4OmpkKljupbfaYDE/dsF37Tcw="
},
"markdown-it-footnote"
:
{
"version"
:
"3.0.2"
,
"resolved"
:
"https://registry.npm.taobao.org/markdown-it-footnote/download/markdown-it-footnote-3.0.2.tgz"
,
"integrity"
:
"sha1-FXXuegk2SNTglqozOGsFjZKsi8E="
},
"markdown-it-highlightjs-external"
:
{
"version"
:
"1.0.1"
,
"resolved"
:
"https://registry.npm.taobao.org/markdown-it-highlightjs-external/download/markdown-it-highlightjs-external-1.0.1.tgz"
,
"integrity"
:
"sha1-hZX9SwIH7EKckzQfmWY3+jHaLVM="
},
"markdown-it-images-preview"
:
{
"version"
:
"1.0.1"
,
"resolved"
:
"https://registry.npm.taobao.org/markdown-it-images-preview/download/markdown-it-images-preview-1.0.1.tgz"
,
"integrity"
:
"sha1-F9brhJHMzSND1ORBmhq+nKQ8C7s="
},
"markdown-it-ins"
:
{
"version"
:
"3.0.0"
,
"resolved"
:
"https://registry.npm.taobao.org/markdown-it-ins/download/markdown-it-ins-3.0.0.tgz"
,
"integrity"
:
"sha1-sbVoJMeNxm5SsPyXUxsxfNeNedI="
},
"markdown-it-katex-external"
:
{
"version"
:
"1.0.0"
,
"resolved"
:
"https://registry.npm.taobao.org/markdown-it-katex-external/download/markdown-it-katex-external-1.0.0.tgz"
,
"integrity"
:
"sha1-eNF4bZTfhlDgvqef+8Cx8D/XxgY="
},
"markdown-it-mark"
:
{
"version"
:
"3.0.0"
,
"resolved"
:
"https://registry.npm.taobao.org/markdown-it-mark/download/markdown-it-mark-3.0.0.tgz"
,
"integrity"
:
"sha1-J8PjnvPMMQst3lN1CCyfqRKYPNo="
},
"markdown-it-sub"
:
{
"version"
:
"1.0.0"
,
"resolved"
:
"https://registry.npm.taobao.org/markdown-it-sub/download/markdown-it-sub-1.0.0.tgz"
,
"integrity"
:
"sha1-N1/WAm6ufdywEkl/ZBEZXqHjr+g="
},
"markdown-it-sup"
:
{
"version"
:
"1.0.0"
,
"resolved"
:
"https://registry.npm.taobao.org/markdown-it-sup/download/markdown-it-sup-1.0.0.tgz"
,
"integrity"
:
"sha1-y5yf+RpSVawI8/09YyhuFd8KH8M="
},
"markdown-it-task-lists"
:
{
"version"
:
"2.1.1"
,
"resolved"
:
"https://registry.npm.taobao.org/markdown-it-task-lists/download/markdown-it-task-lists-2.1.1.tgz"
,
"integrity"
:
"sha1-9o9NKsK61aLDc7qTCBoaaEhBcIg="
},
"markdown-it-toc"
:
{
"version"
:
"1.1.0"
,
"resolved"
:
"https://registry.npm.taobao.org/markdown-it-toc/download/markdown-it-toc-1.1.0.tgz"
,
"integrity"
:
"sha1-bRiYWOMrPetP860nE/qSdDnJV+A="
},
"mavon-editor"
:
{
"version"
:
"2.7.7"
,
"resolved"
:
"https://registry.npm.taobao.org/mavon-editor/download/mavon-editor-2.7.7.tgz"
,
...
...
@@ -7680,6 +7770,11 @@
"resolved"
:
"https://registry.npm.taobao.org/mdn-data/download/mdn-data-2.0.4.tgz?cache=0&sync_timestamp=1573816302294&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fmdn-data%2Fdownload%2Fmdn-data-2.0.4.tgz"
,
"integrity"
:
"sha1-aZs8OKxvHXKAkaZGULZdOIUC/Vs="
},
"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.npm.taobao.org/media-typer/download/media-typer-0.3.0.tgz"
,
...
...
@@ -10042,6 +10137,15 @@
}
}
},
"raw-loader"
:
{
"version"
:
"4.0.0"
,
"resolved"
:
"https://registry.npm.taobao.org/raw-loader/download/raw-loader-4.0.0.tgz?cache=0&sync_timestamp=1574695176795&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fraw-loader%2Fdownload%2Fraw-loader-4.0.0.tgz"
,
"integrity"
:
"sha1-1jnED7nXK1x/irwfst2yWynT1UA="
,
"requires"
:
{
"loader-utils"
:
"^1.2.3"
,
"schema-utils"
:
"^2.5.0"
}
},
"rc"
:
{
"version"
:
"1.2.8"
,
"resolved"
:
"http://registry.npm.taobao.org/rc/download/rc-1.2.8.tgz"
,
...
...
@@ -11972,6 +12076,11 @@
"resolved"
:
"https://registry.npm.taobao.org/ua-parser-js/download/ua-parser-js-0.7.20.tgz"
,
"integrity"
:
"sha1-dScXi4L2pioPJD0flP0w4+PCEJg="
},
"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.7.0"
,
"resolved"
:
"https://registry.npm.taobao.org/uglify-js/download/uglify-js-3.7.0.tgz?cache=0&sync_timestamp=1574701612100&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fuglify-js%2Fdownload%2Fuglify-js-3.7.0.tgz"
,
...
...
pages/answer/detail/_id.vue
View file @
4ace35b9
...
...
@@ -212,9 +212,14 @@
highlightCode
()
{
if
(
process
.
browser
){
this
.
$hljs
.
initHighlightingOnLoad
();
this
.
$hljs
.
initLineNumbersOnLoad
({
singleLine
:
true
});
const
preEl
=
document
.
querySelectorAll
(
'pre'
);
preEl
.
forEach
((
el
)
=>
{
hljs
.
highlightBlock
(
el
)
this
.
$hljs
.
highlightBlock
(
el
)
this
.
$hljs
.
lineNumbersBlock
(
el
);
})
}
...
...
pages/blog/detail/_id.vue
View file @
4ace35b9
...
...
@@ -138,8 +138,6 @@
import
{
dateConvert
}
from
"../../../action/utils/dataConvert"
;
import
{
globalBus
}
from
'../../../components/common/globalBus'
import
hljs
from
'highlight.js'
export
default
{
async
asyncData
({
$axios
,
params
})
{
let
articleDetail
=
await
$axios
.
$get
(
config
.
api
.
get
.
Blog
.
detail
+
params
.
id
);
...
...
@@ -200,6 +198,7 @@
mounted
(){
this
.
highlightCode
();
},
...
...
@@ -221,9 +220,14 @@
highlightCode
()
{
if
(
process
.
browser
){
this
.
$hljs
.
initHighlightingOnLoad
();
this
.
$hljs
.
initLineNumbersOnLoad
({
singleLine
:
true
});
const
preEl
=
document
.
querySelectorAll
(
'pre'
);
preEl
.
forEach
((
el
)
=>
{
hljs
.
highlightBlock
(
el
)
this
.
$hljs
.
highlightBlock
(
el
)
this
.
$hljs
.
lineNumbersBlock
(
el
);
})
}
...
...
@@ -342,6 +346,10 @@
@extend
%flex-row-spb;
align-items
:
flex-start
;
@extend
%detail-container;
}
</
style
>
<
style
lang=
"css"
>
@import
"assets/github-markdown.min.css"
;
</
style
>
pages/dynamic/index.vue
View file @
4ace35b9
...
...
@@ -10,7 +10,6 @@
<release-card
@
listenReleaseState=
"restartPagination()"
></release-card>
<social-card
@
listenSocialCardState=
"restartPagination()"
v-for=
"(val,index) in postList"
:key=
"val.postId"
:info=
"val"
></social-card>
<pagination
ref=
"pagination"
:paginationState=
"paginationState"
:type=
"2"
key=
"container5"
style=
"margin:20px auto;"
:pages=
"pages"
v-on:listenPageChange=
"changePage"
></pagination>
</div>
<div
class=
"dynamic-container__right"
>
<hot-topic-list
></hot-topic-list>
...
...
@@ -93,7 +92,6 @@
},
created
()
{
this
.
dataGetHotTopic
();
this
.
dataGetActiveUser
();
if
(
!
this
.
$store
.
state
.
userProfile
.
userId
){
...
...
@@ -332,16 +330,6 @@
})
},
dataGetHotTopic
(){
this
.
$axios
.
$get
(
config
.
api
.
get
.
Topic
.
hotSearch
,{
params
:{
page
:
1
,
size
:
10
}
}).
then
((
response
)
=>
{
this
.
topicList
=
response
.
data
.
dataList
;
})
},
changePage
(
currentPage
){
//返回页数 请求新的数据
...
...
pages/news/detail/_id.vue
View file @
4ace35b9
...
...
@@ -177,9 +177,14 @@
},
highlightCode
()
{
if
(
process
.
browser
){
this
.
$hljs
.
initHighlightingOnLoad
();
this
.
$hljs
.
initLineNumbersOnLoad
({
singleLine
:
true
});
const
preEl
=
document
.
querySelectorAll
(
'pre'
);
preEl
.
forEach
((
el
)
=>
{
hljs
.
highlightBlock
(
el
)
this
.
$hljs
.
highlightBlock
(
el
)
this
.
$hljs
.
lineNumbersBlock
(
el
);
})
}
...
...
pages/project/detail/_id.vue
View file @
4ace35b9
...
...
@@ -212,9 +212,14 @@
},
highlightCode
()
{
if
(
process
.
browser
){
this
.
$hljs
.
initHighlightingOnLoad
();
this
.
$hljs
.
initLineNumbersOnLoad
({
singleLine
:
true
});
const
preEl
=
document
.
querySelectorAll
(
'pre'
);
preEl
.
forEach
((
el
)
=>
{
hljs
.
highlightBlock
(
el
)
this
.
$hljs
.
highlightBlock
(
el
)
this
.
$hljs
.
lineNumbersBlock
(
el
);
})
}
...
...
plugins/highlight.js
0 → 100644
View file @
4ace35b9
import
hljs
from
'highlight.js'
import
Vue
from
'vue'
;
Vue
.
prototype
.
$hljs
=
hljs
import
lineNumber
from
'../components/pc/highlightjs-line-numbers.js'
lineNumber
(
window
,
document
,
Vue
.
prototype
);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment