码语库记的功能介绍,和以及实现方法
码语库记的仓库地址为:码语库记
功能介绍
全部功能预览
- 搜索所写过的所有笔记,便签,函数功能
- 笔记
- 便签(随记)
- 函数笔记
- 设置
搜索
实现方式:
遍历所有文章,便签,查找所匹配的项目。
这个比较简单,就不多说了
笔记
提供所有MarkDown
功能,使用vditor
作为markdown编辑器
支持及时渲染,类似Typora
支持笔记分类
支持常规操作,删除,重命名,新建,导出
便签
不使用MarkDown
编辑器,因为便签讲究快速,便捷
所以只支持输入文字,加粗,斜体,粘贴图片
可以使用快捷键快速呼出便签,快速录入。
便签名默认为第一行输入的内容
支持常规操作,删除,重命名,新建,不支持导出
函数笔记
规划中…
设置
配置文件将在第一次打开软件自动在C:\User\YourUserName\AppData\Roaming\CodeSpeak-LibraryNotes
下创建一个名为scln-config.json
文件
具体内容为
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| { "author": "xiaowumin & SanWei", "title": "CodeSpeak-LibraryNotes", "description": "CodeSpeak-LibraryNotes", "warehouse": { "main": "https://gitee.com/xiaowumin-mark/CodeSpeak-LibraryNotes", "releases": "https://gitee.com/xiaowumin-mark/CodeSpeak-LibraryNotes/releases", "all_releases": "https://gitee.com/api/v5/repos/xiaowumin-mark/CodeSpeak-LibraryNotes/releases?page=1&per_page=100", "latest_release": "https://gitee.com/api/v5/repos/xiaowumin-mark/CodeSpeak-LibraryNotes/releases/latest" }, "note_path": "C:\\Users\\YourUserName\\AppData\\Local\\CodeSpeak-LibraryNotes", "config_path": "C:\\Users\\YourUserName\\AppData\\Roaming\\CodeSpeak-LibraryNotes\\csln-config.json", "setting": { "auto_update": true, "theme": "auto", "color_theme": "auto" } }
|
功能难点(我认为)
主题切换效果
起因:bilibili客户端的主题切换效果很炫酷,但是一直没有思路。
偶然有一天想起可以用animate
动画的clip-path
属性画圆
但是因为主题要变动所以画圆时整个body元素是被切割的
偶然有一天,知道了startViewTransition
这个api,于是一切就变得顺利起来了
只要在document.startViewTransition
里面运行改变样式的代码,这样就可以让主题变化变得不那么生硬
但是我想要的是画圆效果,就必须要将动画加上去
于是去看文档https://developer.mozilla.org/zh-CN/docs/Web/API/Document/startViewTransition
最后封装为一个函数,要用到勾股定理哦~
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| function changeTheme(type, if_animate = true) { let html = document.documentElement const transition = document.startViewTransition(async () => {
let o_type = getThemeType() if (type == o_type) { return } else if (type == "dark") { if (!document.documentElement.classList.contains('mdui-theme-dark')) { document.documentElement.classList.add('mdui-theme-dark') document.querySelector(".nav").style.borderRight = "1px solid rgb(45 45 45)" } } else if (type == "light") { if (document.documentElement.classList.contains('mdui-theme-dark')) { document.documentElement.classList.remove('mdui-theme-dark') document.querySelector(".nav").style.borderRight = "1px solid rgb(230 230 230)" } }
}); if (if_animate) {
const x = event.pageX || (event.clientX + window.scrollX); const y = event.pageY || (event.clientY + window.scrollY); const radius = Math.sqrt(Math.max(x, (window.innerWidth - x)) ** 2 + Math.max(y, (window.innerHeight - y)) ** 2) let clipPath = [ `circle(0 at ${x}px ${y}px)`, `circle(${radius}px at ${x}px ${y}px)`, ] let is_dark = html.classList.contains('mdui-theme-dark') transition.ready.then(() => { document.documentElement.animate( { clipPath: clipPath, }, { duration: 300, pseudoElement: '::view-transition-new(root)', } ) }) }
}
|
这是最终的效果图 ↓

这个东西也是花了我一天……