This commit is contained in:
Natsumi
2020-12-09 01:14:51 +13:00
committed by pypy
parent 1bce5b574e
commit 8e8dc74b4d
2 changed files with 43 additions and 5 deletions

View File

@@ -336,8 +336,7 @@ import gameLogService from './service/gamelog.js'
...options
};
var { params } = init;
var isGetRequest = init.method === 'GET';
if (isGetRequest === true) {
if (init.method === 'GET') {
// transform body to url
if (params === Object(params)) {
var url = new URL(init.url);
@@ -352,7 +351,10 @@ import gameLogService from './service/gamelog.js'
if (req !== undefined) {
return req;
}
} else {
} else if (init.test === 'a') {
console.log("test");
}
else {
init.headers = {
'Content-Type': 'application/json;charset=utf-8',
...init.headers
@@ -361,6 +363,7 @@ import gameLogService from './service/gamelog.js'
? JSON.stringify(params)
: '{}';
}
console.log(init);
var req = webApiService.execute(init).catch((err) => {
this.$throw(0, err);
}).then((response) => {
@@ -400,7 +403,7 @@ import gameLogService from './service/gamelog.js'
this.$throw(status, data);
return data;
});
if (isGetRequest === true) {
if (init.method === 'GET') {
req.finally(() => {
this.pendingGetRequests.delete(init.url);
});
@@ -7443,6 +7446,8 @@ import gameLogService from './service/gamelog.js'
D.visible = false;
};
// App: VRCPlus Icons
$app.methods.displayVRCPlusIconsTable = function () {
var params = {
n: 100,
@@ -7520,6 +7525,38 @@ import gameLogService from './service/gamelog.js'
});
};
$app.methods.onFileChange = function (e) {
var files = e.target.files || e.dataTransfer.files;
console.log(e);
if (!files.length) {
return;
}
API.uploadVRCPlusIcon({ files[0]
}).then((args) => {
this.$message({
message: 'Icon uploaded',
type: 'success'
});
return args;
});
};
API.uploadVRCPlusIcon = function (params) {
return this.call('icon', {
method: 'POST',
'Content-Type': 'multipart/form-data',
'Content-Disposition': 'form-data; name="file"; filename="blob"',
test: 'a',
body: params
}).then((json) => {
var args = {
json,
params
};
return args;
});
};
$app = new Vue($app);
window.$app = $app;
})();

View File

@@ -444,10 +444,11 @@ html
span(style="font-weight:bold") VRCPlus Icons
el-button(type="default" @click="displayVRCPlusIconsTable()" size="mini" icon="el-icon-refresh" circle style="margin-left:5px")
el-button(type="default" @click="setVRCPlusIcon('')" size="mini" icon="el-icon-close" circle style="margin:0")
input(type="file" @change="onFileChange")
br
.x-friend-item(v-for="icon in VRCPlusIconsTable" :key="icon.id" style="display:inline-block;")
.vrcplus-icon(style="" @click="setVRCPlusIcon(icon.id)" :class="{ 'current-vrcplus-icon': 'https://api.vrchat.cloud/api/1/file/' + icon.id + '/1' === API.currentUser.userIcon }")
img.avatar(v-if="icon.versions[1].file.url" v-lazy="icon.versions[1].file.url")
img(v-if="icon.versions[1].file.url" v-lazy="icon.versions[1].file.url")
el-button(type="default" @click="deleteVRCPlusIcon(icon.id)" size="mini" icon="el-icon-delete" circle style="float:right;")
div(style="margin-top:30px")
span(style="font-weight:bold") Current User JSON