Skip to content

Commit

Permalink
添加自定义组件
Browse files Browse the repository at this point in the history
  • Loading branch information
onresize committed Mar 31, 2024
1 parent cadc094 commit 6bb153d
Show file tree
Hide file tree
Showing 9 changed files with 151 additions and 87 deletions.
8 changes: 8 additions & 0 deletions docs/.vuepress/client.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import { defineClientConfig } from 'vuepress/client'
import Layout from './layouts/Layout.vue'
import Fps from './components/Fps.vue'

// @see: https://v2.vuepress.vuejs.org/zh/advanced/cookbook/usage-of-client-config.html
export default defineClientConfig({
enhance({ app, router, siteData }) {
// app.component('Fps', Fps)
},
setup() {},
layouts: {
// 继承默认主题 、自定义
Layout,
},
// 直接被放置在客户端 Vue 应用的根节点下、作为全局组件
rootComponents: [Fps],
})
23 changes: 23 additions & 0 deletions docs/.vuepress/components/Fps.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<script setup>
import { onMounted } from 'vue'
import { loopFps } from './utils/fps'
onMounted(loopFps)
</script>

<template>
<div id="fps"></div>
</template>

<style scoped lang='scss'>
#fps {
position: fixed;
right: 0;
bottom: 5px;
box-sizing: border-box;
padding: 0 6px;
width: 120px;
text-align: center;
user-select: none;
}
</style>
38 changes: 38 additions & 0 deletions docs/.vuepress/components/utils/fps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
export const loopFps = () => {
if (
null == window.localStorage.getItem('fpson') ||
'1' == window.localStorage.getItem('fpson')
) {
var rAF =
window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
function (e) {
window.setTimeout(e, 1e3 / 60)
},
frame = 0,
allFrameCount = 0,
lastTime = Date.now(),
lastFameTime = Date.now(),
loop = function () {
var e = Date.now(),
a = e - lastFameTime,
o = Math.round(1e3 / a)
if (
((lastFameTime = e), allFrameCount++, frame++, e > 1e3 + lastTime)
) {
if ((o = Math.round((1e3 * frame) / (e - lastTime))) <= 5)
var n = '<span style="color:#bd0000">卡成ppt🤢</span>'
else if (o <= 15) n = '<span style="color:red">电竞级帧率😖</span>'
else if (o <= 25) n = '<span style="color:orange">有点难受😨</span>'
else if (o < 35) n = '<span style="color:#9338e6">不太流畅🙄</span>'
else if (o <= 45) n = '<span style="color:#08b7e4">还不错哦😁</span>'
else n = '<span style="color:#39c5bb">十分流畅🤣</span>'
;(document.getElementById('fps').innerHTML = `FPS: ${o}🚀`),
(frame = 0),
(lastTime = e)
}
rAF(loop)
}
loop()
} else document.getElementById('fps').style = 'display:none!important'
}
120 changes: 37 additions & 83 deletions docs/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,34 @@ export default defineUserConfig({
lang: 'zh-CN',

title: 'onresize',
description: '',
description: '💻学习📝记录🔗分享',

head: [
// 站点图标
['link', { rel: 'icon', href: '/web-blogs/image.png' }],
// SEO
[
'meta',
{
name: 'keywords',
content: 'onresize的笔记, 博客',
},
],
// 百度统计
[
'script',
{},
`
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?9eb20a946f6ada6ace9bb2de590f8ed3";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
`,
],
],

markdown: {
code: {
Expand All @@ -32,40 +59,21 @@ export default defineUserConfig({
theme: defaultTheme({
logo: '/image.png',

lastUpdated: true,
lastUpdatedText: '上次更新',
contributorsText: '贡献者',
notFound: [
'这里什么都没有',
'我们怎么到这来了?',
'这是一个 404 页面',
'看起来我们进入了错误的链接',
],
backToHome: '返回首页',

// GitHub 仓库位置
repo: 'onresize/web-blogs',
docsBranch: 'main',
repoLabel: '📦️GitHub',

head: [
// 站点图标
['link', { rel: 'icon', href: '/image.png' }],
// SEO
[
'meta',
{
name: 'keywords',
content: 'onresize的笔记, 博客',
},
],
// 百度统计
[
'script',
{},
`
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?9eb20a946f6ada6ace9bb2de590f8ed3";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
`,
],
],

docsDir: 'docs',

navbar,
Expand All @@ -79,59 +87,5 @@ export default defineUserConfig({
// 排除首页
isSearchable: (page) => page.path !== '/',
}),
// RSS订阅源
[
'feed',
{
canonical_base: 'https://onresize.github.io',
count: 5000,
},
],
// https://github.com/ekoeryanto/vuepress-plugin-sitemap
[
'sitemap',
{
hostname: domain,
},
],
// Google 分析
[
'@vuepress/google-analytics',
{
ga: 'G-P1NFFNHRH2', // 补充自己的谷歌分析 ID,比如 UA-00000000-0
},
],
// https://github.com/lorisleiva/vuepress-plugin-seo
[
'seo',
{
siteTitle: (_, $site) => $site.title,
title: ($page) => $page.title,
description: ($page) =>
$page.frontmatter.description || $page.description,
author: (_, $site) => $site.themeConfig.author || author,
tags: ($page) => $page.frontmatter.tags || tags,
type: ($page) => 'article',
url: (_, $site, path) =>
($site.themeConfig.domain || domain || '') + path,
image: ($page, $site) =>
$page.frontmatter.image &&
(($site.themeConfig.domain &&
!$page.frontmatter.image.startsWith('http')) ||
'') + $page.frontmatter.image,
publishedAt: ($page) =>
$page.frontmatter.date && new Date($page.frontmatter.date),
modifiedAt: ($page) => $page.lastUpdated && new Date($page.lastUpdated),
},
],
// 点击特效
[
'cursor-effects',
{
size: 2, // size of the particle, default: 2
shape: 'star', // ['star' | 'circle'], // shape of the particle, default: 'star'
zIndex: 999999999, // z-index property of the canvas, default: 999999999
},
],
],
})
4 changes: 2 additions & 2 deletions docs/.vuepress/layouts/Layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import ParentLayout from '@vuepress/theme-default/layouts/Layout.vue'
<template>
<ParentLayout>
<template #page-bottom>
<div class="my-footer">
<!-- <div class="my-footer">
<a href="https://onresize.github.io/rss.xml" title="订阅" target="_blank" class="icon-rss"></a>
</div>
</div> -->
</template>
</ParentLayout>
</template>
Expand Down
Binary file removed docs/.vuepress/public/favicon.ico
Binary file not shown.
4 changes: 2 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ home: true
# title: Home
# heroText: BLOGS
heroImage: /image.png
tagline: 笔记-博客✨
tagline: 💻学习📝记录🔗分享
actions:
- text: 开始阅读 →
- text: 开始阅读 →
link: /技术总结/踩坑总结/一个项目安装不同版本的依赖包
features:
- title: 简洁至上⭐️
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
"@vuepress/theme-default": "2.0.0-rc.21",
"vue": "^3.4.21",
"vuepress": "2.0.0-rc.9",
"vuepress-plugin-cursor-effects": "^1.1.6",
"vuepress-plugin-feed": "^0.1.9",
"vuepress-plugin-seo": "^0.2.0",
"vuepress-plugin-sitemap": "^2.3.1"
}
}
39 changes: 39 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,27 @@
resolved "https://registry.npmmirror.com/@mdit-vue/types/-/types-2.0.0.tgz#466e13f63af80cb90ffdfbad82854cfa1c1e33e4"
integrity sha512-1BeEB+DbtmDMUAfvbNUj5Hso8cSl2sBVK2iTyOMAqhfDVLdh+/9+D0JmQHaCeUk/vuJoMhOwbweZvh55wHxm4w==

"@moefy-canvas/core@^0.5.2":
version "0.5.2"
resolved "https://registry.npmmirror.com/@moefy-canvas/core/-/core-0.5.2.tgz#fd3994025942e911a6dc94b85e564818ef202f7b"
integrity sha512-XkaVE91Tiwb35zFmI1DbrJpMh0xe54QbzQrc7ATwMos4C08dxBnwExwXEVS7oEct7owVDY1UWxtRRVE7smtzHw==

"@moefy-canvas/theme-popper@^0.5.2":
version "0.5.2"
resolved "https://registry.npmmirror.com/@moefy-canvas/theme-popper/-/theme-popper-0.5.2.tgz#717a29c6964362facf842affe47c0f016f0188d6"
integrity sha512-s6Gy27DKTLm2un5Od3fsAonnd7lN4pgyLXJ/omXisAZpVLbPg/Q5/QKpJLZvQ/08qNrn6X/GZjnWwvsHbJTBNw==
dependencies:
"@moefy-canvas/core" "^0.5.2"
"@moefy-canvas/utils" "^0.5.2"
ts-debounce "^4.0.0"

"@moefy-canvas/utils@^0.5.2":
version "0.5.2"
resolved "https://registry.npmmirror.com/@moefy-canvas/utils/-/utils-0.5.2.tgz#11c9ac56e9a81456678ccd10b2234754e2a20cfe"
integrity sha512-DnI8I/cTBFfn3xoXwyyLEtye4pMI6zJFMxU1qps731xgYTWmzBqJPkZZd/2gfNnH5NnLUOGG7Ui3sMkmJ0vg0w==
dependencies:
"@moefy-canvas/core" "^0.5.2"

"@nodelib/fs.scandir@2.1.5":
version "2.1.5"
resolved "https://registry.npmmirror.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5"
Expand Down Expand Up @@ -3927,6 +3948,7 @@ stdin-discarder@^0.2.1:
integrity sha512-UhDfHmA92YAlNnCfhmq0VeNL5bDbiZGg7sZ2IvPsXubGkiNa9EC+tUTsjBRsYUAz87btI6/1wf4XoVvQ3uRnmQ==

"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0:
name string-width-cjs
version "4.2.3"
resolved "https://registry.npmmirror.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
Expand Down Expand Up @@ -4077,6 +4099,11 @@ tr46@^1.0.1:
dependencies:
punycode "^2.1.0"

ts-debounce@^4.0.0:
version "4.0.0"
resolved "https://registry.npmmirror.com/ts-debounce/-/ts-debounce-4.0.0.tgz#33440ef64fab53793c3d546a8ca6ae539ec15841"
integrity sha512-+1iDGY6NmOGidq7i7xZGA4cm8DAa6fqdYcvO5Z6yBevH++Bdo9Qt/mN0TzHUgcCcKv1gmh9+W5dHqz8pMWbCbg==

tslib@^2.0.0, tslib@^2.0.3:
version "2.6.2"
resolved "https://registry.npmmirror.com/tslib/-/tslib-2.6.2.tgz#703ac29425e7b37cd6fd456e92404d46d1f3e4ae"
Expand Down Expand Up @@ -4203,6 +4230,13 @@ vue@^3.4.21:
"@vue/server-renderer" "3.4.21"
"@vue/shared" "3.4.21"

vuepress-plugin-cursor-effects@^1.1.6:
version "1.1.6"
resolved "https://registry.npmmirror.com/vuepress-plugin-cursor-effects/-/vuepress-plugin-cursor-effects-1.1.6.tgz#b71efc76e48a7f0f7492e60fc52047c3386569e9"
integrity sha512-4qXL2flMQcd6ecp+LhdChspobhdb9fkAfmRjRs2K3a/DiwtQtOE24jaVFCClwhfDpYuRe48a0KVeROYkdiWuXg==
dependencies:
"@moefy-canvas/theme-popper" "^0.5.2"

vuepress-plugin-feed@^0.1.9:
version "0.1.9"
resolved "https://registry.npmmirror.com/vuepress-plugin-feed/-/vuepress-plugin-feed-0.1.9.tgz#706fc381c1831c110d161b7e892057750c8904da"
Expand All @@ -4216,6 +4250,11 @@ vuepress-plugin-feed@^0.1.9:
remove-markdown "0.3.0"
striptags "3.1.1"

vuepress-plugin-seo@^0.2.0:
version "0.2.0"
resolved "https://registry.npmmirror.com/vuepress-plugin-seo/-/vuepress-plugin-seo-0.2.0.tgz#2fa4fd7ef2eb6c71f62302f264aeba47c6560ee9"
integrity sha512-/Rqul20UTL30mZyCbNwkfAfP50Yr7jzWlavQ92OVzZ8PcpZGXoDc+eoKQyKLQKL3G96dqvuCCbIMbW7RRs7Bhw==

vuepress-plugin-sitemap@^2.3.1:
version "2.3.1"
resolved "https://registry.npmmirror.com/vuepress-plugin-sitemap/-/vuepress-plugin-sitemap-2.3.1.tgz#51298aca77a5de96396fdbd1103e1637dd61ae6a"
Expand Down

0 comments on commit 6bb153d

Please sign in to comment.