cleanup code

This commit is contained in:
pypy
2020-01-12 19:13:42 +09:00
parent fa62bbdc20
commit b7cd2d8fee
3 changed files with 6791 additions and 6885 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -310,7 +310,7 @@
<!-- favorite -->
<div v-show="$refs.menu && $refs.menu.activeIndex === 'favorite'" class="x-container">
<el-button type="default" :loading="API.isFavoriteLoading" @click="API.refreshFavorite()" size="small" icon="el-icon-refresh" circle style="position:relative;float:right;z-index:1"></el-button>
<el-button type="default" :loading="API.isFavoriteLoading" @click="API.refreshFavorites()" size="small" icon="el-icon-refresh" circle style="position:relative;float:right;z-index:1"></el-button>
<el-tabs type="card" v-loading="API.isFavoriteLoading">
<el-tab-pane label="Friend">
<el-collapse style="border:0">
@@ -445,14 +445,14 @@
<!-- moderation -->
<div v-show="$refs.menu && $refs.menu.activeIndex === 'moderation'" class="x-container">
<data-tables v-bind="playerModerationTable" v-loading="API.isPlayerModerationLoading">
<data-tables v-bind="playerModerationTable" v-loading="API.isPlayerModerationsLoading">
<template #tool>
<div style="margin:0 0 10px;display:flex;align-items:center">
<el-select v-model="playerModerationTable.filters[0].value" multiple clearable collapse-tags style="flex:1" placeholder="Filter">
<el-option v-once v-for="type in ['block', 'mute', 'unmute', 'hideAvatar', 'showAvatar']" :key="type" :label="type" :value="type"></el-option>
</el-select>
<el-input v-model="playerModerationTable.filters[1].value" placeholder="Search" style="flex:none;width:150px;margin:0 10px"></el-input>
<el-button type="default" :loading="API.isPlayerModerationLoading" @click="API.refreshPlayerModeration()" icon="el-icon-refresh" circle style="flex:none"></el-button>
<el-button type="default" :loading="API.isPlayerModerationsLoading" @click="API.refreshPlayerModerations()" icon="el-icon-refresh" circle style="flex:none"></el-button>
</div>
</template>
<el-table-column label="Date" prop="created" sortable="custom" width="120">
@@ -485,7 +485,7 @@
</div>
<!-- notification -->
<div v-show="$refs.menu && $refs.menu.activeIndex === 'notification'" v-loading="API.isNotificationLoading" class="x-container">
<div v-show="$refs.menu && $refs.menu.activeIndex === 'notification'" v-loading="API.isNotificationsLoading" class="x-container">
<data-tables v-bind="notificationTable">
<template #tool>
<div style="margin:0 0 10px;display:flex;align-items:center">
@@ -493,7 +493,7 @@
<el-option v-once v-for="type in ['requestInvite', 'invite', 'friendRequest', 'message']" :key="type" :label="type" :value="type"></el-option>
</el-select>
<el-input v-model="notificationTable.filters[1].value" placeholder="Search" style="flex:none;width:150px;margin:0 10px"></el-input>
<el-button type="default" :loading="API.isNotificationLoading" @click="API.refreshNotification()" icon="el-icon-refresh" circle style="flex:none"></el-button>
<el-button type="default" :loading="API.isNotificationsLoading" @click="API.refreshNotifications()" icon="el-icon-refresh" circle style="flex:none"></el-button>
</div>
</template>
<el-table-column label="Date" prop="created_at" sortable="custom" width="120">
@@ -697,19 +697,19 @@
<span style="font-weight:bold">Friends Sort Option</span>
<div style="font-size:12px;margin-top:5px">
<span style="display:inline-block;min-width:150px">VIP</span>
<el-switch v-model="orderFriendGroup0" inactive-text="by name" active-text="by state"></el-switch>
<el-switch v-model="orderFriendsGroup0" inactive-text="by name" active-text="by state"></el-switch>
</div>
<div style="font-size:12px;margin-top:5px">
<span style="display:inline-block;min-width:150px">ONLINE</span>
<el-switch v-model="orderFriendGroup1" inactive-text="by name" active-text="by state"></el-switch>
<el-switch v-model="orderFriendsGroup1" inactive-text="by name" active-text="by state"></el-switch>
</div>
<div style="font-size:12px;margin-top:5px">
<span style="display:inline-block;min-width:150px">ACTIVE</span>
<el-switch v-model="orderFriendGroup2" inactive-text="by name" active-text="by state"></el-switch>
<el-switch v-model="orderFriendsGroup2" inactive-text="by name" active-text="by state"></el-switch>
</div>
<div style="font-size:12px;margin-top:5px">
<span style="display:inline-block;min-width:150px">OFFLINE</span>
<el-switch v-model="orderFriendGroup3" inactive-text="by name" active-text="by state"></el-switch>
<el-switch v-model="orderFriendsGroup3" inactive-text="by name" active-text="by state"></el-switch>
</div>
</div>
<div style="margin-top:30px">
@@ -780,12 +780,12 @@
</el-option>
</el-select>
<div class="x-friend-list" style="padding-bottom:10px">
<div v-show="friendGroup0.length" class="x-friend-group">
<i class="el-icon-arrow-right" :class="{ rotate: isFriendGroup0 }"></i>
<span @click="isFriendGroup0 = !isFriendGroup0" class="x-link" style="margin-left:5px">VIP&horbar;{{ friendGroup0.length }}</span>
<div v-show="friendsGroup0.length" class="x-friend-group">
<i class="el-icon-arrow-right" :class="{ rotate: isFriendsGroup0 }"></i>
<span @click="isFriendsGroup0 = !isFriendsGroup0" class="x-link" style="margin-left:5px">VIP&horbar;{{ friendsGroup0.length }}</span>
</div>
<div v-show="isFriendGroup0">
<div v-for="friend in friendGroup0" :key="friend.id" @click="showUserDialog(friend.id)" class="x-friend-item">
<div v-show="isFriendsGroup0">
<div v-for="friend in friendsGroup0" :key="friend.id" @click="showUserDialog(friend.id)" class="x-friend-item">
<template v-if="friend.ref">
<div class="avatar" :class="userStatusClass(friend.ref)">
<img v-lazy="friend.ref.currentAvatarThumbnailImageUrl">
@@ -802,12 +802,12 @@
</template>
</div>
</div>
<div v-show="friendGroup1.length" class="x-friend-group">
<i class="el-icon-arrow-right" :class="{ rotate: isFriendGroup1 }"></i>
<span @click="isFriendGroup1 = !isFriendGroup1" class="x-link" style="margin-left:5px">ONLINE&horbar;{{ friendGroup1.length }}</span>
<div v-show="friendsGroup1.length" class="x-friend-group">
<i class="el-icon-arrow-right" :class="{ rotate: isFriendsGroup1 }"></i>
<span @click="isFriendsGroup1 = !isFriendsGroup1" class="x-link" style="margin-left:5px">ONLINE&horbar;{{ friendsGroup1.length }}</span>
</div>
<div v-show="isFriendGroup1">
<div v-for="friend in friendGroup1" :key="friend.id" @click="showUserDialog(friend.id)" class="x-friend-item">
<div v-show="isFriendsGroup1">
<div v-for="friend in friendsGroup1" :key="friend.id" @click="showUserDialog(friend.id)" class="x-friend-item">
<template v-if="friend.ref">
<div class="avatar" :class="userStatusClass(friend.ref)">
<img v-lazy="friend.ref.currentAvatarThumbnailImageUrl">
@@ -824,12 +824,12 @@
</template>
</div>
</div>
<div v-show="friendGroup2.length" class="x-friend-group">
<i class="el-icon-arrow-right" :class="{ rotate: isFriendGroup2 }"></i>
<span @click="isFriendGroup2 = !isFriendGroup2" class="x-link" style="margin-left:5px">ACTIVE&horbar;{{ friendGroup2.length }}</span>
<div v-show="friendsGroup2.length" class="x-friend-group">
<i class="el-icon-arrow-right" :class="{ rotate: isFriendsGroup2 }"></i>
<span @click="isFriendsGroup2 = !isFriendsGroup2" class="x-link" style="margin-left:5px">ACTIVE&horbar;{{ friendsGroup2.length }}</span>
</div>
<div v-show="isFriendGroup2">
<div v-for="friend in friendGroup2" :key="friend.id" @click="showUserDialog(friend.id)" class="x-friend-item">
<div v-show="isFriendsGroup2">
<div v-for="friend in friendsGroup2" :key="friend.id" @click="showUserDialog(friend.id)" class="x-friend-item">
<template v-if="friend.ref">
<div class="avatar">
<img v-lazy="friend.ref.currentAvatarThumbnailImageUrl">
@@ -846,12 +846,12 @@
</template>
</div>
</div>
<div v-show="friendGroup3.length" class="x-friend-group">
<i class="el-icon-arrow-right" :class="{ rotate: isFriendGroup3 }"></i>
<span @click="isFriendGroup3 = !isFriendGroup3" class="x-link" style="margin-left:5px">OFFLINE&horbar;{{ friendGroup3.length }}</span>
<div v-show="friendsGroup3.length" class="x-friend-group">
<i class="el-icon-arrow-right" :class="{ rotate: isFriendsGroup3 }"></i>
<span @click="isFriendsGroup3 = !isFriendsGroup3" class="x-link" style="margin-left:5px">OFFLINE&horbar;{{ friendsGroup3.length }}</span>
</div>
<div v-show="isFriendGroup3">
<div v-for="friend in friendGroup3" :key="friend.id" @click="showUserDialog(friend.id)" class="x-friend-item">
<div v-show="isFriendsGroup3">
<div v-for="friend in friendsGroup3" :key="friend.id" @click="showUserDialog(friend.id)" class="x-friend-item">
<template v-if="friend.ref">
<div class="avatar">
<img v-lazy="friend.ref.currentAvatarThumbnailImageUrl">
@@ -1303,8 +1303,8 @@
</div>
</el-option>
</el-option-group>
<el-option-group v-if="friendGroup0.length" label="VIP">
<el-option v-for="friend in friendGroup0" :key="friend.id" :label="friend.name" :value="friend.id" class="x-friend-item" style="height:auto">
<el-option-group v-if="friendsGroup0.length" label="VIP">
<el-option v-for="friend in friendsGroup0" :key="friend.id" :label="friend.name" :value="friend.id" class="x-friend-item" style="height:auto">
<template v-if="friend.ref">
<div class="avatar" :class="userStatusClass(friend.ref)">
<img v-lazy="friend.ref.currentAvatarThumbnailImageUrl">
@@ -1316,8 +1316,8 @@
<span v-else v-text="friend.id"></span>
</el-option>
</el-option-group>
<el-option-group v-if="friendGroup1.length" label="ONLINE">
<el-option v-for="friend in friendGroup1" :key="friend.id" :label="friend.name" :value="friend.id" class="x-friend-item" style="height:auto">
<el-option-group v-if="friendsGroup1.length" label="ONLINE">
<el-option v-for="friend in friendsGroup1" :key="friend.id" :label="friend.name" :value="friend.id" class="x-friend-item" style="height:auto">
<template v-if="friend.ref">
<div class="avatar" :class="userStatusClass(friend.ref)">
<img v-lazy="friend.ref.currentAvatarThumbnailImageUrl">
@@ -1329,8 +1329,8 @@
<span v-else v-text="friend.id"></span>
</el-option>
</el-option-group>
<el-option-group v-if="friendGroup2.length" label="ACTIVE">
<el-option v-for="friend in friendGroup2" :key="friend.id" :label="friend.name" :value="friend.id" class="x-friend-item" style="height:auto">
<el-option-group v-if="friendsGroup2.length" label="ACTIVE">
<el-option v-for="friend in friendsGroup2" :key="friend.id" :label="friend.name" :value="friend.id" class="x-friend-item" style="height:auto">
<template v-if="friend.ref">
<div class="avatar">
<img v-lazy="friend.ref.currentAvatarThumbnailImageUrl">

View File

@@ -1,16 +1,15 @@
// Copyright(c) 2019 pypy. All rights reserved.
// Copyright(c) 2019-2020 pypy and individual contributors.
// All rights reserved.
//
// This work is licensed under the terms of the MIT license.
// For a copy, see <https://opensource.org/licenses/MIT>.
if (window.CefSharp) {
Promise.all([
CefSharp.BindObjectAsync('VRCX'),
CefSharp.BindObjectAsync('VRCXStorage'),
CefSharp.BindObjectAsync('SQLite')
]).catch(function () {
location = 'https://github.com/pypy-vrc/vrcx';
}).then(function () {
CefSharp.BindObjectAsync(
'VRCX',
'VRCXStorage',
'SQLite'
).then(function () {
var isObject = (arg) => arg === Object(arg);
VRCXStorage.GetBool = function (key) {
return this.Get(key) === 'true';
@@ -40,13 +39,10 @@ if (window.CefSharp) {
VRCXStorage.GetArray = function (key) {
try {
var json = this.Get(key);
if (json) {
var array = JSON.parse(json);
var array = JSON.parse(this.Get(key));
if (Array.isArray(array)) {
return array;
}
}
} catch (err) {
console.error(err);
}
@@ -59,9 +55,9 @@ if (window.CefSharp) {
VRCXStorage.GetObject = function (key) {
try {
var json = this.Get(key);
if (json) {
return JSON.parse(json);
var object = JSON.parse(this.Get(key));
if (isObject(object)) {
return object;
}
} catch (err) {
console.error(err);
@@ -83,8 +79,6 @@ if (window.CefSharp) {
timeout: 6000
});
var isObject = (arg) => arg === Object(arg);
var escapeTag = (s) => String(s).replace(/["&'<>]/gu, (c) => `&#${c.charCodeAt(0)};`);
Vue.filter('escapeTag', escapeTag);
@@ -173,23 +167,23 @@ if (window.CefSharp) {
}
};
API.$on = function (name, fn) {
API.$on = function (name, handler) {
var handlers = this.eventHandlers.get(name);
if (handlers === undefined) {
handlers = [];
this.eventHandlers.set(name, handlers);
}
handlers.push(fn);
handlers.push(handler);
};
API.$off = function (name, fn) {
API.$off = function (name, handler) {
var handlers = this.eventHandlers.get(name);
if (handlers === undefined) {
return;
}
var { length } = handlers;
for (var i = 0; i < length; ++i) {
if (handlers[i] === fn) {
if (handlers[i] === handler) {
if (length > 1) {
handlers.splice(i, 1);
} else {
@@ -249,8 +243,7 @@ if (window.CefSharp) {
}).then((json) => {
if (isObject(json) === false) {
this.$throw(0, 'Invalid JSON response');
}
if (res.ok) {
} else if (res.ok) {
if (isObject(json.success)) {
new Noty({
type: 'success',
@@ -361,10 +354,10 @@ if (window.CefSharp) {
var text = [];
if (code > 0) {
var status = this.statusCodes[code];
if (status) {
text.push(`${code} ${status}`);
} else {
if (status === undefined) {
text.push(`${code}`);
} else {
text.push(`${code} ${status}`);
}
}
if (error !== undefined) {
@@ -388,6 +381,15 @@ if (window.CefSharp) {
args.ref = this.applyConfig(args.json);
});
API.applyConfig = function (json) {
var ref = {
clientApiKey: '',
...json
};
this.cachedConfig = ref;
return ref;
};
API.getConfig = function () {
return this.call('config', {
method: 'GET'
@@ -401,15 +403,6 @@ if (window.CefSharp) {
});
};
API.applyConfig = function (json) {
var ref = {
clientApiKey: '',
...json
};
this.cachedConfig = ref;
return ref;
};
// API: Location
API.parseLocation = function (tag) {
@@ -546,25 +539,6 @@ if (window.CefSharp) {
args.ref = this.applyWorld(args.json);
});
/*
params: {
worldId: string
}
*/
API.getWorld = function (params) {
return this.call(`worlds/${params.worldId}`, {
method: 'GET'
}).then((json) => {
var args = {
ref: null,
json,
params
};
this.$emit('WORLD', args);
return args;
});
};
API.applyWorld = function (json) {
var ref = this.cachedWorlds.get(json.id);
if (ref === undefined) {
@@ -608,12 +582,29 @@ if (window.CefSharp) {
} else {
Object.assign(ref, json);
}
if (Array.isArray(ref.tags)) {
ref.$isLabs = ref.tags.includes('system_labs');
}
return ref;
};
/*
params: {
worldId: string
}
*/
API.getWorld = function (params) {
return this.call(`worlds/${params.worldId}`, {
method: 'GET'
}).then((json) => {
var args = {
ref: null,
json,
params
};
this.$emit('WORLD', args);
return args;
});
};
var $app = {
data: {
API,
@@ -765,7 +756,4 @@ if (window.CefSharp) {
$app = new Vue($app);
window.$app = $app;
});
} else {
location = 'https://github.com/pypy-vrc/vrcx';
}
});