Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #13

Closed
wants to merge 9 commits into from
407 changes: 258 additions & 149 deletions component.html

Large diffs are not rendered by default.

12 changes: 11 additions & 1 deletion details.html
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,14 @@ <h4 id="usename">
if (!tempData) {
return ;
}
if (tempData.body) {
tempData = tempData.body
console.log('tempData')
console.log(tempData)
if (typeof tempData === 'string') {
document.getElementById("mddata").innerHTML = tempData;
return
}
renderTpl('titleTpl',
{
name: tempData.name,
Expand Down Expand Up @@ -781,6 +789,7 @@ <h4 id="usename">

// mddata内容
var converter = new showdown.Converter();
// @TODO: 更新下makeHtml 解析插件
var html = converter.makeHtml(tempData.readme);
document.getElementById("mddata").innerHTML = html;

Expand Down Expand Up @@ -808,8 +817,9 @@ <h4 id="usename">
},
'#quick'
)
}
return ;
})
}, 'isAllData')
}

// V3: 获取Package所有版本接口
Expand Down
19 changes: 15 additions & 4 deletions plugin.html
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,12 @@ <h4 class="lasthead">微信公众号</h4>
<script src="static/js/wow.min.js"></script>
<!--====== Main JS ======-->
<script src="static/js/main.js"></script>

<script src="config/URL.js"></script>
<script src="utils/_Get.js"></script>
<script src="utils/_Post.js"></script>


<script>
function getQueryVariable(variable) {
var query = window.location.search.substring(1);
Expand Down Expand Up @@ -478,8 +484,8 @@ <h4 class="lasthead">微信公众号</h4>
}
document.getElementById(idName).innerHTML = attrString;
}

function getBaseInfor() {
// V2: 获取 分类 / 云厂商 信息
function getBaseInforV2() {
const attrList = {
category: {
url: "https://registry.devsapp.cn/common/category",
Expand Down Expand Up @@ -600,8 +606,13 @@ <h5><a href="details.html?name=${
xmlhttp.send(data);
}

getPackages();
getBaseInfor();

function main() {
getPackages();
getBaseInforV2();
}

main();
</script>
<script>
//translate.ignore.tag.push('span'); //翻译时追加上自己想指定忽略的tag标签,凡是在这里面的,都不进行翻译。
Expand Down
20 changes: 9 additions & 11 deletions search.html
Original file line number Diff line number Diff line change
Expand Up @@ -343,12 +343,17 @@ <h4 class="lasthead">微信公众号</h4>
<script src="utils/_Get.js"></script>
<script src="utils/_Post.js"></script>
<script src="utils/renderTpl.js"></script>
<script src="utils/splitMaxLenth.js"></script>
<script src="services/downloadV3Plugin.js"></script>
<script src="services/getPackagesSearchForV3.js"></script>
<!-- 注入搜索模板 -->
<script type="text/template" id="searchTpl">
{{each data}}
<div class="col-xl-4 wow fadeInUp" data-wow-delay="{{$value.delayTime}}s" style="visibility: visible; animation-delay: 0.2s; animation-name: fadeInUp;">
<div class="themes-box">
<div class="themes-box" style="overflow: hidden;">
{{if $value.package_type === 'v2' }}
<div class="ribbon" data-spm-anchor-id="5176.28448578.0.i154.758e60cczu7hm5">仅维护</div>
{{ /if }}
<div class="main-content">
<h5><a href="details.html?name={{$value.name}}&package_type={{$value.package_type}}" class="text-flow-ellipsis-single">{{$imports.splitMaxLenth($value.name)}}</a> <i class="fas fa-fire" style="float: right; color: orange;"> {{$value.download}} </i></h5>
<div class="last-part">
Expand Down Expand Up @@ -388,11 +393,6 @@ <h5><a href="details.html?name={{$value.name}}&package_type={{$value.package_typ
{{/each}}
</script>
<script>

function splitMaxLenth (dataStr) {
return dataStr.length > 25 ? dataStr.slice(0, 25) + "...": dataStr;
}

// 列表存储数据
var dataList = [];
function downloadPlugin(name) {
Expand Down Expand Up @@ -443,12 +443,9 @@ <h5><a href="details.html?name={{$value.name}}&package_type={{$value.package_typ

// V3: 搜索/获取 Package 信息
function getPackagesV3() {
var base_url = BASE_V3_URL
var url = base_url + '/packages/releases?'+ `search=${getQueryVariable("keyword")}`
_Get(url, function (result) {
getPackagesSearchForV3(`search=${getQueryVariable("keyword")}`, function (result) {
var keys = Object.keys(result);
var times = [0.3, 0.2, 0.1];

for (var i = 0; i < keys.length; i++) {
var item = {};
item.delayTime = times[Math.floor(Math.random() * times.length)];
Expand All @@ -470,7 +467,6 @@ <h5><a href="details.html?name={{$value.name}}&package_type={{$value.package_typ
item.package_type = 'v3'; // v2 v3标识
dataList.push(item);
}

return ;
})
}
Expand All @@ -485,6 +481,8 @@ <h5><a href="details.html?name={{$value.name}}&package_type={{$value.package_typ

if(dataList && dataList.length > 0){
renderTpl('searchTpl', { data: dataList }, '#itemlist')
}else{
renderTpl('searchTpl', { data: [] }, '#itemlist')
}
}

Expand Down
4 changes: 4 additions & 0 deletions services/downloadV3Plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ function downloadV3Plugin(name) {
var base_url = BASE_V3_URL
var url = base_url + '/packages/'+name+'/release/latest'
_Get(url, function (res) {
if (res.body==="未找到指定资源") {
console.log('未找到指定资源')
return;
}
var result = res.body||res.Response;
if (result && result.zipball_url) {
const link = document.createElement('a');
Expand Down
14 changes: 14 additions & 0 deletions services/getPackagesSearchForV3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// 调用V3版本 搜索接口
function getPackagesSearchForV3(dataString, callback) {
var base_url = BASE_V3_URL
if (dataString) {
dataString = dataString + '&platform=3'
} else {
dataString = 'platform=3'
}
var url = base_url + '/packages/releases?'+ dataString
_Get(url, function (result) {
callback && callback(result)
return ;
})
}
24 changes: 24 additions & 0 deletions static/css/style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 15 additions & 1 deletion static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,4 +428,18 @@
new WOW().init();
});

})(jQuery);
})(jQuery);



var objectSerialize = function (obj) {
var params = { ...obj } // wd=111&cb=222

var arrs = [] // 数组序列化
for (var key in params) {
if (params[key]) {
arrs.push(`${key}=${params[key]}`)
}
}
return `?${arrs.join('&')}`
}
27 changes: 24 additions & 3 deletions utils/_Get.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,50 @@ function _Get(url, callback, type) {
);
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState === 4 && xmlhttp.status === 200) {
var result = {};
if (type === 'isAllData') {// get方法返回所有接口数据
var result = JSON.parse(xmlhttp.responseText)
result = JSON.parse(xmlhttp.responseText)
callback&&callback(result)
return ;
}

if (type === 'response') { // get方法返回Response
var result = JSON.parse(xmlhttp.responseText).Response;
result = JSON.parse(xmlhttp.responseText).Response;
callback&&callback(result)
return ;
}

// get方法返回Body
if (type === 'body') {
var result = JSON.parse(xmlhttp.responseText).body;
result = JSON.parse(xmlhttp.responseText).body;
callback&&callback(result)
return ;
}
}else{
callback&&callback(JSON.parse(xmlhttp.responseText))
}
};
xmlhttp.setRequestHeader(
"Content-type",
"application/x-www-form-urlencoded"
);
xmlhttp.send();
}


// _GetJSON: 方法传递json参数,默认返回接口所有数据
function _GetJSON(url, callback){
var xmlhttp = window.XMLHttpRequest
? new XMLHttpRequest()
: new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.open("GET", url, false);
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var result = JSON.parse(xmlhttp.responseText);
callback&&callback(result)
return ;
}
};
xmlhttp.setRequestHeader("Content-type", "application/json");
xmlhttp.send();
}
4 changes: 4 additions & 0 deletions utils/splitMaxLenth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
function splitMaxLenth (dataStr, length) {
length = length || 25;
return dataStr.length > length ? dataStr.slice(0, length) + "...": dataStr;
}
Loading