提交 ecc0378d 编写于 作者: 5 592767809

更新

上级 31f6d774
因为 它太大了无法显示 source diff 。你可以改为 查看blob
const parser = require("@babel/parser");
// 为parser提供模板引擎
const template = require("@babel/template").default;
// 遍历AST
const traverse = require("@babel/traverse").default;
// 操作节点,比如判断节点类型,生成新的节点等
const t = require("@babel/types");
// 将语法树转换为源代码
const generator = require("@babel/generator");
// 操作文件
const fs = require("fs");
//定义公共函数
function wtofile(path, flags, code) {
var fd = fs.openSync(path,flags);
fs.writeSync(fd, code);
fs.closeSync(fd);
}
function dtofile(path) {
fs.unlinkSync(path);
}
var loader_path = 'runtime.62249a5.js';
var jscode = fs.readFileSync(loader_path, {
encoding: "utf-8"
......@@ -35,27 +23,45 @@ for (let i = 0; i < loader_body.length; i++){
if (loader_body[i].type === 'VariableDeclaration'){
loader_ast.program.body[0].expression.argument.callee.body.body.splice(i+3, (loader_body.length- i-3));
loader_ast.program.body[0].expression.argument.callee.body.body.splice(0, i);
loader_ast.program.body[0].expression.argument.callee.body.body.push(t.assignmentExpression("=", t.identifier("export_function"), t.identifier(loader_ast.program.body[0].expression.argument.callee.body.body[1].id.name)));
break
}
}
// 修改加载器参数类型
let loader_arguments = loader_ast.program.body[0].expression.argument.arguments[0] = t.objectExpression([]);
console.log(loader_arguments);
// 加载函数体
// var modular_path = ['app.597640f.js'];
// console.log(loader_ast.program.body[0].expression.argument.arguments)
var modular_path = ['app.597640f.js', 'search.cfd9038.js', 'commons.1e71338.js'];
// modular_path.forEach(function (item, index) {
// var jscode = fs.readFileSync(item, {
// encoding: "utf-8"
// });
//
// let modular_ast = parser.parse(jscode);
// console.log(modular_ast.program.body[0].expression.arguments[0].elements)
//
// });
modular_path.forEach(function (item, index) {
var jscode = fs.readFileSync(item, {
encoding: "utf-8"
});
let modular_ast = parser.parse(jscode);
modular_ast.program.body[0].expression.arguments[0].elements.forEach(function (item2, index2) {
if (item2.type === 'ArrayExpression'){
item2.elements.forEach(function (item3, index3) {
if (item3 && item3.type === 'FunctionExpression'){
loader_arguments.properties.push(t.objectProperty(
t.numericLiteral(index3),
item3,
false,
false
));
}
});
}else {
item2.properties.forEach(function (item3, index3) {
loader_arguments.properties.push(item3)
})
}
});
});
// 申请全局导出函数
loader_ast.program.body.splice(0, 0, t.variableDeclaration("var",[t.variableDeclarator(t.identifier("export_function"))]));
let code = generator.default(loader_ast, {
compact: false, // 压缩格式
......@@ -66,8 +72,5 @@ let code = generator.default(loader_ast, {
}).code;
wtofile('webpack_out.js', 'w', code);
// loader_ast.program.body[0].expression.argument.callee.body.body.forEach(function (item, index) {
// console.log(item.type)
// });
(window.webpackJsonp=window.webpackJsonp||[]).push([[19],{301:function(t,e,n){var content=n(311);"string"==typeof content&&(content=[[t.i,content,""]]),content.locals&&(t.exports=content.locals);(0,n(4).default)("4d9fc87d",content,!0,{sourceMap:!1})},310:function(t,e,n){"use strict";var r=n(301);n.n(r).a},311:function(t,e,n){(e=n(3)(!1)).push([t.i,'a[data-v-17ae183a]{position:relative;display:inline-block;height:20px;line-height:20px;margin-right:34px;font-weight:300;color:#333}a.active[data-v-17ae183a],a[data-v-17ae183a]:hover{color:#000}a.active[data-v-17ae183a]{font-weight:600}a.active[data-v-17ae183a]:after{position:absolute;content:"";left:0;bottom:1px;width:100%;height:6px;background:#ffe443;z-index:-1}',""]),t.exports=e},313:function(t,e,n){"use strict";n(91);var r={props:{subnav:{type:Array,default:function(){return[{name:"推荐",id:""},{name:"排行榜",id:"rankList"},{name:"歌手",id:"singers"},{name:"歌单",id:"playlists"},{name:"MV",id:"mvs"}]}},active:{type:Number,default:function(){return 0}}},data:function(){return{currentTag:this.active}},watch:{active:function(t){this.currentTag=t}},methods:{tagClick:function(t,e){this.currentTag=e,this.$emit("getdata",t)}}},c=(n(310),n(2)),component=Object(c.a)(r,(function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{},t._l(t.subnav,(function(e,r){return n("a",{key:r,class:{active:t.currentTag===r},attrs:{href:"javascript:;"},on:{click:function(n){return t.tagClick(e.id,r)}}},[t._v(t._s(e.name))])})),0)}),[],!1,null,"17ae183a",null);e.a=component.exports},367:function(t,e,n){var content=n(602);"string"==typeof content&&(content=[[t.i,content,""]]),content.locals&&(t.exports=content.locals);(0,n(4).default)("60ebd7be",content,!0,{sourceMap:!1})},601:function(t,e,n){"use strict";var r=n(367);n.n(r).a},602:function(t,e,n){var r=n(3),c=n(58),o=n(603);e=r(!1);var h=c(o);e.push([t.i,".search_out[data-v-71e59797]{position:relative;height:246px}.search_out .bg[data-v-71e59797]{width:1920px;height:100%;background:url("+h+");z-index:-1}.search_out .bg[data-v-71e59797],.search_out .search_inn[data-v-71e59797]{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}.search_out .search_inn[data-v-71e59797]{width:720px;z-index:20}.search_out .search_inn .ipt_out[data-v-71e59797]{position:relative}.search_out .search_inn .ipt_out .search_ipt[data-v-71e59797]{width:100%;height:54px;padding:0 64px 0 18px;border-radius:4px;background:#fff;border:none}.search_out .search_inn .ipt_out .search_icon[data-v-71e59797]{position:absolute;right:0;top:0;width:54px;height:54px;line-height:54px;text-align:center;cursor:pointer}.search_out .search_inn .ipt_out .search_icon .iconfont[data-v-71e59797]{font-size:20px}.tabs[data-v-71e59797]{display:flex;align-items:baseline;margin-top:43px;margin-bottom:42px}.tabs .text[data-v-71e59797]{font-size:22px;font-weight:600;line-height:30px;margin-right:40px}.child_view[data-v-71e59797]{min-height:100px}",""]),t.exports=e},603:function(t,e,n){t.exports=n.p+"img/searchBg.07b12b9.png"},674:function(t,e,n){"use strict";n.r(e);n(42),n(112),n(5);var r=n(313),c=n(144),o={middleware:"userInfo",components:{Subnav:r.a,search:c.a},asyncData:function(t){var e=["/search/list","/search/album","/search/mv","/search/playlist","/search/singers"],n=e.findIndex((function(e,n){return t.route.path===e})),r=t.query,c="";return r&&r.key&&(c=r.key.replace(/^\s*|\s*$/g,"")),{key:c,urlArr:e,active:n}},data:function(){return{subnav:[{name:"单曲",id:"/search/list"},{name:"专辑",id:"/search/album"},{name:"MV",id:"/search/mv"},{name:"歌单",id:"/search/playlist"},{name:"歌手",id:"/search/singers"}],route:"list"}},head:function(){return{meta:[{hid:"keywords",name:"keywords",content:"".concat(this.$route.query.key,",").concat(this.$route.query.key,"歌词,").concat(this.$route.query.key,"歌曲,").concat(this.$route.query.key,"专辑,").concat(this.$route.query.key,"资料,").concat(this.$route.query.key,"歌单,").concat(this.$route.query.key,"MV,").concat(this.$route.query.key,"的评论,酷我音乐")}]}},watch:{$route:function(){var t=this,e=this.urlArr.findIndex((function(e,n){return t.$route.path===e}));e>=0&&(this.active=e);var n=this.$route.query.key;this.key=n||""}},mounted:function(){this.$store.commit("downloadurl/set",{windows:"http://down.kuwo.cn/mbox/kwmusic_web_6.exe"})},methods:{switchTab:function(t){t!==this.route&&(this.route=t,this.$router.push({path:t,query:{key:this.key}}))}}},h=(n(601),n(2)),component=Object(h.a)(o,(function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"search_page"},[n("div",{staticClass:"search_out"},[n("div",{staticClass:"bg"}),t._v(" "),n("div",{staticClass:"search_inn"},[n("search",{attrs:{keyquery:t.key,type:"search_page"}})],1)]),t._v(" "),n("div",[n("div",{staticClass:"tabs"},[n("span",{staticClass:"text"},[t._v("搜索结果")]),t._v(" "),n("Subnav",{attrs:{subnav:t.subnav,active:t.active},on:{getdata:t.switchTab}})],1),t._v(" "),n("nuxt-child",{staticClass:"child_view",attrs:{keystr:t.key}})],1)])}),[],!1,null,"71e59797",null);e.default=component.exports}}]);
\ No newline at end of file
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册