mirror of
https://github.com/NeteaseCloudMusicApiEnhanced/api-enhanced.git
synced 2026-03-21 11:03:15 +00:00
style(code): 格式化代码
- 将长参数列表拆分为多行以提高可读性 - 标准化函数调用中的逗号使用 - 统一对象和数组的换行格式 - 更新 ESLint 配置中的 ECMA 版本至 2020,以支持 ES2020 语法(包括 Optional Chaining) - 优化代码缩进和对齐方式 - 确保所有文件中的代码风格一致性
This commit is contained in:
parent
755489546b
commit
b1729f19aa
@ -16,7 +16,7 @@ const compat = new FlatCompat({
|
|||||||
module.exports = defineConfig([
|
module.exports = defineConfig([
|
||||||
{
|
{
|
||||||
languageOptions: {
|
languageOptions: {
|
||||||
ecmaVersion: 2018,
|
ecmaVersion: 2020,
|
||||||
sourceType: 'module',
|
sourceType: 'module',
|
||||||
parserOptions: {
|
parserOptions: {
|
||||||
parser: 'babel-eslint',
|
parser: 'babel-eslint',
|
||||||
|
|||||||
@ -14,7 +14,9 @@ let mm
|
|||||||
module.exports = async (query, request) => {
|
module.exports = async (query, request) => {
|
||||||
mm = require('music-metadata')
|
mm = require('music-metadata')
|
||||||
|
|
||||||
query.songFile.name = Buffer.from(query.songFile.name, 'latin1').toString('utf-8')
|
query.songFile.name = Buffer.from(query.songFile.name, 'latin1').toString(
|
||||||
|
'utf-8',
|
||||||
|
)
|
||||||
const ext = getFileExtension(query.songFile.name)
|
const ext = getFileExtension(query.songFile.name)
|
||||||
const filename = sanitizeFilename(query.songFile.name)
|
const filename = sanitizeFilename(query.songFile.name)
|
||||||
const bitrate = 999000
|
const bitrate = 999000
|
||||||
@ -59,7 +61,10 @@ module.exports = async (query, request) => {
|
|||||||
if (useTemp) {
|
if (useTemp) {
|
||||||
metadata = await mm.parseFile(query.songFile.tempFilePath)
|
metadata = await mm.parseFile(query.songFile.tempFilePath)
|
||||||
} else {
|
} else {
|
||||||
metadata = await mm.parseBuffer(query.songFile.data, query.songFile.mimetype)
|
metadata = await mm.parseBuffer(
|
||||||
|
query.songFile.data,
|
||||||
|
query.songFile.mimetype,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
const info = metadata.common
|
const info = metadata.common
|
||||||
if (info.title) songName = info.title
|
if (info.title) songName = info.title
|
||||||
|
|||||||
@ -35,7 +35,10 @@ module.exports = async (query, request) => {
|
|||||||
{
|
{
|
||||||
bucket: bucket,
|
bucket: bucket,
|
||||||
ext: ext,
|
ext: ext,
|
||||||
filename: filename.replace(/\.[^.]+$/, '').replace(/\s/g, '').replace(/\./g, '_'),
|
filename: filename
|
||||||
|
.replace(/\.[^.]+$/, '')
|
||||||
|
.replace(/\s/g, '')
|
||||||
|
.replace(/\./g, '_'),
|
||||||
local: false,
|
local: false,
|
||||||
nos_product: 3,
|
nos_product: 3,
|
||||||
type: 'audio',
|
type: 'audio',
|
||||||
|
|||||||
@ -82,9 +82,16 @@ module.exports = async (query, request) => {
|
|||||||
while (offset < fileSize) {
|
while (offset < fileSize) {
|
||||||
let chunk
|
let chunk
|
||||||
if (useTempFile) {
|
if (useTempFile) {
|
||||||
chunk = await readFileChunk(query.songFile.tempFilePath, offset, Math.min(blockSize, fileSize - offset))
|
chunk = await readFileChunk(
|
||||||
|
query.songFile.tempFilePath,
|
||||||
|
offset,
|
||||||
|
Math.min(blockSize, fileSize - offset),
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
chunk = query.songFile.data.slice(offset, Math.min(offset + blockSize, fileSize))
|
chunk = query.songFile.data.slice(
|
||||||
|
offset,
|
||||||
|
Math.min(offset + blockSize, fileSize),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const res3 = await axios({
|
const res3 = await axios({
|
||||||
|
|||||||
@ -1,7 +1,11 @@
|
|||||||
const { default: axios } = require('axios')
|
const { default: axios } = require('axios')
|
||||||
const createOption = require('../util/option.js')
|
const createOption = require('../util/option.js')
|
||||||
const logger = require('../util/logger.js')
|
const logger = require('../util/logger.js')
|
||||||
const { getUploadData, getFileExtension, sanitizeFilename } = require('../util/fileHelper')
|
const {
|
||||||
|
getUploadData,
|
||||||
|
getFileExtension,
|
||||||
|
sanitizeFilename,
|
||||||
|
} = require('../util/fileHelper')
|
||||||
|
|
||||||
module.exports = async (query, request) => {
|
module.exports = async (query, request) => {
|
||||||
const ext = getFileExtension(query.songFile.name)
|
const ext = getFileExtension(query.songFile.name)
|
||||||
|
|||||||
14
server.js
14
server.js
@ -182,17 +182,21 @@ async function consturctServer(moduleDefs) {
|
|||||||
const MAX_UPLOAD_SIZE_BYTES = MAX_UPLOAD_SIZE_MB * 1024 * 1024
|
const MAX_UPLOAD_SIZE_BYTES = MAX_UPLOAD_SIZE_MB * 1024 * 1024
|
||||||
|
|
||||||
app.use(express.json({ limit: `${MAX_UPLOAD_SIZE_MB}mb` }))
|
app.use(express.json({ limit: `${MAX_UPLOAD_SIZE_MB}mb` }))
|
||||||
app.use(express.urlencoded({ extended: false, limit: `${MAX_UPLOAD_SIZE_MB}mb` }))
|
app.use(
|
||||||
|
express.urlencoded({ extended: false, limit: `${MAX_UPLOAD_SIZE_MB}mb` }),
|
||||||
|
)
|
||||||
|
|
||||||
app.use(fileUpload({
|
app.use(
|
||||||
|
fileUpload({
|
||||||
limits: {
|
limits: {
|
||||||
fileSize: MAX_UPLOAD_SIZE_BYTES
|
fileSize: MAX_UPLOAD_SIZE_BYTES,
|
||||||
},
|
},
|
||||||
useTempFiles: true,
|
useTempFiles: true,
|
||||||
tempFileDir: require('os').tmpdir(),
|
tempFileDir: require('os').tmpdir(),
|
||||||
abortOnLimit: true,
|
abortOnLimit: true,
|
||||||
parseNested: true
|
parseNested: true,
|
||||||
}))
|
}),
|
||||||
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cache
|
* Cache
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user