Skip to content

Commit 08f95ed

Browse files
authored
fix: cannot get recent comments (#365)
* 修复 无法获取最新评论 * 改进 允许自定义 Prism 加载地址,默认为从 jsDelivr CDN 加载
1 parent 71666eb commit 08f95ed

File tree

9 files changed

+19
-15
lines changed

9 files changed

+19
-15
lines changed

docs/.vuepress/theme/layouts/Layout.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
<!-- Twikoo -->
1515
<div id="twikoo"></div>
16-
<script src="https://cdn.jsdelivr.net/npm/twikoo@1.5.7/dist/twikoo.all.min.js" ref="twikooJs"></script>
16+
<script src="https://cdn.jsdelivr.net/npm/twikoo@1.5.8/dist/twikoo.all.min.js" ref="twikooJs"></script>
1717
</div>
1818
</template>
1919
</ParentLayout>

docs/quick-start.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ exports.main = require('twikoo-func').main
4444
8. 创建完成后,点击“twikoo"进入云函数详情页,进入“函数代码”标签,点击“文件 - 新建文件”,输入 `package.json`,回车
4545
9. 复制以下代码、粘贴到代码框中,点击“保存并安装依赖”
4646
``` json
47-
{ "dependencies": { "twikoo-func": "1.5.7" } }
47+
{ "dependencies": { "twikoo-func": "1.5.8" } }
4848
```
4949

5050
### 命令行部署
@@ -175,7 +175,7 @@ twikoo:
175175

176176
``` html
177177
<div id="tcomment"></div>
178-
<script src="https://cdn.jsdelivr.net/npm/twikoo@1.5.7/dist/twikoo.all.min.js"></script>
178+
<script src="https://cdn.jsdelivr.net/npm/twikoo@1.5.8/dist/twikoo.all.min.js"></script>
179179
<script>
180180
twikoo.init({
181181
envId: '您的环境id', // 腾讯云环境填 envId;Vercel 环境填地址(https://xxx.vercel.app)
@@ -193,7 +193,7 @@ twikoo.init({
193193

194194
请参考爆米兔前端静态资源库 [https://cdn.baomitu.com/twikoo](https://cdn.baomitu.com/twikoo)
195195

196-
引入的 CDN 链接替换为如下即可:`https://lib.baomitu.com/twikoo/1.5.7/twikoo.all.min.js`
196+
引入的 CDN 链接替换为如下即可:`https://lib.baomitu.com/twikoo/1.5.8/twikoo.all.min.js`
197197

198198
## 开启管理面板
199199

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "twikoo",
3-
"version": "1.5.7",
3+
"version": "1.5.8",
44
"description": "A simple comment system based on Tencent CloudBase (tcb).",
55
"keywords": ["twikoojs", "comment", "comment-system", "cloudbase", "vercel"],
66
"author": "imaegoo <hello@imaegoo.com> (https://github.com/imaegoo)",

src/function/twikoo/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "twikoo-func",
3-
"version": "1.5.7",
3+
"version": "1.5.8",
44
"description": "A simple comment system based on Tencent CloudBase (tcb).",
55
"author": "imaegoo <hello@imaegoo.com> (https://github.com/imaegoo)",
66
"license": "MIT",

src/js/utils/api.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ const isUrl = (s) => {
77
const call = async (tcb, event, data = {}) => {
88
const _tcb = tcb || (app ? app.$tcb : null)
99
const _envId = data.envId || app.$twikoo.envId
10+
const _funcName = data.funcName || app?.$twikoo.funcName || 'twikoo'
1011
if (_tcb) {
1112
try {
1213
return await _tcb.app.callFunction({
13-
name: app.$twikoo.funcName || 'twikoo',
14+
name: _funcName,
1415
data: { event, ...data }
1516
})
1617
} catch (e) {

src/js/utils/highlight.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,30 @@
1+
import { app } from '../../view'
2+
13
const PRISM_CDN = 'https://cdn.jsdelivr.net/npm/prismjs@1.23.0'
24
let Prism
35
let cssEl
46

57
const renderCode = (el, theme) => {
8+
const prismCdn = (app && app.$twikoo.prismCdn) ? app.$twikoo.prismCdn : PRISM_CDN
69
window.Prism = window.Prism || {}
710
window.Prism.manual = true
811
if (!Prism) {
912
Prism = require('prismjs')
1013
require('prismjs/plugins/autoloader/prism-autoloader')
11-
Prism.plugins.autoloader.languages_path = `${PRISM_CDN}/components/`
14+
Prism.plugins.autoloader.languages_path = `${prismCdn}/components/`
1215
}
13-
loadCss(theme)
16+
loadCss(theme, prismCdn)
1417
Prism.highlightAllUnder(el)
1518
}
1619

17-
const loadCss = (theme) => {
20+
const loadCss = (theme, prismCdn) => {
1821
const twikooEl = document.getElementById('twikoo')
1922
if ((cssEl && twikooEl.contains(cssEl)) || !theme || theme === 'none') return
2023
cssEl = document.createElement('link')
2124
if (theme === 'default') {
22-
cssEl.href = `${PRISM_CDN}/themes/prism.css`
25+
cssEl.href = `${prismCdn}/themes/prism.css`
2326
} else {
24-
cssEl.href = `${PRISM_CDN}/themes/prism-${theme}.css`
27+
cssEl.href = `${prismCdn}/themes/prism-${theme}.css`
2528
}
2629
cssEl.rel = 'stylesheet'
2730
cssEl.type = 'text/css'

src/vercel-min/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "dependencies": { "twikoo-vercel": "1.5.7" } }
1+
{ "dependencies": { "twikoo-vercel": "1.5.8" } }

src/vercel/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "twikoo-vercel",
3-
"version": "1.5.7",
3+
"version": "1.5.8",
44
"description": "A simple comment system based on Tencent CloudBase (tcb).",
55
"author": "imaegoo <hello@imaegoo.com> (https://github.com/imaegoo)",
66
"license": "MIT",

src/version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
const version = '1.5.7'
1+
const version = '1.5.8'
22

33
export { version }

0 commit comments

Comments
 (0)