refactor: remove unused code
This commit is contained in:
parent
a73da45f16
commit
967e0b29f0
1 changed files with 0 additions and 25 deletions
25
src/file.ts
25
src/file.ts
|
@ -1,41 +1,16 @@
|
||||||
/* eslint-disable no-extend-native */
|
/* eslint-disable no-extend-native */
|
||||||
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
||||||
|
|
||||||
import { ALL, webpackGlobalOverride } from './webpack-hook'
|
|
||||||
import { console } from './utils'
|
import { console } from './utils'
|
||||||
|
|
||||||
type FileType = 'img' | 'mp3' | 'midi'
|
type FileType = 'img' | 'mp3' | 'midi'
|
||||||
|
|
||||||
const TYPE_REG = /id=(\d+)&type=(img|mp3|midi)/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* I know this is super hacky.
|
* I know this is super hacky.
|
||||||
*/
|
*/
|
||||||
const magicHookConstr = (() => {
|
const magicHookConstr = (() => {
|
||||||
const l = {}
|
const l = {}
|
||||||
|
|
||||||
webpackGlobalOverride(ALL, (n, r, t) => { // override
|
|
||||||
const e = n.exports
|
|
||||||
if (typeof e === 'object' && e.fetch) {
|
|
||||||
const fn = e.fetch
|
|
||||||
t.d(e, 'fetch', () => {
|
|
||||||
return function (...args) {
|
|
||||||
const [url, init] = args
|
|
||||||
const token = init?.headers?.Authorization
|
|
||||||
if (typeof url === 'string' && token) {
|
|
||||||
const m = url.match(TYPE_REG)
|
|
||||||
if (m) {
|
|
||||||
const type = m[2]
|
|
||||||
// eslint-disable-next-line no-unused-expressions
|
|
||||||
l[type]?.(token)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return fn(...args)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
return async (type: FileType) => {
|
return async (type: FileType) => {
|
||||||
return new Promise<string>((resolve) => {
|
return new Promise<string>((resolve) => {
|
||||||
l[type] = (token) => {
|
l[type] = (token) => {
|
||||||
|
|
Loading…
Reference in a new issue