Export own avatars as list

This commit is contained in:
Natsumi
2021-05-20 16:14:19 +12:00
parent 69f6660c99
commit 857f2f4814
2 changed files with 58 additions and 0 deletions

View File

@@ -4647,6 +4647,59 @@ speechSynthesis.getVoices();
this.exportFriendsListDialog = true;
};
$app.data.exportAvatarsListDialog = false;
$app.data.exportAvatarsListContent = '';
$app.methods.showExportAvatarsListDialog = function () {
for (var ref of API.cachedAvatars.values()) {
if (ref.authorId === API.currentUser.id) {
API.cachedAvatars.delete(ref.id);
}
}
var params = {
n: 50,
offset: 0,
sort: 'updated',
order: 'descending',
releaseStatus: 'all',
user: 'me',
};
var map = new Map();
API.bulk({
fn: 'getAvatars',
N: -1,
params,
handle: (args) => {
for (var json of args.json) {
var $ref = API.cachedAvatars.get(json.id);
if (typeof $ref !== 'undefined') {
map.set($ref.id, $ref);
}
}
},
done: () => {
var avatars = Array.from(map.values());
if (Array.isArray(avatars) === false) {
return;
}
var lines = [
'AvatarID,AvatarName'
];
var _ = function (str) {
if (/[\x00-\x1f,"]/.test(str) === true) {
str = `"${str.replace(/"/g, '""')}"`;
}
return str;
};
for (var avatar of avatars) {
lines.push(`${_(avatar.id)},${_(avatar.name)}`);
}
this.exportAvatarsListContent = lines.join('\n');
this.exportAvatarsListDialog = true;
}
});
};
API.$on('USER:2FA', function () {
$app.promptTOTP();
});

View File

@@ -481,6 +481,7 @@ html
div(style="margin-top:10px")
el-button(size="small" icon="el-icon-switch-button" @click="logout()") Logout
el-button(size="small" icon="el-icon-printer" @click="showExportFriendsListDialog()") Export Friends List
el-button(size="small" icon="el-icon-user" @click="showExportAvatarsListDialog()") Export Own Avatars
el-button(size="small" icon="el-icon-chat-dot-round" @click="showDiscordNamesDialog()") Discord Names
div.options-container
span.header Game Info
@@ -1581,6 +1582,10 @@ html
el-dialog.x-dialog(:visible.sync="exportFriendsListDialog" title="Export Friends List" width="650px")
el-input(type="textarea" v-model="exportFriendsListContent" size="mini" rows="15" resize="none" readonly style="margin-top:15px" @click.native="$event.target.tagName === 'TEXTAREA' && $event.target.select()")
//- dialog: export avatars list
el-dialog.x-dialog(:visible.sync="exportAvatarsListDialog" title="Export Own Avatars" width="650px")
el-input(type="textarea" v-model="exportAvatarsListContent" size="mini" rows="15" resize="none" readonly style="margin-top:15px" @click.native="$event.target.tagName === 'TEXTAREA' && $event.target.select()")
//- dialog: Discord username list
el-dialog.x-dialog(:visible.sync="discordNamesDialogVisible" title="Discord Names" width="650px")
div(style='font-size:12px;')