Skip to content

Commit

Permalink
feat: Add sw support (#141)
Browse files Browse the repository at this point in the history
* feat: Add sw support

Signed-off-by: unknowIfGuestInDream <liang.tang.cx@gmail.com>

* feat: Add sw support

Signed-off-by: unknowIfGuestInDream <liang.tang.cx@gmail.com>

* feat: Add sw support

Signed-off-by: unknowIfGuestInDream <liang.tang.cx@gmail.com>

* feat: Add sw support

Signed-off-by: unknowIfGuestInDream <liang.tang.cx@gmail.com>

* feat: Add sw support

Signed-off-by: unknowIfGuestInDream <liang.tang.cx@gmail.com>

* feat: Add sw support

Signed-off-by: unknowIfGuestInDream <liang.tang.cx@gmail.com>

* feat: Add sw support

Signed-off-by: unknowIfGuestInDream <liang.tang.cx@gmail.com>

* feat: Add sw support

Signed-off-by: unknowIfGuestInDream <liang.tang.cx@gmail.com>

* feat: Add sw support

Signed-off-by: unknowIfGuestInDream <liang.tang.cx@gmail.com>

* feat: Add sw support

Signed-off-by: unknowIfGuestInDream <liang.tang.cx@gmail.com>

* feat: Add sw support

Signed-off-by: unknowIfGuestInDream <liang.tang.cx@gmail.com>

* feat: Add sw support

Signed-off-by: unknowIfGuestInDream <liang.tang.cx@gmail.com>

* feat: Add sw support

Signed-off-by: unknowIfGuestInDream <liang.tang.cx@gmail.com>

* feat: Add sw support

Signed-off-by: unknowIfGuestInDream <liang.tang.cx@gmail.com>

* feat: Add sw support

Signed-off-by: unknowIfGuestInDream <liang.tang.cx@gmail.com>

* feat: Add sw support

Signed-off-by: unknowIfGuestInDream <liang.tang.cx@gmail.com>

* feat: Add sw support

Signed-off-by: unknowIfGuestInDream <liang.tang.cx@gmail.com>

* feat: Add sw support

Signed-off-by: unknowIfGuestInDream <liang.tang.cx@gmail.com>

* feat: Add sw support

Signed-off-by: unknowIfGuestInDream <liang.tang.cx@gmail.com>

* feat: Add sw support

Signed-off-by: unknowIfGuestInDream <liang.tang.cx@gmail.com>

---------

Signed-off-by: unknowIfGuestInDream <liang.tang.cx@gmail.com>
  • Loading branch information
unknowIfGuestInDream authored Dec 22, 2024
1 parent 97cf1ef commit 7a3e010
Show file tree
Hide file tree
Showing 9 changed files with 267 additions and 41 deletions.
52 changes: 50 additions & 2 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@
<!--</nav>-->
<!-- 定义加载时候的动作 -->
<div id="app"></div>
<script>
//离线渲染
if (typeof navigator.serviceWorker !== 'undefined') {
navigator.serviceWorker.register('sw.js')
}
</script>
<script>
// document.oncontextmenu = function () {
// Toast('右键菜单已禁用', 1000);
Expand Down Expand Up @@ -303,7 +309,7 @@
],
markdown: {
renderer: {
code: function (code, lang) {
code: function (code, lang, base = null) {
if (lang === "mermaid") {
return (
'<div class="mermaid">' + code + "</div>"
Expand All @@ -316,10 +322,48 @@
return `<div class='drawio-code'>${code}</div>`
}
}
return this.origin.code.apply(this, arguments);
// pdf
var pdf_renderer = function (code, lang, verify) {
function unique_id_generator() {
function rand_gen() {
return Math.floor((Math.random() + 1) * 65536).toString(16).substring(1);
}

return rand_gen() + rand_gen() + '-' + rand_gen() + '-' + rand_gen() + '-' + rand_gen() + '-' + rand_gen() + rand_gen() + rand_gen();
}

if (lang && !(lang.localeCompare('pdf', 'en', {sensitivity: 'base'}) || lang.localeCompare('pdf', 'zh', {sensitivity: 'base'}))) {
if (verify) {
return true;
} else {
var divId = "markdown_code_pdf_container_" + unique_id_generator().toString();
var container_list = new Array();
if (localStorage.getItem('pdf_container_list')) {
container_list = JSON.parse(localStorage.getItem('pdf_container_list'));
}
container_list.push({"pdf_location": code, "div_id": divId});
localStorage.setItem('pdf_container_list', JSON.stringify(container_list));
return (
'<div style="margin-top:' + PDF_MARGIN_TOP + '; margin-bottom:' + PDF_MARGIN_BOTTOM + ';" id="' + divId + '">'
+ '<a href="' + code + '"> Link </a> to ' + code +
'</div>'
);
}
}
return false;
}
if (pdf_renderer(code, lang, true)) {
return pdf_renderer(code, lang, false);
}

return (base ? base : this.origin.code.apply(this, arguments));
}
}
},
hideCode: {
scroll: false, // Enable scrolling
height: 300 // Max height
}
// ads: [
// {
// img: 'https://dn-lego-static.qbox.me/cps/1638355965-480x300.jpg',
Expand Down Expand Up @@ -439,6 +483,10 @@
<!-- drawio支持 -->
<script src="lib/drawio-viewer.min.js" defer></script>
<script src="lib/drawio.js" defer></script>
<!-- 代码过长时隐藏超出部分 -->
<script src="lib/docsify-hide-code.min.js"></script>
<!-- bilibili -->
<script src="lib/docsify-bilibili.min.js"></script>
<!-- 百度统计 -->
<script src="lib/baiduTj.js" async></script>
</body>
Expand Down
4 changes: 2 additions & 2 deletions docs/japanese/junior/25.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
**学习简报**

```pdf
../../static/japanese/25/新维学习简报L25.pdf
../../static/japanese/25/xinweijianbaoL25.pdf
```

**单词**
Expand All @@ -17,7 +17,7 @@
**第25课练习**

```pdf
../../static/japanese/25/第25课练习.pdf
../../static/japanese/25/lianxi25.pdf
```

14215 12142
Expand Down
1 change: 1 addition & 0 deletions docs/lib/docsify-bilibili.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions docs/lib/docsify-hide-code.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7a3e010

Please sign in to comment.