Skip to content

Commit

Permalink
修复params页面获取参数可能失败的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
liying2008 committed Apr 6, 2019
1 parent b6c212e commit 33cb536
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 12 deletions.
6 changes: 3 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ mkdir -p dist/chrome
cp -r _locales css fonts img js LICENSE manifest.json *.html dist/chrome

cd dist/chrome
rm js/libs/vue.js
rm -f js/libs/vue.js
# 将 vue.js 替换为 vue.min.js
html_file=`ls *.html`
for html in $html_file;do
for html in $html_file; do
sed -i 's/src="js\/libs\/vue.js"/src="js\/libs\/vue.min.js"/' $html
done

zip -r ../jenkins-helper.zip *
cd -
cd -
3 changes: 2 additions & 1 deletion js/params.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ new Vue({
getParametersByUrl(url) {
var _self = this;
var jsonUrl = url + '/api/json';
fetch(jsonUrl).then(function (res) {
// console.log("jsonUrl", jsonUrl);
fetch(jsonUrl, Tools.getDefaultFetchOption()).then(function (res) {
if (res.ok) {
return res.json();
} else {
Expand Down
17 changes: 11 additions & 6 deletions js/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ var Tools = (function () {
jenkinsTokens = tokens
}

function getDefaultFetchOption(method = 'GET') {
return {
method: method,
credentials: 'include',
mode: 'cors',
redirect: 'follow',
}
}

function getFetchOption(url, method = 'GET') {
// console.log('jenkinsTokens', jenkinsTokens);
var token = undefined;
Expand All @@ -25,17 +34,13 @@ var Tools = (function () {
})
}
} else {
return {
method: method,
credentials: 'include',
mode: 'cors',
redirect: 'follow',
}
return getDefaultFetchOption(method)
}
}

return {
setJenkinsTokens,
getDefaultFetchOption,
getFetchOption
}
})();
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "__MSG_pluginDesc__",
"author": "LiYing",
"homepage_url": "https://github.com/liying2008/jenkins-helper",
"version": "1.1.6",
"version": "1.1.7",
"minimum_chrome_version": "45",
"default_locale": "en",
"omnibox": {
Expand Down
3 changes: 2 additions & 1 deletion params.html
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,5 @@ <h3 class="text-center" v-show="!fullDisplayName" style="margin: 64px">
</body>
<script src="js/libs/vue.js"></script>
<script src="js/params.js"></script>
</html>
<script src="js/tools.js"></script>
</html>

0 comments on commit 33cb536

Please sign in to comment.