-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: markdown load slow #307
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,14 +3,18 @@ | |
</template> | ||
|
||
<script> | ||
import 'https://goplus-builder.qiniu.io/widgets/loader.js'; | ||
import Plyr from 'plyr'; | ||
import 'plyr/dist/plyr.css' | ||
import 'https://goplus-builder.qiniu.io/widgets/loader.js' | ||
import 'plyr/dist/plyr.css'; | ||
|
||
import 'https://builder.goplus.org/widgets/loader.js' | ||
import 'https://builder.goplus.org/widgets/loader.js'; | ||
|
||
var cherrInstance = null | ||
|
||
// this is markdown change callback | ||
// TODO: In order to change the callback function by article_yap.html, this is the worst way to do this. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: |
||
// It should use the vue event to handle it, but the current attempt does not work. | ||
window.mdChange = ()=>{ | ||
} | ||
var vtt_src = "" | ||
|
||
// var origin_vtt_src = "" | ||
|
@@ -92,6 +96,12 @@ function initCherryMD(value, config) { | |
cherrInstance = new Cherry({ | ||
id: 'markdown-container', | ||
value: defaultValue, | ||
callback: { | ||
// In order to change the callback function, here is the reference relationship | ||
afterChange: ()=>{ | ||
window.mdChange() | ||
} | ||
}, | ||
customSyntax: { | ||
importHook: { | ||
syntaxClass: CustomHookA, // 将自定义语法对象挂载到 importHook.syntaxClass上 | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
通过
window.xxx
作为事件 handler 不是常规的做法,也有明显的问题这里
MarkdownViewer
是个 vue component,可以通过 vue component 的事件来做,比如把getArticleToc
添加到上边methods
里,然后在模板中绑定事件:对应地在
MarkdownViewer
中去 emitchange
事件即可;详见 https://vuejs.org/guide/components/events.html#component-events
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我最开始是这样去做的,它无法生效
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
那先保留 window.mdChange 的做法,然后在这里注释记个 TODO 吧
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done