This commit is contained in:
syuilo 2018-12-03 20:08:18 +09:00
parent 396a2b9bfc
commit aae394e34e
5 changed files with 25 additions and 0 deletions

View file

@ -497,6 +497,7 @@ common/views/components/profile-editor.vue:
account: "アカウント" account: "アカウント"
location: "場所" location: "場所"
description: "自己紹介" description: "自己紹介"
language: "言語"
birthday: "誕生日" birthday: "誕生日"
avatar: "アイコン" avatar: "アイコン"
banner: "バナー" banner: "バナー"

View file

@ -156,6 +156,7 @@
"koa-send": "5.0.0", "koa-send": "5.0.0",
"koa-slow": "2.1.0", "koa-slow": "2.1.0",
"koa-views": "6.1.4", "koa-views": "6.1.4",
"langmap": "0.0.16",
"loader-utils": "1.1.0", "loader-utils": "1.1.0",
"minio": "7.0.1", "minio": "7.0.1",
"mkdirp": "0.5.1", "mkdirp": "0.5.1",

View file

@ -32,6 +32,12 @@
<span>{{ $t('description') }}</span> <span>{{ $t('description') }}</span>
</ui-textarea> </ui-textarea>
<ui-select v-model="lang">
<span slot="label">{{ $t('language') }}</span>
<span slot="icon"><fa icon="language"/></span>
<option v-for="lang in unique(Object.values(langmap).map(x => x.nativeName)).map(name => Object.keys(langmap).find(k => langmap[k].nativeName == name))" :value="lang" :key="lang">{{ langmap[lang].nativeName }}</option>
</ui-select>
<ui-input type="file" @change="onAvatarChange"> <ui-input type="file" @change="onAvatarChange">
<span>{{ $t('avatar') }}</span> <span>{{ $t('avatar') }}</span>
<span slot="icon"><fa icon="image"/></span> <span slot="icon"><fa icon="image"/></span>
@ -87,12 +93,16 @@ import Vue from 'vue';
import i18n from '../../../i18n'; import i18n from '../../../i18n';
import { apiUrl, host } from '../../../config'; import { apiUrl, host } from '../../../config';
import { toUnicode } from 'punycode'; import { toUnicode } from 'punycode';
import langmap from 'langmap';
import { unique } from '../../../../../prelude/array';
export default Vue.extend({ export default Vue.extend({
i18n: i18n('common/views/components/profile-editor.vue'), i18n: i18n('common/views/components/profile-editor.vue'),
data() { data() {
return { return {
unique,
langmap,
host: toUnicode(host), host: toUnicode(host),
enableEmail: false, enableEmail: false,
email: null, email: null,
@ -100,6 +110,7 @@ export default Vue.extend({
username: null, username: null,
location: null, location: null,
description: null, description: null,
lang: null,
birthday: null, birthday: null,
avatarId: null, avatarId: null,
bannerId: null, bannerId: null,
@ -137,6 +148,7 @@ export default Vue.extend({
this.username = this.$store.state.i.username; this.username = this.$store.state.i.username;
this.location = this.$store.state.i.profile.location; this.location = this.$store.state.i.profile.location;
this.description = this.$store.state.i.description; this.description = this.$store.state.i.description;
this.lang = this.$store.state.i.lang;
this.birthday = this.$store.state.i.profile.birthday; this.birthday = this.$store.state.i.profile.birthday;
this.avatarId = this.$store.state.i.avatarId; this.avatarId = this.$store.state.i.avatarId;
this.bannerId = this.$store.state.i.bannerId; this.bannerId = this.$store.state.i.bannerId;
@ -198,6 +210,7 @@ export default Vue.extend({
name: this.name || null, name: this.name || null,
location: this.location || null, location: this.location || null,
description: this.description || null, description: this.description || null,
lang: this.lang,
birthday: this.birthday || null, birthday: this.birthday || null,
avatarId: this.avatarId || undefined, avatarId: this.avatarId || undefined,
bannerId: this.bannerId || undefined, bannerId: this.bannerId || undefined,

View file

@ -44,6 +44,7 @@ type IUserBase = {
wallpaperUrl?: string; wallpaperUrl?: string;
data: any; data: any;
description: string; description: string;
lang?: string;
pinnedNoteIds: mongo.ObjectID[]; pinnedNoteIds: mongo.ObjectID[];
/** /**

View file

@ -6,6 +6,7 @@ import acceptAllFollowRequests from '../../../../services/following/requests/acc
import { publishToFollowers } from '../../../../services/i/update'; import { publishToFollowers } from '../../../../services/i/update';
import define from '../../define'; import define from '../../define';
import getDriveFileUrl from '../../../../misc/get-drive-file-url'; import getDriveFileUrl from '../../../../misc/get-drive-file-url';
const langmap = require('langmap');
export const meta = { export const meta = {
desc: { desc: {
@ -32,6 +33,13 @@ export const meta = {
} }
}, },
lang: {
validator: $.str.optional.nullable.or(Object.keys(langmap)),
desc: {
'ja-JP': '言語'
}
},
location: { location: {
validator: $.str.optional.nullable.pipe(isValidLocation), validator: $.str.optional.nullable.pipe(isValidLocation),
desc: { desc: {
@ -121,6 +129,7 @@ export default define(meta, (ps, user, app) => new Promise(async (res, rej) => {
if (ps.name !== undefined) updates.name = ps.name; if (ps.name !== undefined) updates.name = ps.name;
if (ps.description !== undefined) updates.description = ps.description; if (ps.description !== undefined) updates.description = ps.description;
if (ps.lang !== undefined) updates.lang = ps.lang;
if (ps.location !== undefined) updates['profile.location'] = ps.location; if (ps.location !== undefined) updates['profile.location'] = ps.location;
if (ps.birthday !== undefined) updates['profile.birthday'] = ps.birthday; if (ps.birthday !== undefined) updates['profile.birthday'] = ps.birthday;
if (ps.avatarId !== undefined) updates.avatarId = ps.avatarId; if (ps.avatarId !== undefined) updates.avatarId = ps.avatarId;