forked from Qiu-Jun/wx_lovers
-
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
13 changed files
with
14,451 additions
and
77 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
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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
class AppBootHook { | ||
constructor(app) { | ||
this.app = app; | ||
} | ||
|
||
// configWillLoad() { | ||
// // 此时 config 文件已经被读取并合并,但是还并未生效 | ||
// // 这是应用层修改配置的最后时机 | ||
// // 注意:此函数只支持同步调用 | ||
|
||
// // 例如:参数中的密码是加密的,在此处进行解密 | ||
// this.app.config.mysql.password = decrypt(this.app.config.mysql.password); | ||
// // 例如:插入一个中间件到框架的 coreMiddleware 之间 | ||
// const statusIdx = this.app.config.coreMiddleware.indexOf('status'); | ||
// this.app.config.coreMiddleware.splice(statusIdx + 1, 0, 'limit'); | ||
// } | ||
|
||
// async didLoad() { | ||
// // 所有的配置已经加载完毕 | ||
// // 可以用来加载应用自定义的文件,启动自定义的服务 | ||
|
||
// // 例如:创建自定义应用的示例 | ||
// this.app.queue = new Queue(this.app.config.queue); | ||
// await this.app.queue.init(); | ||
|
||
// // 例如:加载自定义的目录 | ||
// this.app.loader.loadToContext(path.join(__dirname, 'app/tasks'), 'tasks', { | ||
// fieldClass: 'tasksClasses', | ||
// }); | ||
// } | ||
|
||
// async willReady() { | ||
// // 所有的插件都已启动完毕,但是应用整体还未 ready | ||
// // 可以做一些数据初始化等操作,这些操作成功才会启动应用 | ||
|
||
// // 例如:从数据库加载数据到内存缓存 | ||
// this.app.cacheData = await this.app.model.query(QUERY_CACHE_SQL); | ||
// } | ||
|
||
// async didReady() { | ||
// // 应用已经启动完毕 | ||
|
||
// const ctx = await this.app.createAnonymousContext(); | ||
// await ctx.service.Biz.request(); | ||
// } | ||
|
||
async serverDidReady() { | ||
await this.app.curl(`http://127.0.0.1:7001/setCity?city=${this.app.config.userData.weatherCity}`, { | ||
method: 'GET', | ||
dataType: 'json' | ||
}) | ||
|
||
// // http / https server 已启动,开始接受外部请求 | ||
// // 此时可以从 app.server 拿到 server 的实例 | ||
|
||
// this.app.server.on('timeout', (socket) => { | ||
// // handle socket timeout | ||
// }); | ||
} | ||
} | ||
|
||
module.exports = AppBootHook; |
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 |
---|---|---|
@@ -0,0 +1,136 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>处理异常</title> | ||
<style> | ||
html, body { | ||
width: 100%; | ||
height: 100%; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
.box { | ||
position: absolute; | ||
left: 0; | ||
top: 0; | ||
width: 300px; | ||
height: 120px; | ||
} | ||
</style> | ||
<script crossorigin="anonymous" integrity="sha512-PhuYrdDBtBeUjY7KTmjRYFFadw8uXXdTmzZyhCHZewYsqZJ0pxFCwU528jRoil42LXMW3ksegQT5zdjkfiR1IA==" src="https://lib.baomitu.com/vue/2.7.7/vue.min.js"></script> | ||
</head> | ||
<body> | ||
<div class="box" id="box"> | ||
<button @click="handleClick">当你频繁操作,导致无法发送版本时,请点击</button> | ||
</div> | ||
</body> | ||
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.27.2/axios.min.js"></script> | ||
<script> | ||
!(function () { | ||
|
||
const canvas = document.createElement("canvas") | ||
document.body.append(canvas) | ||
const ctx = canvas.getContext('2d') | ||
|
||
function resizeCanvas() { | ||
canvas.width = window.innerWidth | ||
canvas.height = window.innerHeight | ||
} | ||
|
||
function clearCanvas() { | ||
ctx.fillStyle = "#000" | ||
ctx.fillRect(0, 0, canvas.width, canvas.height) | ||
} | ||
|
||
resizeCanvas() | ||
clearCanvas() | ||
|
||
window.addEventListener('resize', resizeCanvas) | ||
|
||
function mouseDownHandler(e) { | ||
const x = e.clientX | ||
const y = e.clientY | ||
createFireworks(x, y) | ||
} | ||
document.addEventListener('mousedown', mouseDownHandler, false) | ||
|
||
const particles = [] // 烟花 | ||
function createFireworks(sx, sy) { | ||
const hue = Math.floor(Math.random() * 51) + 150 | ||
const hueVariance = 30 | ||
const count = 100 | ||
for(let i = 0; i < count; i ++) { | ||
const angle = 360 / count * i | ||
const sr = (Math.random() * 5) + .4 | ||
const p ={ | ||
x: sx, | ||
y: sy, | ||
radians: angle * Math.PI / 180, | ||
size: Math.floor(Math.random() * 3) + 1, | ||
speed: sr, | ||
radius: sr, | ||
hue: Math.floor(Math.random() * ((hue + hueVariance) - (hue - hueVariance))) + (hue - hueVariance), | ||
brightness: Math.floor(Math.random() * 31) + 50, | ||
alpha: (Math.floor(Math.random() * 61) + 40) / 100 | ||
} | ||
particles.push(p) | ||
} | ||
} | ||
function drawFireworks() { | ||
clearCanvas() | ||
for(let i = 0; i < particles.length; i ++) { | ||
const p = particles[i] | ||
const vx = Math.cos(p.radians) * p.radius | ||
const vy = Math.sin(p.radians) * p.radius + 0.4 | ||
p.x += vx | ||
p.y += vy | ||
p.radius *= 1 - p.speed / 100 | ||
p.alpha -= 0.005 | ||
if(p.x < 0 || p.x > canvas.width || p.y < 0 || p.y > canvas.height) { | ||
particles.slice(i, 1) | ||
continue | ||
} | ||
ctx.beginPath() | ||
ctx.arc(p.x, p.y, p.size, 0, Math.PI * 2, false) | ||
ctx.closePath() | ||
ctx.fillStyle = `hsla(${p.hue}, 100%, ${p.brightness}%, ${p.alpha})` | ||
ctx.fill() | ||
} | ||
} | ||
|
||
// requestAnimationFrame | ||
function tick() { | ||
ctx.globalCompositeOperation = 'destination-out' | ||
ctx.fillStyle = `rgba(0, 0, 0, 0.1)` | ||
ctx.fillRect(0, 0, canvas.width, canvas.height) | ||
ctx.globalCompositeOperation = 'lighter' | ||
drawFireworks() | ||
requestAnimationFrame(tick) | ||
} | ||
tick() | ||
// setInterval(function () { | ||
// createFireworks(Math.random() * canvas.width, Math.random() | ||
// * canvas.height); | ||
// }, 1000); | ||
})() | ||
|
||
new Vue({ | ||
el: '#box', | ||
methods: { | ||
handleClick() { | ||
axios.get('http://127.0.0.1:7001/clearQuota') | ||
.then(res => { | ||
if(res.status === 200 && res.data.code === 200) { | ||
alert('操作成功') | ||
} else { | ||
alert(res.data.msg) | ||
} | ||
}) | ||
} | ||
} | ||
}) | ||
</script> | ||
</html> |
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
Oops, something went wrong.