Skip to content

Commit 313e48f

Browse files
committed
fixed error config notice
1 parent f0c29e7 commit 313e48f

File tree

4 files changed

+24
-17
lines changed

4 files changed

+24
-17
lines changed

README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ $ gulp serve
6363

6464
# Changelog
6565

66-
## 0.0.8 - 2017-05-10
66+
## 1.0 - 2018-05-11
67+
### Fixed
68+
- Error configuration notice
69+
70+
## 0.0.8 - 2018-05-10
6771
### Added
6872
- Intercept filter,blacklist and whitelist
6973

app/manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "__MSG_appName__",
3-
"version": "0.0.7",
3+
"version": "1.0",
44
"manifest_version": 2,
55
"description": "__MSG_appDescription__",
66
"author": "Jaeger <[email protected]>",

app/scripts.babel/background.js

+17-14
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ function add(down) {
148148
}
149149

150150
function postaria2obj(addobj, callback = null) {
151-
var httppost = new XMLHttpRequest();
152151
var aria2jsonrpcpath = getStorage('path');
153152

154153
var result = parse_url(aria2jsonrpcpath);
@@ -161,23 +160,27 @@ function postaria2obj(addobj, callback = null) {
161160
}
162161
}
163162

164-
httppost.open('POST', result[0] + '?tm=' + (new Date()).getTime().toString(), true);
165-
httppost.setRequestHeader('Authorization', auth);
166-
167-
httppost.onerror = function () {
168-
console.log('Error aria2 configuration!');
169-
if (addobj[0] && addobj[0].method === 'aria2.addUri') {
170-
notice('Error adding tasks to aria2,please check the configuration!', 'Error');
163+
fetch(result[0] + '?tm=' + (new Date()).getTime().toString(), {
164+
method: 'POST',
165+
body: JSON.stringify(addobj),
166+
headers: {
167+
'Authorization': auth,
168+
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
171169
}
172-
};
173-
httppost.addEventListener('load', function () {
174-
let rt = JSON.parse(this.responseText)
170+
}).then((response) => {
171+
return response.json()
172+
}).then((data) => {
175173
if (callback) {
176-
callback(rt)
174+
callback(data)
175+
}
176+
}).catch((error) => {
177+
console.error('Error:', error)
178+
console.log('Error aria2 configuration!');
179+
if (addobj && addobj.method === 'aria2.addUri') {
180+
notice('Error adding tasks to aria2,please check the configuration!', 'Error');
177181
}
178182
})
179-
httppost.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
180-
httppost.send(JSON.stringify(addobj));
183+
181184
return 'ok';
182185

183186
}

gulpfile.babel.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ gulp.task('html', () => {
7171
gulp.task('chromeManifest', () => {
7272
return gulp.src('app/manifest.json')
7373
.pipe($.chromeManifest({
74-
buildnumber: true,
74+
buildnumber: false,
7575
background: {
7676
target: 'scripts/background.js',
7777
exclude: [

0 commit comments

Comments
 (0)