Add more ESLint rules and format

This commit is contained in:
Pig Fang 2018-08-05 09:47:29 +08:00
parent 3c2aa37967
commit 33de864504
5 changed files with 161 additions and 49 deletions

View File

@ -38,6 +38,23 @@ rules:
prefer-const: warn
no-var: error
eqeqeq: error
vue/html-closing-bracket-newline:
- error
- singleline: never
multiline: always
vue/html-indent:
- error
- 4
vue/max-attributes-per-line:
- error
- singleline: 3
multiline: 1
vue/mustache-interpolation-spacing: error
vue/no-multi-spaces: error
vue/v-bind-style: error
vue/v-on-style: error
vue/html-quotes: error
vue/order-in-components: warn
globals:
blessing: false

View File

@ -89,6 +89,20 @@ export default {
}
}
},
watch: {
skin(url) {
this.viewer.skinUrl = url || SkinSteve;
},
cape(url) {
this.viewer.capeUrl = url;
}
},
mounted() {
this.initPreviewer();
},
beforeDestroy() {
this.viewer.dispose();
},
methods: {
initPreviewer() {
this.viewer = new skinview3d.SkinViewer({
@ -128,20 +142,6 @@ export default {
this.viewer.camera.position.z = 70;
}
},
watch: {
skin(url) {
this.viewer.skinUrl = url || SkinSteve;
},
cape(url) {
this.viewer.capeUrl = url;
}
},
mounted() {
this.initPreviewer();
},
beforeDestroy() {
this.viewer.dispose();
}
};
</script>

View File

@ -8,23 +8,46 @@
<!-- Tabs within a box -->
<ul class="nav nav-tabs">
<li :class="{ active: category === 'skin' }">
<a href="#" @click="switchCategory" v-t="'general.skin'" class="category-switch" data-toggle="tab" />
<a
href="#"
@click="switchCategory"
v-t="'general.skin'"
class="category-switch"
data-toggle="tab"
/>
</li>
<li :class="{ active: category === 'cape' }">
<a href="#" @click="switchCategory" v-t="'general.cape'" class="category-switch" data-toggle="tab" />
<a
href="#"
@click="switchCategory"
v-t="'general.cape'"
class="category-switch"
data-toggle="tab"
/>
</li>
<li class="pull-right" style="padding: 7px;">
<div class="has-feedback pull-right">
<div class="user-search-form">
<input type="text" v-model="query" @input="search" class="form-control input-sm" :placeholder="$t('user.typeToSearch')">
<input
type="text"
v-model="query"
@input="search"
class="form-control input-sm"
:placeholder="$t('user.typeToSearch')"
>
<span class="glyphicon glyphicon-search form-control-feedback"></span>
</div>
</div>
</li>
</ul>
<div class="tab-content no-padding">
<div v-if="category === 'skin'" class="tab-pane box-body" :class="{ active: category === 'skin' }" id="skin-category">
<div
v-if="category === 'skin'"
class="tab-pane box-body"
:class="{ active: category === 'skin' }"
id="skin-category"
>
<div v-if="skinItems.length === 0" class="empty-msg">
<div v-if="query !== ''" v-t="'general.noResult'"></div>
<div v-else v-t="{ path: 'user.emptyClosetMsg', args: { url: linkToSkin } }" />
@ -42,7 +65,12 @@
></closet-item>
</div>
</div>
<div v-else class="tab-pane box-body" :class="{ active: category === 'cape' }" id="cape-category">
<div
v-else
class="tab-pane box-body"
:class="{ active: category === 'cape' }"
id="cape-category"
>
<div v-if="capeItems.length === 0" class="empty-msg">
<div v-if="query !== ''" v-t="'general.noResult'"></div>
<div v-else v-t="{ path: 'user.emptyClosetMsg', args: { url: linkToCape } }" />
@ -114,11 +142,21 @@
</div>
</div>
<div id="modal-use-as" class="modal fade" tabindex="-1" role="dialog">
<div
id="modal-use-as"
class="modal fade"
tabindex="-1"
role="dialog"
>
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<button
type="button"
class="close"
data-dismiss="modal"
aria-label="Close"
>
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title" v-t="'user.closet.use-as.title'"></h4>
@ -127,7 +165,12 @@
<template v-if="players.length !== 0">
<div v-for="player in players" :key="player.pid" class="player-item">
<label class="model-label" :for="player.pid">
<input type="radio" name="player" :value="player.pid" v-model="selectedPlayer" />
<input
type="radio"
name="player"
:value="player.pid"
v-model="selectedPlayer"
/>
<img :src="avatarUrl(player)" width="35" height="35" />
<span>{{ player.player_name }}</span>
</label>
@ -180,6 +223,12 @@ export default {
linkToSkin: () => `${blessing.base_url}/skinlib?filter=skin`,
linkToCape: () => `${blessing.base_url}/skinlib?filter=cape`,
},
created() {
this.search = debounce(this.loadCloset, 350);
},
beforeMount() {
this.loadCloset();
},
methods: {
search() {},
async loadCloset(page = 1) {
@ -265,12 +314,6 @@ export default {
this.skinUrl = this.capeUrl = '';
}
},
created() {
this.search = debounce(this.loadCloset, 350);
},
beforeMount() {
this.loadCloset();
}
};
</script>

View File

@ -8,8 +8,20 @@
<span :title="name">{{ textureName }} <small>({{ type }})</small></span>
</p>
<a :href="linkToSkinlib" :title="$t('user.viewInSkinlib')" class="more" data-toggle="tooltip" data-placement="bottom"><i class="fa fa-share"></i></a>
<span :title="$t('general.more')" class="more" data-toggle="dropdown" aria-haspopup="true" id="more-button"><i class="fa fa-cog"></i></span>
<a
:href="linkToSkinlib"
:title="$t('user.viewInSkinlib')"
class="more"
data-toggle="tooltip"
data-placement="bottom"
><i class="fa fa-share"></i></a>
<span
:title="$t('general.more')"
class="more"
data-toggle="dropdown"
aria-haspopup="true"
id="more-button"
><i class="fa fa-cog"></i></span>
<ul class="dropup dropdown-menu" aria-labelledby="more-button">
<li><a @click="rename" v-t="'user.renameItem'"></a></li>
@ -42,6 +54,11 @@ export default {
},
selected: Boolean
},
data() {
return {
textureName: this.name
};
},
computed: {
previewLink() {
return `${blessing.base_url}/preview/${this.tid}.png`;
@ -50,11 +67,6 @@ export default {
return `${blessing.base_url}/skinlib/show/${this.tid}`;
}
},
data() {
return {
textureName: this.name
};
},
methods: {
async rename() {
const { value: newTextureName, dismiss } = await swal({

View File

@ -16,17 +16,32 @@
<div class="box-body">
<div class="form-group">
<label v-t="'user.profile.password.old'"></label>
<input type="password" class="form-control" v-model="oldPassword" ref="oldPassword">
<input
type="password"
class="form-control"
v-model="oldPassword"
ref="oldPassword"
>
</div>
<div class="form-group">
<label v-t="'user.profile.password.new'"></label>
<input type="password" class="form-control" v-model="newPassword" ref="newPassword">
<input
type="password"
class="form-control"
v-model="newPassword"
ref="newPassword"
>
</div>
<div class="form-group">
<label v-t="'user.profile.password.confirm'"></label>
<input type="password" class="form-control" v-model="confirmPassword" ref="confirmPassword">
<input
type="password"
class="form-control"
v-model="confirmPassword"
ref="confirmPassword"
>
</div>
</div><!-- /.box-body -->
<div class="box-footer">
@ -43,8 +58,8 @@
<div class="box box-primary">
<div class="box-header with-border">
<h3 class="box-title" v-t="'user.profile.nickname.title'"></h3>
</div><!-- /.box-header -->
<div class="box-body">
</div><!-- /.box-header -->
<div class="box-body">
<div class="form-group has-feedback">
<input
v-model="nickname"
@ -69,8 +84,8 @@
<div class="box box-warning">
<div class="box-header with-border">
<h3 class="box-title" v-t="'user.profile.email.title'"></h3>
</div><!-- /.box-header -->
<div class="box-body">
</div><!-- /.box-header -->
<div class="box-body">
<div class="form-group has-feedback">
<input
v-model="email"
@ -105,8 +120,8 @@
<div class="box box-danger">
<div class="box-header with-border">
<h3 class="box-title" v-t="'user.profile.delete.title'"></h3>
</div><!-- /.box-header -->
<div class="box-body">
</div><!-- /.box-header -->
<div class="box-body">
<template v-if="isAdmin">
<p v-t="'user.profile.delete.admin'"></p>
<button class="btn btn-danger" disabled v-t="'user.profile.delete.button'"></button>
@ -125,11 +140,21 @@
</div>
</div>
<div id="modal-delete-account" class="modal modal-danger fade" tabindex="-1" role="dialog">
<div
id="modal-delete-account"
class="modal modal-danger fade"
tabindex="-1"
role="dialog"
>
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<button
type="button"
class="close"
data-dismiss="modal"
aria-label="Close"
>
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title" v-t="'user.profile.delete.modal-title'"></h4>
@ -137,12 +162,27 @@
<div class="modal-body">
<div v-once v-html="nl2br($t('user.profile.delete.modal-notice'))"></div>
<br />
<input type="password" class="form-control" v-model="deleteConfirm" :placeholder="$t('user.profile.delete.password')">
<input
type="password"
class="form-control"
v-model="deleteConfirm"
:placeholder="$t('user.profile.delete.password')"
>
<br />
</div>
<div class="modal-footer">
<button type="button" class="btn btn-outline" data-dismiss="modal" v-t="'general.close'"></button>
<a @click="deleteAccount" class="btn btn-outline" v-t="'general.submit'" data-test="deleteAccount"></a>
<button
type="button"
class="btn btn-outline"
data-dismiss="modal"
v-t="'general.close'"
></button>
<a
@click="deleteAccount"
class="btn btn-outline"
v-t="'general.submit'"
data-test="deleteAccount"
></a>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->