-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
151 additions
and
87 deletions.
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
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], | ||
}) |
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 |
---|---|---|
@@ -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> |
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 |
---|---|---|
@@ -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' | ||
} |
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
Binary file not shown.
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