mirror of
https://github.com/kokonect-link/cherrypick
synced 2024-12-01 00:08:31 +09:00
wip
This commit is contained in:
parent
24478a060e
commit
b7596e357c
@ -12,7 +12,9 @@
|
|||||||
"target": "es2017",
|
"target": "es2017",
|
||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
"removeComments": false,
|
"removeComments": false,
|
||||||
"noLib": false
|
"noLib": false,
|
||||||
|
"strict": true,
|
||||||
|
"strictNullChecks": false
|
||||||
},
|
},
|
||||||
"compileOnSave": false,
|
"compileOnSave": false,
|
||||||
"include": [
|
"include": [
|
||||||
|
@ -4,6 +4,10 @@ import signout from './scripts/signout';
|
|||||||
import Progress from './scripts/loading';
|
import Progress from './scripts/loading';
|
||||||
import HomeStreamManager from './scripts/streaming/home-stream-manager';
|
import HomeStreamManager from './scripts/streaming/home-stream-manager';
|
||||||
import api from './scripts/api';
|
import api from './scripts/api';
|
||||||
|
import DriveStreamManager from './scripts/streaming/drive-stream-manager';
|
||||||
|
import ServerStreamManager from './scripts/streaming/server-stream-manager';
|
||||||
|
import RequestsStreamManager from './scripts/streaming/requests-stream-manager';
|
||||||
|
import MessagingIndexStreamManager from './scripts/streaming/messaging-index-stream-manager';
|
||||||
|
|
||||||
//#region environment variables
|
//#region environment variables
|
||||||
declare const _VERSION_: string;
|
declare const _VERSION_: string;
|
||||||
@ -50,6 +54,16 @@ export default class MiOS extends EventEmitter {
|
|||||||
*/
|
*/
|
||||||
public stream: HomeStreamManager;
|
public stream: HomeStreamManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Connection managers
|
||||||
|
*/
|
||||||
|
public streams: {
|
||||||
|
driveStream: DriveStreamManager;
|
||||||
|
serverStream: ServerStreamManager;
|
||||||
|
requestsStream: RequestsStreamManager;
|
||||||
|
messagingIndexStream: MessagingIndexStreamManager;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A registration of service worker
|
* A registration of service worker
|
||||||
*/
|
*/
|
||||||
@ -69,6 +83,9 @@ export default class MiOS extends EventEmitter {
|
|||||||
|
|
||||||
this.shouldRegisterSw = shouldRegisterSw;
|
this.shouldRegisterSw = shouldRegisterSw;
|
||||||
|
|
||||||
|
this.streams.serverStream = new ServerStreamManager();
|
||||||
|
this.streams.requestsStream = new RequestsStreamManager();
|
||||||
|
|
||||||
//#region BIND
|
//#region BIND
|
||||||
this.log = this.log.bind(this);
|
this.log = this.log.bind(this);
|
||||||
this.logInfo = this.logInfo.bind(this);
|
this.logInfo = this.logInfo.bind(this);
|
||||||
@ -79,6 +96,15 @@ export default class MiOS extends EventEmitter {
|
|||||||
this.getMeta = this.getMeta.bind(this);
|
this.getMeta = this.getMeta.bind(this);
|
||||||
this.registerSw = this.registerSw.bind(this);
|
this.registerSw = this.registerSw.bind(this);
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
|
this.once('signedin', () => {
|
||||||
|
// Init home stream manager
|
||||||
|
this.stream = new HomeStreamManager(this.i);
|
||||||
|
|
||||||
|
// Init other stream manager
|
||||||
|
this.streams.driveStream = new DriveStreamManager(this.i);
|
||||||
|
this.streams.messagingIndexStream = new MessagingIndexStreamManager(this.i);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public log(...args) {
|
public log(...args) {
|
||||||
@ -139,8 +165,8 @@ export default class MiOS extends EventEmitter {
|
|||||||
// When failure
|
// When failure
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
// Render the error screen
|
// Render the error screen
|
||||||
document.body.innerHTML = '<mk-error />';
|
//document.body.innerHTML = '<mk-error />';
|
||||||
riot.mount('*');
|
//riot.mount('*');
|
||||||
|
|
||||||
Progress.done();
|
Progress.done();
|
||||||
});
|
});
|
||||||
@ -173,10 +199,7 @@ export default class MiOS extends EventEmitter {
|
|||||||
|
|
||||||
this.i = me;
|
this.i = me;
|
||||||
|
|
||||||
// Init home stream manager
|
this.emit('signedin');
|
||||||
this.stream = this.isSignedin
|
|
||||||
? new HomeStreamManager(this.i)
|
|
||||||
: null;
|
|
||||||
|
|
||||||
// Finish init
|
// Finish init
|
||||||
callback();
|
callback();
|
||||||
|
@ -1,40 +0,0 @@
|
|||||||
import * as riot from 'riot';
|
|
||||||
|
|
||||||
import MiOS from './mios';
|
|
||||||
import ServerStreamManager from './scripts/streaming/server-stream-manager';
|
|
||||||
import RequestsStreamManager from './scripts/streaming/requests-stream-manager';
|
|
||||||
import MessagingIndexStreamManager from './scripts/streaming/messaging-index-stream-manager';
|
|
||||||
import DriveStreamManager from './scripts/streaming/drive-stream-manager';
|
|
||||||
|
|
||||||
export default (mios: MiOS) => {
|
|
||||||
(riot as any).mixin('os', {
|
|
||||||
mios: mios
|
|
||||||
});
|
|
||||||
|
|
||||||
(riot as any).mixin('i', {
|
|
||||||
init: function() {
|
|
||||||
this.I = mios.i;
|
|
||||||
this.SIGNIN = mios.isSignedin;
|
|
||||||
|
|
||||||
if (this.SIGNIN) {
|
|
||||||
this.on('mount', () => {
|
|
||||||
mios.i.on('updated', this.update);
|
|
||||||
});
|
|
||||||
this.on('unmount', () => {
|
|
||||||
mios.i.off('updated', this.update);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
me: mios.i
|
|
||||||
});
|
|
||||||
|
|
||||||
(riot as any).mixin('api', {
|
|
||||||
api: mios.api
|
|
||||||
});
|
|
||||||
|
|
||||||
(riot as any).mixin('stream', { stream: mios.stream });
|
|
||||||
(riot as any).mixin('drive-stream', { driveStream: new DriveStreamManager(mios.i) });
|
|
||||||
(riot as any).mixin('server-stream', { serverStream: new ServerStreamManager() });
|
|
||||||
(riot as any).mixin('requests-stream', { requestsStream: new RequestsStreamManager() });
|
|
||||||
(riot as any).mixin('messaging-index-stream', { messagingIndexStream: new MessagingIndexStreamManager(mios.i) });
|
|
||||||
};
|
|
@ -7,23 +7,43 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="typescript">
|
<script lang="typescript">
|
||||||
export default {
|
import Vue from 'vue';
|
||||||
|
|
||||||
|
export default Vue.extend({
|
||||||
props: ['time', 'mode'],
|
props: ['time', 'mode'],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
mode: 'relative',
|
mode: 'relative',
|
||||||
tickId: null
|
tickId: null,
|
||||||
|
now: new Date()
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
created() {
|
computed: {
|
||||||
this.absolute =
|
absolute() {
|
||||||
|
return (
|
||||||
this.time.getFullYear() + '年' +
|
this.time.getFullYear() + '年' +
|
||||||
(this.time.getMonth() + 1) + '月' +
|
(this.time.getMonth() + 1) + '月' +
|
||||||
this.time.getDate() + '日' +
|
this.time.getDate() + '日' +
|
||||||
' ' +
|
' ' +
|
||||||
this.time.getHours() + '時' +
|
this.time.getHours() + '時' +
|
||||||
this.time.getMinutes() + '分';
|
this.time.getMinutes() + '分');
|
||||||
|
},
|
||||||
|
relative() {
|
||||||
|
const ago = (this.now - this.time) / 1000/*ms*/;
|
||||||
|
return (
|
||||||
|
ago >= 31536000 ? '%i18n:common.time.years_ago%' .replace('{}', ~~(ago / 31536000)) :
|
||||||
|
ago >= 2592000 ? '%i18n:common.time.months_ago%' .replace('{}', ~~(ago / 2592000)) :
|
||||||
|
ago >= 604800 ? '%i18n:common.time.weeks_ago%' .replace('{}', ~~(ago / 604800)) :
|
||||||
|
ago >= 86400 ? '%i18n:common.time.days_ago%' .replace('{}', ~~(ago / 86400)) :
|
||||||
|
ago >= 3600 ? '%i18n:common.time.hours_ago%' .replace('{}', ~~(ago / 3600)) :
|
||||||
|
ago >= 60 ? '%i18n:common.time.minutes_ago%'.replace('{}', ~~(ago / 60)) :
|
||||||
|
ago >= 10 ? '%i18n:common.time.seconds_ago%'.replace('{}', ~~(ago % 60)) :
|
||||||
|
ago >= 0 ? '%i18n:common.time.just_now%' :
|
||||||
|
ago < 0 ? '%i18n:common.time.future%' :
|
||||||
|
'%i18n:common.time.unknown%');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
if (this.mode == 'relative' || this.mode == 'detail') {
|
if (this.mode == 'relative' || this.mode == 'detail') {
|
||||||
this.tick();
|
this.tick();
|
||||||
this.tickId = setInterval(this.tick, 1000);
|
this.tickId = setInterval(this.tick, 1000);
|
||||||
@ -36,20 +56,8 @@
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
tick() {
|
tick() {
|
||||||
const now = new Date();
|
this.now = new Date();
|
||||||
const ago = (now - this.time) / 1000/*ms*/;
|
|
||||||
this.relative =
|
|
||||||
ago >= 31536000 ? '%i18n:common.time.years_ago%' .replace('{}', ~~(ago / 31536000)) :
|
|
||||||
ago >= 2592000 ? '%i18n:common.time.months_ago%' .replace('{}', ~~(ago / 2592000)) :
|
|
||||||
ago >= 604800 ? '%i18n:common.time.weeks_ago%' .replace('{}', ~~(ago / 604800)) :
|
|
||||||
ago >= 86400 ? '%i18n:common.time.days_ago%' .replace('{}', ~~(ago / 86400)) :
|
|
||||||
ago >= 3600 ? '%i18n:common.time.hours_ago%' .replace('{}', ~~(ago / 3600)) :
|
|
||||||
ago >= 60 ? '%i18n:common.time.minutes_ago%'.replace('{}', ~~(ago / 60)) :
|
|
||||||
ago >= 10 ? '%i18n:common.time.seconds_ago%'.replace('{}', ~~(ago % 60)) :
|
|
||||||
ago >= 0 ? '%i18n:common.time.just_now%' :
|
|
||||||
ago < 0 ? '%i18n:common.time.future%' :
|
|
||||||
'%i18n:common.time.unknown%';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@ -30,21 +30,21 @@ if (_HOST_ != 'localhost') {
|
|||||||
document.domain = _HOST_;
|
document.domain = _HOST_;
|
||||||
}
|
}
|
||||||
|
|
||||||
{ // Set lang attr
|
//#region Set lang attr
|
||||||
const html = document.documentElement;
|
const html = document.documentElement;
|
||||||
html.setAttribute('lang', _LANG_);
|
html.setAttribute('lang', _LANG_);
|
||||||
}
|
//#endregion
|
||||||
|
|
||||||
{ // Set description meta tag
|
//#region Set description meta tag
|
||||||
const head = document.getElementsByTagName('head')[0];
|
const head = document.getElementsByTagName('head')[0];
|
||||||
const meta = document.createElement('meta');
|
const meta = document.createElement('meta');
|
||||||
meta.setAttribute('name', 'description');
|
meta.setAttribute('name', 'description');
|
||||||
meta.setAttribute('content', '%i18n:common.misskey%');
|
meta.setAttribute('content', '%i18n:common.misskey%');
|
||||||
head.appendChild(meta);
|
head.appendChild(meta);
|
||||||
}
|
//#endregion
|
||||||
|
|
||||||
// Set global configuration
|
// Set global configuration
|
||||||
(riot as any).mixin(__CONSTS__);
|
//(riot as any).mixin(__CONSTS__);
|
||||||
|
|
||||||
// iOSでプライベートモードだとlocalStorageが使えないので既存のメソッドを上書きする
|
// iOSでプライベートモードだとlocalStorageが使えないので既存のメソッドを上書きする
|
||||||
try {
|
try {
|
||||||
|
@ -12,7 +12,9 @@
|
|||||||
"target": "es2017",
|
"target": "es2017",
|
||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
"removeComments": false,
|
"removeComments": false,
|
||||||
"noLib": false
|
"noLib": false,
|
||||||
|
"strict": true,
|
||||||
|
"strictNullChecks": false
|
||||||
},
|
},
|
||||||
"compileOnSave": false,
|
"compileOnSave": false,
|
||||||
"include": [
|
"include": [
|
||||||
|
Loading…
Reference in New Issue
Block a user