云函数是 Mix Space 中的一个重要功能,它极大地辅助了使用者在 Mix Space 中的体验。通过云函数,Mix Space 可以额外实现实现歌单解析,追番列表等等的功能。
建议食用官方文档 https://mx-space.js.org/usage 本篇仅作参考
快速导入
具体配置需要一个一个修改,最多免去了创建过程。

Shiro主题
主题配置
这个是我当前配置 ,仅供参考,根据需要更改
Mix-Space 后台,进入「配置与云函数」页面,点击右上角的新增按钮,在编辑页面中,填入以下设置:
- 名称:shiro
- 引用:theme
数据类型:JSON
CodeBlock Loading...我的动态
需要在主题配置中配置
我的动态模块 新建云函数
- 名称:update
- 引用:ps
- 数据类型:Function
- 请求方式:POST
这个地方还需要设置一个密钥,在 Secret 中填入 key,在 Value 中填入你自己的密钥。
export default async function handler(ctx: Context) {
const {
timestamp,
process: processName,
key,
media,
meta,
} = ctx.req.body || {}
// handle GET
{
const [processInfo, mediaInfo] = await Promise.all([
ctx.storage.cache.get('ps') as any as Promise<Process | undefined>,
ctx.storage.cache.get('media') as any as Promise<Media | undefined>,
])
if (!key) {
return {
processName: processInfo?.name,
processInfo,
mediaInfo,
}
}
}
const ts = +new Date()
// if (Math.abs(ts - timestamp) > 1000 * 10) {
// ctx.throws(400, 'this request is outdate')
// return
// }
const processInfo: Process = {
name: processName,
...meta,
}
const validKey = (await ctx.secret.key) || 'testing'
if (key != validKey)
ctx.throws(401, "You haven't permission to update process info")
const originalPsInfo: Process | null = (await ctx.storage.cache.get(
'ps',
)) as any
await ctx.storage.cache.set('ps', processInfo, 300)
if (originalPsInfo?.name !== processName)
ctx?.broadcast?.('ps-update', {
processInfo,
process: processInfo.name,
ts,
})
if (media) {
await ctx.storage.cache.set('media', media, 10)
}
const mediaInfo: Media | undefined = (await ctx.storage.cache.get(
'media',
)) as any
if (mediaInfo?.title !== media?.title)
ctx?.broadcast?.('media-update', media || null)
return {
ok: 1,
mediaInfo,
process: processInfo.name,
processInfo,
timestamp: +new Date(),
}
}
interface Media {
title: string
artist: string
}
interface Process {
name: string
iconBase64?: string
iconUrl?: string
description?: string
}
另外需要下载对应平台的状态上报软件
参考官方文档:
https://mx-space.js.org/themes/shiro/extra#配置软件
个人状态(闭源专属)

- 名称:status
- 引用:shiro
- 数据类型:Function
- 请求方式:ALL
这个地方还需要设置一个密钥,在 Secret 中填入 key,在 Value 中填入你自己的密钥。
CodeBlock Loading...
设置状态,前端首页->双击左上角头像->登录,点击左上角头像的右下方设置状态。
svg签名动画(闭源专属)

受限于 Json 语法规则,此处 svg 代码需替换所有的
" 为 \ ",否则会报错。