なんかもうめっちゃ変えた

Closes #940
This commit is contained in:
syuilo
2017-11-23 05:43:00 +09:00
parent 1809800980
commit 3f8ebac466
46 changed files with 244 additions and 225 deletions

View File

@@ -2,7 +2,7 @@
* API Request
*/
import CONFIG from './config';
declare const _API_URL_: string;
let spinner = null;
let pending = 0;
@@ -26,7 +26,7 @@ export default (i, endpoint, data = {}): Promise<{ [x: string]: any }> => {
return new Promise((resolve, reject) => {
// Send request
fetch(endpoint.indexOf('://') > -1 ? endpoint : `${CONFIG.apiUrl}/${endpoint}`, {
fetch(endpoint.indexOf('://') > -1 ? endpoint : `${_API_URL_}/${endpoint}`, {
method: 'POST',
body: JSON.stringify(data),
credentials: endpoint === 'signin' ? 'include' : 'omit'

View File

@@ -1,12 +1,12 @@
import MiOS from '../mios';
declare var VERSION: string;
declare const _VERSION_: string;
export default async function(mios: MiOS) {
const meta = await mios.getMeta();
if (meta.version != VERSION) {
if (meta.version != _VERSION_) {
localStorage.setItem('should-refresh', 'true');
alert('%i18n:common.update-available%'.replace('{newer}', meta.version).replace('{current}', VERSION));
alert('%i18n:common.update-available%'.replace('{newer}', meta.version).replace('{current}', _VERSION_));
}
}

View File

@@ -1,27 +0,0 @@
const _url = new URL(location.href);
const isRoot = _url.host == 'localhost'
? true
: _url.host.split('.')[0] == 'misskey';
const host = isRoot ? _url.host : _url.host.substring(_url.host.indexOf('.') + 1, _url.host.length);
const scheme = _url.protocol;
const url = `${scheme}//${host}`;
const apiUrl = `${scheme}//api.${host}`;
const chUrl = `${scheme}//ch.${host}`;
const devUrl = `${scheme}//dev.${host}`;
const aboutUrl = `${scheme}//about.${host}`;
const statsUrl = `${scheme}//stats.${host}`;
const statusUrl = `${scheme}//status.${host}`;
export default {
host,
scheme,
url,
apiUrl,
chUrl,
devUrl,
aboutUrl,
statsUrl,
statusUrl
};

View File

@@ -1,7 +1,7 @@
import CONFIG from './config';
declare const _HOST_: string;
export default () => {
localStorage.removeItem('me');
document.cookie = `i=; domain=.${CONFIG.host}; expires=Thu, 01 Jan 1970 00:00:01 GMT;`;
document.cookie = `i=; domain=.${_HOST_}; expires=Thu, 01 Jan 1970 00:00:01 GMT;`;
location.href = '/';
};

View File

@@ -1,6 +1,7 @@
declare const _API_URL_: string;
import { EventEmitter } from 'eventemitter3';
import * as ReconnectingWebsocket from 'reconnecting-websocket';
import CONFIG from '../config';
/**
* Misskey stream connection
@@ -24,7 +25,7 @@ export default class Connection extends EventEmitter {
this.state = 'initializing';
this.buffer = [];
const host = CONFIG.apiUrl.replace('http', 'ws');
const host = _API_URL_.replace('http', 'ws');
const query = params
? Object.keys(params)
.map(k => encodeURIComponent(k) + '=' + encodeURIComponent(params[k]))

View File

@@ -1,6 +1,7 @@
declare const _URL_: string;
import * as riot from 'riot';
import * as pictograph from 'pictograph';
import CONFIG from './config';
const escape = text =>
text
@@ -26,7 +27,7 @@ export default (tokens, shouldBreak) => {
case 'link':
return `<a class="link" href="${escape(token.url)}" target="_blank" title="${escape(token.url)}">${escape(token.title)}</a>`;
case 'mention':
return `<a href="${CONFIG.url + '/' + escape(token.username)}" target="_blank" data-user-preview="${token.content}" ${me && me.username == token.username ? 'data-is-me' : ''}>${token.content}</a>`;
return `<a href="${_URL_ + '/' + escape(token.username)}" target="_blank" data-user-preview="${token.content}" ${me && me.username == token.username ? 'data-is-me' : ''}>${token.content}</a>`;
case 'hashtag': // TODO
return `<a>${escape(token.content)}</a>`;
case 'code':