mirror of
https://github.com/GiriNeko/YesPlayMusic.git
synced 2025-12-17 13:48:02 +00:00
feat: integrate api in electron app
This commit is contained in:
parent
bd29570e31
commit
74bf714c28
240 changed files with 21003 additions and 112 deletions
26
napi/main.js
Normal file
26
napi/main.js
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const request = require('./util/request');
|
||||
const { cookieToJson } = require('./util/index');
|
||||
|
||||
let obj = {};
|
||||
fs.readdirSync(path.join(__dirname, 'module'))
|
||||
.reverse()
|
||||
.forEach((file) => {
|
||||
if (!file.endsWith('.js')) return;
|
||||
let fileModule = require(path.join(__dirname, 'module', file));
|
||||
obj[file.split('.').shift()] = function (data) {
|
||||
if (typeof data.cookie === 'string') {
|
||||
data.cookie = cookieToJson(data.cookie);
|
||||
}
|
||||
return fileModule(
|
||||
{
|
||||
...data,
|
||||
cookie: data.cookie ? data.cookie : {},
|
||||
},
|
||||
request,
|
||||
);
|
||||
};
|
||||
});
|
||||
|
||||
module.exports = obj;
|
||||
Loading…
Add table
Add a link
Reference in a new issue