mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-19 06:43:51 +02:00
refactor: Splitting API requests from app.js (#1175)
This commit is contained in:
1405
src/app.js
1405
src/app.js
File diff suppressed because it is too large
Load Diff
@@ -2,7 +2,7 @@ import * as workerTimers from 'worker-timers';
|
||||
import configRepository from '../repository/config.js';
|
||||
import database from '../repository/database.js';
|
||||
import { baseClass, $app, API, $t, $utils } from './baseClass.js';
|
||||
import { avatarRequest, worldRequest } from './request';
|
||||
import { avatarRequest, favoriteRequest, worldRequest } from './request';
|
||||
|
||||
export default class extends baseClass {
|
||||
constructor(_app, _API, _t) {
|
||||
@@ -317,20 +317,22 @@ export default class extends baseClass {
|
||||
),
|
||||
callback: (action, instance) => {
|
||||
if (action === 'confirm') {
|
||||
API.saveFavoriteGroup({
|
||||
type: ctx.type,
|
||||
group: ctx.name,
|
||||
displayName: instance.inputValue
|
||||
}).then((args) => {
|
||||
this.$message({
|
||||
message: $t(
|
||||
'prompt.change_favorite_group_name.message.success'
|
||||
),
|
||||
type: 'success'
|
||||
favoriteRequest
|
||||
.saveFavoriteGroup({
|
||||
type: ctx.type,
|
||||
group: ctx.name,
|
||||
displayName: instance.inputValue
|
||||
})
|
||||
.then((args) => {
|
||||
this.$message({
|
||||
message: $t(
|
||||
'prompt.change_favorite_group_name.message.success'
|
||||
),
|
||||
type: 'success'
|
||||
});
|
||||
// load new group name
|
||||
API.refreshFavoriteGroups();
|
||||
});
|
||||
// load new group name
|
||||
API.refreshFavoriteGroups();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
60
src/classes/request/avatarModeration.js
Normal file
60
src/classes/request/avatarModeration.js
Normal file
@@ -0,0 +1,60 @@
|
||||
// #region | API: AvatarModeration
|
||||
|
||||
const avatarModerationReq = {
|
||||
getAvatarModerations() {
|
||||
return window.API.call('auth/user/avatarmoderations', {
|
||||
method: 'GET'
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json
|
||||
};
|
||||
window.API.$emit('AVATAR-MODERATION:LIST', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {{ avatarModerationType: string, targetAvatarId: string }} params
|
||||
* @return { Promise<{json: any, params}> }
|
||||
*/
|
||||
sendAvatarModeration(params) {
|
||||
return window.API.call('auth/user/avatarmoderations', {
|
||||
method: 'POST',
|
||||
params
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('AVATAR-MODERATION', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {{ avatarModerationType: string, targetAvatarId: string }} params
|
||||
* @return { Promise<{json: any, params}> }
|
||||
*/
|
||||
deleteAvatarModeration(params) {
|
||||
return window.API.call(
|
||||
`auth/user/avatarmoderations?targetAvatarId=${encodeURIComponent(
|
||||
params.targetAvatarId
|
||||
)}&avatarModerationType=${encodeURIComponent(
|
||||
params.avatarModerationType
|
||||
)}`,
|
||||
{
|
||||
method: 'DELETE'
|
||||
}
|
||||
).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('AVATAR-MODERATION:DELETE', args);
|
||||
return args;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// #endregion
|
||||
export default avatarModerationReq;
|
||||
187
src/classes/request/favorite.js
Normal file
187
src/classes/request/favorite.js
Normal file
@@ -0,0 +1,187 @@
|
||||
// #region | API: Favorite
|
||||
|
||||
const favoriteReq = {
|
||||
getFavoriteLimits() {
|
||||
return window.API.call('auth/user/favoritelimits', {
|
||||
method: 'GET'
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json
|
||||
};
|
||||
window.API.$emit('FAVORITE:LIMITS', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {{
|
||||
* n: number,
|
||||
* offset: number,
|
||||
* type: string,
|
||||
* tag: string
|
||||
* }} params
|
||||
* @return { Promise<{json: any, params}> }
|
||||
*/
|
||||
getFavorites(params) {
|
||||
return window.API.call('favorites', {
|
||||
method: 'GET',
|
||||
params
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('FAVORITE:LIST', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {{
|
||||
* type: string,
|
||||
* favoriteId: string (objectId),
|
||||
* tags: string
|
||||
* }} params
|
||||
* @return { Promise<{json: any, params}> }
|
||||
*/
|
||||
addFavorite(params) {
|
||||
return window.API.call('favorites', {
|
||||
method: 'POST',
|
||||
params
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('FAVORITE:ADD', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {{ objectId: string }} params
|
||||
* @return { Promise<{json: any, params}> }
|
||||
*/
|
||||
deleteFavorite(params) {
|
||||
return window.API.call(`favorites/${params.objectId}`, {
|
||||
method: 'DELETE'
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('FAVORITE:DELETE', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {{ n: number, offset: number, type: string }} params
|
||||
* @return { Promise<{json: any, params}> }
|
||||
*/
|
||||
getFavoriteGroups(params) {
|
||||
return window.API.call('favorite/groups', {
|
||||
method: 'GET',
|
||||
params
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('FAVORITE:GROUP:LIST', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {{ type: string, group: string, displayName: string, visibility: string }} params group is a name
|
||||
* @return { Promise<{json: any, params}> }
|
||||
*/
|
||||
saveFavoriteGroup(params) {
|
||||
return window.API.call(
|
||||
`favorite/group/${params.type}/${params.group}/${window.API.currentUser.id}`,
|
||||
{
|
||||
method: 'PUT',
|
||||
params
|
||||
}
|
||||
).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('FAVORITE:GROUP:SAVE', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {{
|
||||
* type: string,
|
||||
* group: string (name)
|
||||
* }} params
|
||||
* @return { Promise<{json: any, params}> }
|
||||
*/
|
||||
clearFavoriteGroup(params) {
|
||||
return window.API.call(
|
||||
`favorite/group/${params.type}/${params.group}/${window.API.currentUser.id}`,
|
||||
{
|
||||
method: 'DELETE',
|
||||
params
|
||||
}
|
||||
).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('FAVORITE:GROUP:CLEAR', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {{
|
||||
* n: number,
|
||||
* offset: number
|
||||
* }} params
|
||||
* @return { Promise<{json: any, params}> }
|
||||
*/
|
||||
getFavoriteWorlds(params) {
|
||||
return window.API.call('worlds/favorites', {
|
||||
method: 'GET',
|
||||
params
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('FAVORITE:WORLD:LIST', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {{
|
||||
* n: number,
|
||||
* offset: number
|
||||
* }} params
|
||||
* @return { Promise<{json: any, params}> }
|
||||
*/
|
||||
getFavoriteAvatars(params) {
|
||||
return window.API.call('avatars/favorites', {
|
||||
method: 'GET',
|
||||
params
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('FAVORITE:AVATAR:LIST', args);
|
||||
return args;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// #endregion
|
||||
|
||||
export default favoriteReq;
|
||||
306
src/classes/request/image.js
Normal file
306
src/classes/request/image.js
Normal file
@@ -0,0 +1,306 @@
|
||||
const imageReq = {
|
||||
// use in uploadAvatarImage
|
||||
// need to test
|
||||
async uploadAvatarFailCleanup(id) {
|
||||
const json = await window.API.call(`file/${id}`, {
|
||||
method: 'GET'
|
||||
});
|
||||
const fileId = json.id;
|
||||
const fileVersion = json.versions[json.versions.length - 1].version;
|
||||
window.API.call(`file/${fileId}/${fileVersion}/signature/finish`, {
|
||||
method: 'PUT'
|
||||
});
|
||||
window.API.call(`file/${fileId}/${fileVersion}/file/finish`, {
|
||||
method: 'PUT'
|
||||
});
|
||||
window.$app.avatarDialog.loading = false;
|
||||
window.$app.changeAvatarImageDialogLoading = false;
|
||||
},
|
||||
|
||||
async uploadAvatarImage(params, fileId) {
|
||||
try {
|
||||
return await window.API.call(`file/${fileId}`, {
|
||||
method: 'POST',
|
||||
params
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params,
|
||||
fileId
|
||||
};
|
||||
window.API.$emit('AVATARIMAGE:INIT', args);
|
||||
return args;
|
||||
});
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
window.API.uploadAvatarFailCleanup(fileId);
|
||||
}
|
||||
return void 0;
|
||||
},
|
||||
|
||||
async uploadAvatarImageFileStart(params) {
|
||||
try {
|
||||
return await window.API.call(
|
||||
`file/${params.fileId}/${params.fileVersion}/file/start`,
|
||||
{
|
||||
method: 'PUT'
|
||||
}
|
||||
).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('AVATARIMAGE:FILESTART', args);
|
||||
return args;
|
||||
});
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
window.API.uploadAvatarFailCleanup(params.fileId);
|
||||
}
|
||||
return void 0;
|
||||
},
|
||||
|
||||
uploadAvatarImageFileFinish(params) {
|
||||
return window.API.call(
|
||||
`file/${params.fileId}/${params.fileVersion}/file/finish`,
|
||||
{
|
||||
method: 'PUT',
|
||||
params: {
|
||||
maxParts: 0,
|
||||
nextPartNumber: 0
|
||||
}
|
||||
}
|
||||
).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('AVATARIMAGE:FILEFINISH', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
async uploadAvatarImageSigStart(params) {
|
||||
try {
|
||||
return await window.API.call(
|
||||
`file/${params.fileId}/${params.fileVersion}/signature/start`,
|
||||
{
|
||||
method: 'PUT'
|
||||
}
|
||||
).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('AVATARIMAGE:SIGSTART', args);
|
||||
return args;
|
||||
});
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
window.API.uploadAvatarFailCleanup(params.fileId);
|
||||
}
|
||||
return void 0;
|
||||
},
|
||||
|
||||
uploadAvatarImageSigFinish(params) {
|
||||
return window.API.call(
|
||||
`file/${params.fileId}/${params.fileVersion}/signature/finish`,
|
||||
{
|
||||
method: 'PUT',
|
||||
params: {
|
||||
maxParts: 0,
|
||||
nextPartNumber: 0
|
||||
}
|
||||
}
|
||||
).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('AVATARIMAGE:SIGFINISH', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
setAvatarImage(params) {
|
||||
return window.API.call(`avatars/${params.id}`, {
|
||||
method: 'PUT',
|
||||
params
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('AVATARIMAGE:SET', args);
|
||||
window.API.$emit('AVATAR', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
// use in uploadWorldImage
|
||||
// need to test
|
||||
async uploadWorldFailCleanup(id) {
|
||||
const json = await window.API.call(`file/${id}`, {
|
||||
method: 'GET'
|
||||
});
|
||||
const fileId = json.id;
|
||||
const fileVersion = json.versions[json.versions.length - 1].version;
|
||||
window.API.call(`file/${fileId}/${fileVersion}/signature/finish`, {
|
||||
method: 'PUT'
|
||||
});
|
||||
window.API.call(`file/${fileId}/${fileVersion}/file/finish`, {
|
||||
method: 'PUT'
|
||||
});
|
||||
window.$app.worldDialog.loading = false;
|
||||
window.$app.changeWorldImageDialogLoading = false;
|
||||
},
|
||||
|
||||
async uploadWorldImage(params, fileId) {
|
||||
try {
|
||||
return await window.API.call(`file/${fileId}`, {
|
||||
method: 'POST',
|
||||
params
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params,
|
||||
fileId
|
||||
};
|
||||
window.API.$emit('WORLDIMAGE:INIT', args);
|
||||
return args;
|
||||
});
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
window.API.uploadWorldFailCleanup(fileId);
|
||||
}
|
||||
return void 0;
|
||||
},
|
||||
|
||||
async uploadWorldImageFileStart(params) {
|
||||
try {
|
||||
return await window.API.call(
|
||||
`file/${params.fileId}/${params.fileVersion}/file/start`,
|
||||
{
|
||||
method: 'PUT'
|
||||
}
|
||||
).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('WORLDIMAGE:FILESTART', args);
|
||||
return args;
|
||||
});
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
window.API.uploadWorldFailCleanup(params.fileId);
|
||||
}
|
||||
return void 0;
|
||||
},
|
||||
|
||||
uploadWorldImageFileFinish(params) {
|
||||
return window.API.call(
|
||||
`file/${params.fileId}/${params.fileVersion}/file/finish`,
|
||||
{
|
||||
method: 'PUT',
|
||||
params: {
|
||||
maxParts: 0,
|
||||
nextPartNumber: 0
|
||||
}
|
||||
}
|
||||
).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('WORLDIMAGE:FILEFINISH', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
async uploadWorldImageSigStart(params) {
|
||||
try {
|
||||
return await window.API.call(
|
||||
`file/${params.fileId}/${params.fileVersion}/signature/start`,
|
||||
{
|
||||
method: 'PUT'
|
||||
}
|
||||
).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('WORLDIMAGE:SIGSTART', args);
|
||||
return args;
|
||||
});
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
window.API.uploadWorldFailCleanup(params.fileId);
|
||||
}
|
||||
return void 0;
|
||||
},
|
||||
|
||||
uploadWorldImageSigFinish(params) {
|
||||
return window.API.call(
|
||||
`file/${params.fileId}/${params.fileVersion}/signature/finish`,
|
||||
{
|
||||
method: 'PUT',
|
||||
params: {
|
||||
maxParts: 0,
|
||||
nextPartNumber: 0
|
||||
}
|
||||
}
|
||||
).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('WORLDIMAGE:SIGFINISH', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
setWorldImage(params) {
|
||||
return window.API.call(`worlds/${params.id}`, {
|
||||
method: 'PUT',
|
||||
params
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('WORLDIMAGE:SET', args);
|
||||
window.API.$emit('WORLD', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
getAvatarImages(params) {
|
||||
return window.API.call(`file/${params.fileId}`, {
|
||||
method: 'GET'
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('AVATARIMAGE:GET', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
getWorldImages(params) {
|
||||
return window.API.call(`file/${params.fileId}`, {
|
||||
method: 'GET',
|
||||
params
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('WORLDIMAGE:GET', args);
|
||||
return args;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export default imageReq;
|
||||
@@ -12,6 +12,14 @@ import instanceRequest from './instance';
|
||||
import friendRequest from './friend';
|
||||
import avatarRequest from './avatar';
|
||||
import notificationRequest from './notification';
|
||||
import playerModerationRequest from './playerModeration';
|
||||
import avatarModerationRequest from './avatarModeration';
|
||||
import favoriteRequest from './favorite';
|
||||
import vrcPlusIconRequest from './vrcPlusIcon';
|
||||
import vrcPlusImageRequest from './vrcPlusImage';
|
||||
import inviteMessagesRequest from './inviteMessages';
|
||||
import imageRequest from './image';
|
||||
import miscRequest from './misc';
|
||||
|
||||
export {
|
||||
userRequest,
|
||||
@@ -19,5 +27,13 @@ export {
|
||||
instanceRequest,
|
||||
friendRequest,
|
||||
avatarRequest,
|
||||
notificationRequest
|
||||
notificationRequest,
|
||||
playerModerationRequest,
|
||||
avatarModerationRequest,
|
||||
favoriteRequest,
|
||||
vrcPlusIconRequest,
|
||||
vrcPlusImageRequest,
|
||||
inviteMessagesRequest,
|
||||
imageRequest,
|
||||
miscRequest
|
||||
};
|
||||
|
||||
41
src/classes/request/inviteMessages.js
Normal file
41
src/classes/request/inviteMessages.js
Normal file
@@ -0,0 +1,41 @@
|
||||
// #region | App: Invite Messages
|
||||
|
||||
const inviteMessagesReq = {
|
||||
refreshInviteMessageTableData(messageType) {
|
||||
return window.API.call(
|
||||
`message/${window.API.currentUser.id}/${messageType}`,
|
||||
{
|
||||
method: 'GET'
|
||||
}
|
||||
).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
messageType
|
||||
};
|
||||
window.API.$emit(`INVITE:${messageType.toUpperCase()}`, args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
editInviteMessage(params, messageType, slot) {
|
||||
return window.API.call(
|
||||
`message/${window.API.currentUser.id}/${messageType}/${slot}`,
|
||||
{
|
||||
method: 'PUT',
|
||||
params
|
||||
}
|
||||
).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params,
|
||||
messageType,
|
||||
slot
|
||||
};
|
||||
return args;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// #endregion
|
||||
|
||||
export default inviteMessagesReq;
|
||||
179
src/classes/request/misc.js
Normal file
179
src/classes/request/misc.js
Normal file
@@ -0,0 +1,179 @@
|
||||
const miscReq = {
|
||||
getBundles(fileId) {
|
||||
return window.API.call(`file/${fileId}`, {
|
||||
method: 'GET'
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json
|
||||
};
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
saveNote(params) {
|
||||
return window.API.call('userNotes', {
|
||||
method: 'POST',
|
||||
params
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('NOTE', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {{
|
||||
* userId: string,
|
||||
* contentType: string,
|
||||
* reason: string,
|
||||
* type: string
|
||||
* }} params
|
||||
* @return { Promise<{json: any, params}> }
|
||||
*/
|
||||
reportUser(params) {
|
||||
return window.API.call(`feedback/${params.userId}/user`, {
|
||||
method: 'POST',
|
||||
params: {
|
||||
contentType: params.contentType,
|
||||
reason: params.reason,
|
||||
type: params.type
|
||||
}
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('FEEDBACK:REPORT:USER', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {{
|
||||
* fileId: string,
|
||||
* version: number
|
||||
* }} params
|
||||
* @return { Promise<{json: any, params}> }
|
||||
*/
|
||||
getFileAnalysis(params) {
|
||||
return window.API.call(
|
||||
`analysis/${params.fileId}/${params.version}/${params.variant}`,
|
||||
{
|
||||
method: 'GET'
|
||||
}
|
||||
).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('FILE:ANALYSIS', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
getVRChatCredits() {
|
||||
return window.API.call(`user/${window.API.currentUser.id}/balance`, {
|
||||
method: 'GET'
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json
|
||||
};
|
||||
window.API.$emit('VRCCREDITS', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {{
|
||||
* location: string,
|
||||
* hardClose: boolean
|
||||
* }} params
|
||||
* @returns {Promise<{json: any, params}>}
|
||||
*/
|
||||
closeInstance(params) {
|
||||
return window.API.call(`instances/${params.location}`, {
|
||||
method: 'DELETE',
|
||||
params: {
|
||||
hardClose: params.hardClose ?? false
|
||||
}
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('INSTANCE:CLOSE', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {{
|
||||
* worldId: string
|
||||
* }} params
|
||||
* @returns {Promise<{json: any, params}>}
|
||||
*/
|
||||
deleteWorldPersistData(params) {
|
||||
return window.API.call(
|
||||
`users/${window.API.currentUser.id}/${params.worldId}/persist`,
|
||||
{
|
||||
method: 'DELETE'
|
||||
}
|
||||
).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('WORLD:PERSIST:DELETE', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {{
|
||||
* worldId: string
|
||||
* }} params
|
||||
* @returns {Promise<{json: any, params}>}
|
||||
*/
|
||||
hasWorldPersistData(params) {
|
||||
return window.API.call(
|
||||
`users/${window.API.currentUser.id}/${params.worldId}/persist/exists`,
|
||||
{
|
||||
method: 'GET'
|
||||
}
|
||||
).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('WORLD:PERSIST:HAS', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
updateBadge(params) {
|
||||
return window.API.call(
|
||||
`users/${window.API.currentUser.id}/badges/${params.badgeId}`,
|
||||
{
|
||||
method: 'PUT',
|
||||
params: {
|
||||
userId: window.API.currentUser.id,
|
||||
badgeId: params.badgeId,
|
||||
hidden: params.hidden,
|
||||
showcased: params.showcased
|
||||
}
|
||||
}
|
||||
).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('BADGE:UPDATE', args);
|
||||
return args;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export default miscReq;
|
||||
56
src/classes/request/playerModeration.js
Normal file
56
src/classes/request/playerModeration.js
Normal file
@@ -0,0 +1,56 @@
|
||||
// #region | API: PlayerModeration
|
||||
|
||||
const playerModerationReq = {
|
||||
getPlayerModerations() {
|
||||
return window.API.call('auth/user/playermoderations', {
|
||||
method: 'GET'
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json
|
||||
};
|
||||
window.API.$emit('PLAYER-MODERATION:LIST', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {{ moderated: string, type: string }} params
|
||||
* @return { Promise<{json: any, params}> }
|
||||
*/
|
||||
// old-way: POST auth/user/blocks {blocked:userId}
|
||||
sendPlayerModeration(params) {
|
||||
return window.API.call('auth/user/playermoderations', {
|
||||
method: 'POST',
|
||||
params
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('PLAYER-MODERATION:SEND', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {{ moderated: string, type: string }} params
|
||||
* @return { Promise<{json: any, params}> }
|
||||
*/
|
||||
// old-way: PUT auth/user/unblocks {blocked:userId}
|
||||
deletePlayerModeration(params) {
|
||||
return window.API.call('auth/user/unplayermoderate', {
|
||||
method: 'PUT',
|
||||
params
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('PLAYER-MODERATION:DELETE', args);
|
||||
return args;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// #endregion
|
||||
export default playerModerationReq;
|
||||
66
src/classes/request/vrcPlusIcon.js
Normal file
66
src/classes/request/vrcPlusIcon.js
Normal file
@@ -0,0 +1,66 @@
|
||||
// #region | App: VRCPlus Icons
|
||||
|
||||
const VRCPlusIconsReq = {
|
||||
getFileList(params) {
|
||||
return window.API.call('files', {
|
||||
method: 'GET',
|
||||
params
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('FILES:LIST', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
deleteFile(fileId) {
|
||||
return window.API.call(`file/${fileId}`, {
|
||||
method: 'DELETE'
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
fileId
|
||||
};
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
uploadVRCPlusIcon(imageData) {
|
||||
const params = {
|
||||
tag: 'icon'
|
||||
};
|
||||
return window.API.call('file/image', {
|
||||
uploadImage: true,
|
||||
matchingDimensions: true,
|
||||
postData: JSON.stringify(params),
|
||||
imageData
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('VRCPLUSICON:ADD', args);
|
||||
return args;
|
||||
});
|
||||
}
|
||||
|
||||
// unused
|
||||
// images.pug line 63
|
||||
// deleteFileVersion(params) {
|
||||
// return window.API.call(`file/${params.fileId}/${params.version}`, {
|
||||
// method: 'DELETE'
|
||||
// }).then((json) => {
|
||||
// const args = {
|
||||
// json,
|
||||
// params
|
||||
// };
|
||||
// return args;
|
||||
// });
|
||||
// }
|
||||
};
|
||||
|
||||
// #endregion
|
||||
|
||||
export default VRCPlusIconsReq;
|
||||
125
src/classes/request/vrcPlusImage.js
Normal file
125
src/classes/request/vrcPlusImage.js
Normal file
@@ -0,0 +1,125 @@
|
||||
const vrcPlusImageReq = {
|
||||
uploadGalleryImage(imageData) {
|
||||
const params = {
|
||||
tag: 'gallery'
|
||||
};
|
||||
return window.API.call('file/image', {
|
||||
uploadImage: true,
|
||||
matchingDimensions: false,
|
||||
postData: JSON.stringify(params),
|
||||
imageData
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('GALLERYIMAGE:ADD', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
uploadSticker(imageData, params) {
|
||||
return window.API.call('file/image', {
|
||||
uploadImage: true,
|
||||
matchingDimensions: true,
|
||||
postData: JSON.stringify(params),
|
||||
imageData
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('STICKER:ADD', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
getPrints(params) {
|
||||
return window.API.call(`prints/user/${window.API.currentUser.id}`, {
|
||||
method: 'GET',
|
||||
params
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('PRINT:LIST', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
deletePrint(printId) {
|
||||
return window.API.call(`prints/${printId}`, {
|
||||
method: 'DELETE'
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
printId
|
||||
};
|
||||
window.API.$emit('PRINT:DELETE', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
uploadPrint(imageData, params) {
|
||||
return window.API.call('prints', {
|
||||
uploadImagePrint: true,
|
||||
postData: JSON.stringify(params),
|
||||
imageData
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('PRINT:ADD', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
getPrint(params) {
|
||||
return window.API.call(`prints/${params.printId}`, {
|
||||
method: 'GET'
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('PRINT', args);
|
||||
return args;
|
||||
});
|
||||
},
|
||||
|
||||
uploadEmoji(imageData, params) {
|
||||
return window.API.call('file/image', {
|
||||
uploadImage: true,
|
||||
matchingDimensions: true,
|
||||
postData: JSON.stringify(params),
|
||||
imageData
|
||||
}).then((json) => {
|
||||
const args = {
|
||||
json,
|
||||
params
|
||||
};
|
||||
window.API.$emit('EMOJI:ADD', args);
|
||||
return args;
|
||||
});
|
||||
}
|
||||
|
||||
// ----------- no place uses this function ------------
|
||||
|
||||
// editPrint(params) {
|
||||
// return window.API.call(`prints/${params.printId}`, {
|
||||
// method: 'POST',
|
||||
// params
|
||||
// }).then((json) => {
|
||||
// const args = {
|
||||
// json,
|
||||
// params
|
||||
// };
|
||||
// window.API.$emit('PRINT:EDIT', args);
|
||||
// return args;
|
||||
// });
|
||||
// },
|
||||
};
|
||||
|
||||
export default vrcPlusImageReq;
|
||||
@@ -205,7 +205,7 @@ export default class extends baseClass {
|
||||
'<el-tooltip v-if="isValidInstance" placement="bottom">' +
|
||||
'<div slot="content">' +
|
||||
'<template v-if="isClosed"><span>Closed At: {{ closedAt | formatDate(\'long\') }}</span></br></template>' +
|
||||
'<template v-if="canCloseInstance"><el-button :disabled="isClosed" size="mini" type="primary" @click="$app.closeInstance(location)">{{ $t("dialog.user.info.close_instance") }}</el-button></br></br></template>' +
|
||||
'<template v-if="canCloseInstance"><el-button :disabled="isClosed" size="mini" type="primary" @click="$root.closeInstance(location)">{{ $t("dialog.user.info.close_instance") }}</el-button></br></br></template>' +
|
||||
'<span><span style="color:#409eff">PC: </span>{{ platforms.standalonewindows }}</span></br>' +
|
||||
'<span><span style="color:#67c23a">Android: </span>{{ platforms.android }}</span></br>' +
|
||||
'<span>{{ $t("dialog.user.info.instance_game_version") }} {{ gameServerVersion }}</span></br>' +
|
||||
|
||||
@@ -129,6 +129,8 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { favoriteRequest } from '../../classes/request';
|
||||
|
||||
export default {
|
||||
name: 'FavoritesWorldItem',
|
||||
inject: ['API'],
|
||||
@@ -170,18 +172,20 @@
|
||||
}
|
||||
},
|
||||
moveFavorite(ref, group, type) {
|
||||
this.API.deleteFavorite({
|
||||
objectId: ref.id
|
||||
}).then(() => {
|
||||
this.API.addFavorite({
|
||||
type,
|
||||
favoriteId: ref.id,
|
||||
tags: group.name
|
||||
favoriteRequest
|
||||
.deleteFavorite({
|
||||
objectId: ref.id
|
||||
})
|
||||
.then(() => {
|
||||
favoriteRequest.addFavorite({
|
||||
type,
|
||||
favoriteId: ref.id,
|
||||
tags: group.name
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
deleteFavorite(objectId) {
|
||||
this.API.deleteFavorite({
|
||||
favoriteRequest.deleteFavorite({
|
||||
objectId
|
||||
});
|
||||
// FIXME: 메시지 수정
|
||||
@@ -200,19 +204,21 @@
|
||||
},
|
||||
addFavoriteWorld(ref, group, message) {
|
||||
// wait API splitting PR Merged
|
||||
return this.API.addFavorite({
|
||||
type: 'world',
|
||||
favoriteId: ref.id,
|
||||
tags: group.name
|
||||
}).then((args) => {
|
||||
if (message) {
|
||||
this.$message({
|
||||
message: 'World added to favorites',
|
||||
type: 'success'
|
||||
});
|
||||
}
|
||||
return args;
|
||||
});
|
||||
return favoriteRequest
|
||||
.addFavorite({
|
||||
type: 'world',
|
||||
favoriteId: ref.id,
|
||||
tags: group.name
|
||||
})
|
||||
.then((args) => {
|
||||
if (message) {
|
||||
this.$message({
|
||||
message: 'World added to favorites',
|
||||
type: 'success'
|
||||
});
|
||||
}
|
||||
return args;
|
||||
});
|
||||
},
|
||||
showFavoriteDialog(favoriteId) {
|
||||
this.$emit('show-favorite-dialog', 'world', favoriteId);
|
||||
|
||||
@@ -224,6 +224,8 @@
|
||||
|
||||
<script>
|
||||
import FavoritesWorldItem from './FavoritesWorldItem.vue';
|
||||
import { favoriteRequest } from '../../classes/request';
|
||||
|
||||
export default {
|
||||
name: 'FavoritesWorldTab',
|
||||
components: {
|
||||
@@ -296,7 +298,7 @@
|
||||
group: name,
|
||||
visibility
|
||||
};
|
||||
this.API.saveFavoriteGroup(params).then((args) => {
|
||||
favoriteRequest.saveFavoriteGroup(params).then((args) => {
|
||||
this.$message({
|
||||
message: 'Group visibility changed',
|
||||
type: 'success'
|
||||
|
||||
@@ -202,7 +202,6 @@
|
||||
@click="deleteVRChatCache(worldDialog.ref)" />
|
||||
</el-tooltip>
|
||||
<el-tooltip
|
||||
v-if="worldDialog.isFavorite"
|
||||
placement="top"
|
||||
:content="$t('dialog.world.actions.favorites_tooltip')"
|
||||
:disabled="hideTooltips">
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
:filters="filters"
|
||||
:tableProps="tableProps"
|
||||
:paginationProps="paginationProps"
|
||||
v-loading="API.isPlayerModerationsLoading"
|
||||
>
|
||||
v-loading="API.isPlayerModerationsLoading">
|
||||
<template slot="tool">
|
||||
<div class="tool-slot">
|
||||
<el-select
|
||||
@@ -16,32 +15,27 @@
|
||||
multiple
|
||||
clearable
|
||||
style="flex: 1"
|
||||
:placeholder="$t('view.moderation.filter_placeholder')"
|
||||
>
|
||||
:placeholder="$t('view.moderation.filter_placeholder')">
|
||||
<el-option
|
||||
v-for="item in moderationTypes"
|
||||
:key="item"
|
||||
:label="$t('view.moderation.filters.' + item)"
|
||||
:value="item"
|
||||
/>
|
||||
:value="item" />
|
||||
</el-select>
|
||||
<el-input
|
||||
v-model="filters[1].value"
|
||||
:placeholder="$t('view.moderation.search_placeholder')"
|
||||
class="filter-input"
|
||||
/>
|
||||
class="filter-input" />
|
||||
<el-tooltip
|
||||
placement="bottom"
|
||||
:content="$t('view.moderation.refresh_tooltip')"
|
||||
:disabled="hideTooltips"
|
||||
>
|
||||
:disabled="hideTooltips">
|
||||
<el-button
|
||||
type="default"
|
||||
:loading="API.isPlayerModerationsLoading"
|
||||
@click="API.refreshPlayerModerations()"
|
||||
icon="el-icon-refresh"
|
||||
circle
|
||||
/>
|
||||
circle />
|
||||
</el-tooltip>
|
||||
</div>
|
||||
</template>
|
||||
@@ -65,8 +59,7 @@
|
||||
<span
|
||||
class="x-link"
|
||||
v-text="scope.row.sourceDisplayName"
|
||||
@click="showUserDialog(scope.row.sourceUserId)"
|
||||
></span>
|
||||
@click="showUserDialog(scope.row.sourceUserId)"></span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('table.moderation.target')" prop="targetDisplayName">
|
||||
@@ -74,8 +67,7 @@
|
||||
<span
|
||||
class="x-link"
|
||||
v-text="scope.row.targetDisplayName"
|
||||
@click="showUserDialog(scope.row.targetUserId)"
|
||||
></span>
|
||||
@click="showUserDialog(scope.row.targetUserId)"></span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('table.moderation.action')" width="80" align="right">
|
||||
@@ -87,15 +79,13 @@
|
||||
type="text"
|
||||
icon="el-icon-close"
|
||||
size="mini"
|
||||
@click="deletePlayerModeration(scope.row)"
|
||||
></el-button>
|
||||
@click="deletePlayerModeration(scope.row)"></el-button>
|
||||
<el-button
|
||||
v-else
|
||||
type="text"
|
||||
icon="el-icon-close"
|
||||
size="mini"
|
||||
@click="deletePlayerModerationPrompt(scope.row)"
|
||||
></el-button>
|
||||
@click="deletePlayerModerationPrompt(scope.row)"></el-button>
|
||||
</template>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@@ -104,6 +94,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { playerModerationRequest } from '../../classes/request/index.js';
|
||||
import configRepository from '../../repository/config.js';
|
||||
|
||||
export default {
|
||||
@@ -163,7 +154,7 @@
|
||||
configRepository.setString('VRCX_playerModerationTableFilters', JSON.stringify(this.filters[0].value));
|
||||
},
|
||||
deletePlayerModeration(row) {
|
||||
this.API.deletePlayerModeration({
|
||||
playerModerationRequest.deletePlayerModeration({
|
||||
moderated: row.targetUserId,
|
||||
type: row.type
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user