mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-08 10:56:15 -08:00
feat: add danmuku plugin documentation and i18n setup instructions
- Created a new documentation file for the danmuku plugin with code examples. - Added comprehensive language settings documentation, including default languages, importing languages, adding new languages, and modifying existing languages. - Updated the i18n setup examples to reflect the latest changes in language handling.
This commit is contained in:
1 parent
9d966bf696
commit
e947be8a8e
67 files changed
+216
-198
No files matched your search
+37
-19
@@ -1,26 +1,44 @@
|
||||
import fs from 'fs';
|
||||
import cpy from 'cpy';
|
||||
import path from 'path';
|
||||
import { glob } from 'glob';
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import { glob } from 'glob'
|
||||
|
||||
const reg = /^import.*;$/gim;
|
||||
const artplayerTS = glob.sync('packages/artplayer/types/*.d.ts');
|
||||
const artplayerTSoutput = path.join('docs/assets/ts/artplayer.d.ts');
|
||||
function parsePluginInfo(path) {
|
||||
const file = path.split('/').pop() || ''
|
||||
const baseName = file.replace('.d.ts', '')
|
||||
|
||||
let code = '';
|
||||
for (let index = 0; index < artplayerTS.length; index++) {
|
||||
const type = artplayerTS[index];
|
||||
code += String(fs.readFileSync(type)).replace(reg, '') + '\n';
|
||||
const name = baseName
|
||||
.split('-')
|
||||
.map((word, index) =>
|
||||
index === 0 ? word : word[0].toUpperCase() + word.slice(1),
|
||||
)
|
||||
.join('')
|
||||
|
||||
return { name, file }
|
||||
}
|
||||
|
||||
fs.writeFileSync(artplayerTSoutput, code.trim());
|
||||
const reg = /^import.*$/gim
|
||||
const artplayerTS = glob.sync('packages/artplayer/types/*.d.ts')
|
||||
const artplayerTSoutput = path.join('docs/assets/ts/artplayer.d.ts')
|
||||
|
||||
let code = ''
|
||||
for (let index = 0; index < artplayerTS.length; index++) {
|
||||
const type = artplayerTS[index]
|
||||
code += `${String(fs.readFileSync(type)).replace(reg, '')}\n`
|
||||
}
|
||||
|
||||
code.replace('export default ', '')
|
||||
code += `export = Artplayer;\nexport as namespace Artplayer;\n`
|
||||
fs.writeFileSync(artplayerTSoutput, code.trim())
|
||||
console.log(`✨ Built ${artplayerTSoutput}`);
|
||||
|
||||
(async function () {
|
||||
const pluginsTS = glob.sync('packages/artplayer-plugin-*/types/*.d.ts');
|
||||
for (let index = 0; index < pluginsTS.length; index++) {
|
||||
const type = pluginsTS[index];
|
||||
await cpy(type, 'docs/assets/ts/', { flat: true });
|
||||
console.log(`✨ Copy ${type}`);
|
||||
}
|
||||
})();
|
||||
const pluginsTS = glob.sync('packages/artplayer-plugin-*/types/*.d.ts')
|
||||
for (let index = 0; index < pluginsTS.length; index++) {
|
||||
const type = pluginsTS[index]
|
||||
const { name, file } = parsePluginInfo(type)
|
||||
const code = `${String(fs.readFileSync(type)).replace(reg, '')}\nexport = ${name};\nexport as namespace ${name};\n`
|
||||
const output = path.join('docs/assets/ts', file)
|
||||
fs.writeFileSync(output, code.trim())
|
||||
console.log(`✨ Built ${output}`)
|
||||
}
|
||||
})()
|
||||
Reference in new issue
Block a user