From 8e8dc74b4dbffa3fb9fc489f6ab0e3901fa766c8 Mon Sep 17 00:00:00 2001 From: Natsumi Date: Wed, 9 Dec 2020 01:14:51 +1300 Subject: [PATCH] AH --- html/src/app.js | 45 +++++++++++++++++++++++++++++++++++++++++---- html/src/index.pug | 3 ++- 2 files changed, 43 insertions(+), 5 deletions(-) diff --git a/html/src/app.js b/html/src/app.js index 455b0320..88402fd9 100644 --- a/html/src/app.js +++ b/html/src/app.js @@ -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; })(); diff --git a/html/src/index.pug b/html/src/index.pug index 116cf4a8..945c10f2 100644 --- a/html/src/index.pug +++ b/html/src/index.pug @@ -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