-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathSettings.vue
308 lines (282 loc) · 8.48 KB
/
Settings.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
<template>
<!-- eslint-disable no-irregular-whitespace -->
<v-dialog
v-model="isActive"
fullscreen
hide-overlay
transition="dialog-left-transition"
>
<v-card>
<v-toolbar dark flat>
<v-btn @click.native="isActive = false" icon dark>
<v-icon>close</v-icon>
</v-btn>
<v-toolbar-title>設定</v-toolbar-title>
</v-toolbar>
<v-card-text>
<v-list three-line subheader>
<v-list-tile avatar>
<v-select
v-model="gameType"
:items="diceBots"
label="ダイスボット"
item-text="name"
item-value="gameType"
/>
</v-list-tile>
<v-list-tile avatar>
<v-text-field
:value="apiURL"
@change="v => (apiURL = v)"
@click:append="resetApiURL"
label="BCDice-APIのURL"
append-icon="restore"
/>
</v-list-tile>
<v-list-tile avatar>
<v-list-tile-action>
<v-switch v-model="playDiceAnimation" color="primary" />
</v-list-tile-action>
<v-list-tile-content>
<v-list-tile-title>ダイスロールアニメーション</v-list-tile-title>
<v-list-tile-sub-title
>ダイスロール時のアニメーションを表示する</v-list-tile-sub-title
>
</v-list-tile-content>
</v-list-tile>
<v-list-tile avatar>
<v-list-tile-action>
<v-switch v-model="playSound" color="primary" />
</v-list-tile-action>
<v-list-tile-content>
<v-list-tile-title>効果音</v-list-tile-title>
<v-list-tile-sub-title
>ダイスロール時に効果音を鳴らす</v-list-tile-sub-title
>
</v-list-tile-content>
</v-list-tile>
<v-list-tile avatar>
<v-list-tile-action>
<v-switch v-model="showSystemInfo" color="primary" />
</v-list-tile-action>
<v-list-tile-content>
<v-list-tile-title>ヘルプ表示</v-list-tile-title>
<v-list-tile-sub-title
>ダイスコマンド入力時にヘルプを表示する</v-list-tile-sub-title
>
</v-list-tile-content>
</v-list-tile>
<v-list-tile avatar>
<v-list-tile-action>
<v-switch v-model="showTips" color="primary" />
</v-list-tile-action>
<v-list-tile-content>
<v-list-tile-title>Tips表示</v-list-tile-title>
<v-list-tile-sub-title
>SaipageのTipsを表示する</v-list-tile-sub-title
>
</v-list-tile-content>
</v-list-tile>
<v-list-tile>
<span class="setting-title">音量</span>
<v-slider
v-model="volume"
class="volume"
max="10"
append-icon="volume_up"
prepend-icon="volume_down"
/>
</v-list-tile>
</v-list>
<v-divider />
<v-subheader class="red--text">Danger Zone</v-subheader>
<v-list three-line subheader>
<v-list-tile>
<v-list-tile-content>
<v-list-tile-title>ログを削除</v-list-tile-title>
<v-list-tile-sub-title
>このSaipageで行ったダイスロールの全ログをブラウザから削除します</v-list-tile-sub-title
>
</v-list-tile-content>
<v-list-tile-action class="danger-zone-action">
<v-btn
@click.stop="removeLogDialog = true"
depressed
color="error"
>ログを削除</v-btn
>
</v-list-tile-action>
</v-list-tile>
</v-list>
<v-divider />
<v-subheader>アプリケーション情報</v-subheader>
<v-card-text>
<div class="headline">
Saipage <small>- {{ commitHash }}</small>
</div>
<p>
Created by <a href="https://twitter.com/ysakasin">酒田 シンジ</a>
</p>
<p>
ご要望やバグ報告は<a
href="https://github.com/ysakasin/saipage/issues"
>Github issue</a
>または<a href="https://twitter.com/ysakasin">Twitter</a
>までお寄せください
</p>
</v-card-text>
</v-card-text>
<div style="flex: 1 1 auto;" />
</v-card>
<v-dialog v-model="removeLogDialog" max-width="500">
<v-card>
<v-card-title class="headline">ログを削除</v-card-title>
<v-card-text>
<p>
このSaipageで行ったダイスロールの全ログをブラウザから削除します。ログを削除すると復旧することはできません。
</p>
<p>
ログを削除しますか?
</p>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn @click="removeLogDialog = false" color="green darken-1" text>
キャンセル
</v-btn>
<v-btn @click="removeAllLogs" depressed color="error">
削除する
</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
<v-snackbar v-model="snackbar" :timeout="3000" color="success" top>
{{ snackbarText }}
<v-btn @click="snackbar = false" dark text>
閉じる
</v-btn>
</v-snackbar>
</v-dialog>
</template>
<script lang="ts">
import Vue from "vue";
import Component from "vue-class-component";
import { DEFAULT_URL } from "./dice";
import { COMMIT_HASH, STAGED, UNSTAGED } from "./constants";
@Component({
props: {
value: Boolean
},
watch: {
value(val: boolean) {
if (val != this.$data.isActive) {
this.$data.isActive = val;
}
},
isActive(val: boolean) {
this.$emit("input", val);
}
}
})
export default class Settings extends Vue {
data() {
return {
isActive: false,
snackbar: false,
snackbarText: "",
removeLogDialog: false
};
}
resetApiURL() {
this.$store.dispatch("updateApiURL", DEFAULT_URL);
this.$data.snackbarText = `APIをデフォルト設定に戻しました`;
this.$data.snackbar = true;
}
removeAllLogs() {
this.$store.commit("removeAllLogs");
this.$data.removeLogDialog = false;
this.$data.snackbarText = `ログを削除しました`;
this.$data.snackbar = true;
}
get diceBots() {
return this.$store.state.diceBots;
}
get commitHash() {
if (STAGED || UNSTAGED) {
return COMMIT_HASH + "+";
} else {
return COMMIT_HASH;
}
}
get apiURL() {
return this.$store.state.apiURL;
}
set apiURL(newURL: string) {
this.$store.dispatch("updateApiURL", newURL);
this.$data.snackbarText = `変更しました`;
this.$data.snackbar = true;
}
get gameType() {
return this.$store.state.gameType;
}
set gameType(newType) {
this.$store.dispatch("updateGameType", newType);
this.$data.snackbarText = `ダイスボットを「${newType}」に変更しました`;
this.$data.snackbar = true;
}
get playSound() {
return this.$store.state.settings.playSound;
}
set playSound(val: boolean) {
this.$store.commit("updateSoundSetting", val);
}
get playDiceAnimation() {
return this.$store.state.settings.playDiceAnimation;
}
set playDiceAnimation(val: boolean) {
this.$store.commit("updateAnimationSetting", val);
}
get showSystemInfo() {
return this.$store.state.settings.showSystemInfo;
}
set showSystemInfo(val: boolean) {
this.$store.commit("updateSystemInfoSetting", val);
}
get showTips() {
return this.$store.state.settings.showTips;
}
set showTips(val: boolean) {
this.$store.commit("updateTipsSetting", val);
}
get volume() {
return this.$store.state.settings.soundVolume * 10;
}
set volume(val: number) {
const newVolume = val / 10;
this.$store.commit("updateSoundVolumeSetting", newVolume);
}
}
</script>
<style lang="scss" scoped>
.v-toolbar {
margin-bottom: 20px;
}
.volume {
max-width: 400px;
}
.setting-title {
padding-right: 1rem;
}
.danger-zone-action {
margin-left: 4px;
min-width: auto;
}
</style>
<style lang="scss">
.dialog-left-transition {
&-enter,
&-leave-to {
transform: translateX(100%);
}
}
</style>