Skip to content

Commit caabf63

Browse files
F-loatFormatter [BOT]
andauthored
fix: 动态小程序码生成接口 (#478)
* Auto-format code 🧹🌟🤖 * fix: 动态小程序码生成接口 --------- Co-authored-by: Formatter [BOT] <runner@fv-az1361-149.2ktbtkyutslunjvokbglb2a1ge.bx.internal.cloudapp.net>
1 parent 084a9c9 commit caabf63

File tree

3 files changed

+21
-22
lines changed

3 files changed

+21
-22
lines changed

xiaomusic/static/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ <h1>谁家灯火夜通明</h1>
201201
display: flex;
202202
align-items: center;
203203
justify-content: center;
204+
transition: color 0.3s ease;
204205
}
205206

206207
.options a::before {

xiaomusic/static/weapp/qrcode.html

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,34 +26,29 @@
2626
padding: 8px;
2727
}
2828
</style>
29-
<script src="https://web-9gikcbug35bad3a8-1304825656.tcloudbaseapp.com/sdk/1.4.0/cloud.js"></script>
3029
</head>
3130

3231
<body>
3332
<img id="qrcode" src="https://assets-1251785959.cos.ap-beijing.myqcloud.com/xiaoplayer/weappcode.jpg" />
3433
<script>
35-
const c1 = new cloud.Cloud({
36-
identityless: true,
37-
resourceAppid: 'wx5931d820da6e8e50',
38-
resourceEnv: 'cards-ahoy-3g50hglqe5f630e4'
39-
})
40-
41-
c1.init().then(() => {
42-
c1.callFunction({
43-
name: 'qrcode',
44-
data: {
45-
host: location.host,
46-
protocol: location.protocol
47-
},
48-
complete: (res) => {
49-
if (res.errMsg === 'cloud.callFunction:ok' && !res.result.errCode) {
50-
const blob = new Blob([res.result.buffer])
51-
const url = URL.createObjectURL(blob)
52-
document.querySelector('#qrcode').setAttribute('src', url)
53-
}
54-
}
34+
fetch('https://xiaoplayer.f-loat.site/qrcode', {
35+
method: 'POST',
36+
headers: {
37+
'Content-Type': 'application/json'
38+
},
39+
body: JSON.stringify({
40+
host: location.host,
41+
protocol: location.protocol
5542
})
5643
})
44+
.then(res => {
45+
return res.ok ? res.blob() : null
46+
})
47+
.then(blob => {
48+
if (!blob) return
49+
const url = URL.createObjectURL(blob)
50+
document.querySelector('#qrcode').setAttribute('src', url)
51+
})
5752
</script>
5853
</body>
5954

xiaomusic/xiaomusic.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,10 @@ def setup_logger(self):
173173
if os.path.exists(log_file):
174174
os.remove(log_file)
175175
handler = RotatingFileHandler(
176-
self.config.log_file, maxBytes=10 * 1024 * 1024, backupCount=1,encoding='utf-8'
176+
self.config.log_file,
177+
maxBytes=10 * 1024 * 1024,
178+
backupCount=1,
179+
encoding="utf-8",
177180
)
178181
handler.stream.flush()
179182
handler.setFormatter(formatter)

0 commit comments

Comments
 (0)