forked from FoundKeyGang/FoundKey
parent
4ba43b69b6
commit
9fc1cc5255
7 changed files with 36 additions and 74 deletions
|
@ -870,9 +870,6 @@ desktop/views/components/settings.vue:
|
|||
web-search-engine-desc: "例: https://www.google.com/?#q={{query}}"
|
||||
auto-popout: "ウィンドウの自動ポップアウト"
|
||||
auto-popout-desc: "ウィンドウが開かれるとき、ポップアウト(ブラウザ外に切り離す)可能なら自動でポップアウトします。この設定はブラウザに記憶されます。"
|
||||
advanced: "詳細設定"
|
||||
api-via-stream: "ストリームを経由したAPIリクエスト"
|
||||
api-via-stream-desc: "この設定をオンにすると、websocket接続を経由してAPIリクエストが行われます(パフォーマンス向上が期待できます)。オフにすると、ネイティブの fetch APIが利用されます。この設定はこのデバイスのみ有効です。"
|
||||
deck-nav: "デッキ内ナビゲーション"
|
||||
deck-nav-desc: "デッキを使用しているとき、ナビゲーションが発生する際にページ遷移を行わずに一時的なカラムで受けるようにします。"
|
||||
deck-default: "デッキをデフォルトのUIにする"
|
||||
|
|
|
@ -148,7 +148,7 @@ export default Vue.extend({
|
|||
},
|
||||
|
||||
updateStats() {
|
||||
this.$root.api('stats', {}, false, true).then(stats => {
|
||||
this.$root.api('stats', {}, true).then(stats => {
|
||||
this.stats = stats;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ export default Vue.extend({
|
|||
username: this.username,
|
||||
password: this.password,
|
||||
token: this.user && this.user.twoFactorEnabled ? this.token : undefined
|
||||
}, true).then(res => {
|
||||
}).then(res => {
|
||||
localStorage.setItem('i', res.i);
|
||||
location.reload();
|
||||
}).catch(() => {
|
||||
|
|
|
@ -142,11 +142,11 @@ export default Vue.extend({
|
|||
password: this.password,
|
||||
invitationCode: this.invitationCode,
|
||||
'g-recaptcha-response': this.meta.enableRecaptcha ? (window as any).grecaptcha.getResponse() : null
|
||||
}, true).then(() => {
|
||||
}).then(() => {
|
||||
this.$root.api('signin', {
|
||||
username: this.username,
|
||||
password: this.password
|
||||
}, true).then(res => {
|
||||
}).then(res => {
|
||||
localStorage.setItem('i', res.i);
|
||||
location.reload();
|
||||
});
|
||||
|
|
|
@ -32,13 +32,6 @@
|
|||
<span slot="desc">{{ $t('auto-popout-desc') }}</span>
|
||||
</ui-switch>
|
||||
<ui-switch v-model="deckNav">{{ $t('deck-nav') }}<span slot="desc">{{ $t('deck-nav-desc') }}</span></ui-switch>
|
||||
|
||||
<details>
|
||||
<summary>{{ $t('advanced') }}</summary>
|
||||
<ui-switch v-model="apiViaStream">{{ $t('api-via-stream') }}
|
||||
<span slot="desc">{{ $t('api-via-stream-desc') }}</span>
|
||||
</ui-switch>
|
||||
</details>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
|
@ -333,11 +326,6 @@ export default Vue.extend({
|
|||
set(value) { this.$store.commit('device/set', { key: 'reduceMotion', value }); }
|
||||
},
|
||||
|
||||
apiViaStream: {
|
||||
get() { return this.$store.state.device.apiViaStream; },
|
||||
set(value) { this.$store.commit('device/set', { key: 'apiViaStream', value }); }
|
||||
},
|
||||
|
||||
autoPopout: {
|
||||
get() { return this.$store.state.device.autoPopout; },
|
||||
set(value) { this.$store.commit('device/set', { key: 'autoPopout', value }); }
|
||||
|
|
|
@ -385,7 +385,7 @@ export default class MiOS extends EventEmitter {
|
|||
* @param data パラメータ
|
||||
*/
|
||||
@autobind
|
||||
public api(endpoint: string, data: { [x: string]: any } = {}, forceFetch = false, silent = false): Promise<{ [x: string]: any }> {
|
||||
public api(endpoint: string, data: { [x: string]: any } = {}, silent = false): Promise<{ [x: string]: any }> {
|
||||
if (!silent) {
|
||||
if (++pending === 1) {
|
||||
spinner = document.createElement('div');
|
||||
|
@ -401,66 +401,44 @@ export default class MiOS extends EventEmitter {
|
|||
};
|
||||
|
||||
const promise = new Promise((resolve, reject) => {
|
||||
const viaStream = this.stream && this.stream.state == 'connected' && this.store.state.device.apiViaStream && !forceFetch;
|
||||
// Append a credential
|
||||
if (this.store.getters.isSignedIn) (data as any).i = this.store.state.i.token;
|
||||
|
||||
if (viaStream) {
|
||||
const id = Math.random().toString().substr(2, 8);
|
||||
const req = {
|
||||
id: uuid(),
|
||||
date: new Date(),
|
||||
name: endpoint,
|
||||
data,
|
||||
res: null,
|
||||
status: null
|
||||
};
|
||||
|
||||
this.stream.once(`api:${id}`, res => {
|
||||
if (res == null || Object.keys(res).length == 0) {
|
||||
resolve(null);
|
||||
} else if (res.res) {
|
||||
resolve(res.res);
|
||||
} else {
|
||||
reject(res.e);
|
||||
}
|
||||
});
|
||||
if (this.debug) {
|
||||
this.requests.push(req);
|
||||
}
|
||||
|
||||
this.stream.send('api', {
|
||||
id: id,
|
||||
ep: endpoint,
|
||||
data: data
|
||||
});
|
||||
} else {
|
||||
// Append a credential
|
||||
if (this.store.getters.isSignedIn) (data as any).i = this.store.state.i.token;
|
||||
|
||||
const req = {
|
||||
id: uuid(),
|
||||
date: new Date(),
|
||||
name: endpoint,
|
||||
data,
|
||||
res: null,
|
||||
status: null
|
||||
};
|
||||
// Send request
|
||||
fetch(endpoint.indexOf('://') > -1 ? endpoint : `${apiUrl}/${endpoint}`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(data),
|
||||
credentials: endpoint === 'signin' ? 'include' : 'omit',
|
||||
cache: 'no-cache'
|
||||
}).then(async (res) => {
|
||||
const body = res.status === 204 ? null : await res.json();
|
||||
|
||||
if (this.debug) {
|
||||
this.requests.push(req);
|
||||
req.status = res.status;
|
||||
req.res = body;
|
||||
}
|
||||
|
||||
// Send request
|
||||
fetch(endpoint.indexOf('://') > -1 ? endpoint : `${apiUrl}/${endpoint}`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(data),
|
||||
credentials: endpoint === 'signin' ? 'include' : 'omit',
|
||||
cache: 'no-cache'
|
||||
}).then(async (res) => {
|
||||
const body = res.status === 204 ? null : await res.json();
|
||||
|
||||
if (this.debug) {
|
||||
req.status = res.status;
|
||||
req.res = body;
|
||||
}
|
||||
|
||||
if (res.status === 200) {
|
||||
resolve(body);
|
||||
} else if (res.status === 204) {
|
||||
resolve();
|
||||
} else {
|
||||
reject(body.error);
|
||||
}
|
||||
}).catch(reject);
|
||||
}
|
||||
if (res.status === 200) {
|
||||
resolve(body);
|
||||
} else if (res.status === 204) {
|
||||
resolve();
|
||||
} else {
|
||||
reject(body.error);
|
||||
}
|
||||
}).catch(reject);
|
||||
});
|
||||
|
||||
promise.then(onFinally, onFinally);
|
||||
|
|
|
@ -47,7 +47,6 @@ const defaultSettings = {
|
|||
|
||||
const defaultDeviceSettings = {
|
||||
reduceMotion: false,
|
||||
apiViaStream: true,
|
||||
autoPopout: false,
|
||||
darkmode: false,
|
||||
darkTheme: 'dark',
|
||||
|
|
Loading…
Reference in a new issue