- src/ 下拆分为入口/语言包/默认配置/主函数/工具模块,主函数整体搬入零改动 - rollup 打包 UMD(moeplayer.js + moeplayer.min.js),用户使用方式不变 - 库拷贝逻辑移至 scripts/copy-libs.js - README 重写:中文文档、快速开始、路线图、致谢原作者 - index.html 增加皮肤切换演示(默认/红色/西瓜)
27 lines
850 B
JavaScript
27 lines
850 B
JavaScript
import { isUndefined } from './type.js';
|
|
|
|
/*
|
|
* getPath
|
|
* 功能:获取该js文件所在路径
|
|
*/
|
|
function getPath(siz) {
|
|
var scriptList = document.scripts,
|
|
thisPath = scriptList[scriptList.length - 1].src;
|
|
for (var i = 0; i < scriptList.length; i++) {
|
|
var scriptName = scriptList[i].getAttribute('name') || scriptList[i].getAttribute('data-name');
|
|
var src = scriptList[i].src.slice(scriptList[i].src.lastIndexOf('/') + 1, scriptList[i].src.lastIndexOf('.'));
|
|
if ((scriptName && (scriptName == 'moeplayer' || scriptName == 'moeplayer.min')) || (scriptList[i].src && (src == 'moeplayer' || src == 'moeplayer.min'))) {
|
|
thisPath = scriptList[i].src;
|
|
break;
|
|
}
|
|
}
|
|
var path=thisPath.substring(0, thisPath.lastIndexOf('/js/') + 1);
|
|
if(!isUndefined(siz)){
|
|
path+=siz+'/';
|
|
}
|
|
return path;
|
|
}
|
|
|
|
|
|
export { getPath };
|