This commit is contained in:
syuilo 2017-08-28 23:47:43 +09:00
parent f546edb810
commit ffaec0b971
14 changed files with 137 additions and 33 deletions

View file

@ -0,0 +1,11 @@
import * as riot from 'riot';
export default (title, onOk, onCancel) => {
const dialog = document.body.appendChild(document.createElement('mk-input-dialog'));
return riot.mount(dialog, {
title: title,
type: 'password',
onOk: onOk,
onCancel: onCancel
});
};

View file

@ -5,7 +5,7 @@
</yield>
<yield to="content">
<div class="body">
<input ref="text" oninput={ parent.update } onkeydown={ parent.onKeydown } placeholder={ parent.placeholder }/>
<input ref="text" type={ parent.type } oninput={ parent.onInput } onkeydown={ parent.onKeydown } placeholder={ parent.placeholder }/>
</div>
<div class="action">
<button class="cancel" onclick={ parent.cancel }>キャンセル</button>
@ -126,6 +126,7 @@
this.placeholder = this.opts.placeholder;
this.default = this.opts.default;
this.allowEmpty = this.opts.allowEmpty != null ? this.opts.allowEmpty : true;
this.type = this.opts.type ? this.opts.type : 'text';
this.on('mount', () => {
this.text = this.refs.window.refs.text;
@ -156,6 +157,10 @@
this.refs.window.close();
};
this.onInput = () => {
this.update();
};
this.onKeydown = e => {
if (e.which == 13) { // Enter
e.preventDefault();

View file

@ -211,3 +211,33 @@
};
</script>
</mk-settings>
<mk-api-info>
<p>Token:<code>{ I.token }</code></p>
<p>APIを利用するには、上記のトークンを「i」というキーでパラメータに付加してリクエストします。</p>
<p>アカウントを乗っ取られてしまう可能性があるため、このトークンは第三者に教えないでください(アプリなどにも入力しないでください)。</p>
<p>万が一このトークンが漏れたりその可能性がある場合は<a class="regenerate" onclick={ regenerateToken }>トークンを再生成</a>できます。(副作用として、ログインしているすべてのデバイスでログアウトが発生します)</p>
<style>
:scope
display block
color #4a535a
code
padding 4px
background #eee
</style>
<script>
import passwordDialog from '../scripts/password-dialog';
this.mixin('i');
this.mixin('api');
this.regenerateToken = () => {
passwordDialog('%i18n:desktop.tags.mk-api-info.regenerate-token%', password => {
this.api('i/regenerate_token', {
password: password
})
});
};
</script>
</mk-api-info>