mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-10 01:53:08 +02:00
wip
This commit is contained in:
parent
24478a060e
commit
b7596e357c
6 changed files with 79 additions and 84 deletions
|
@ -12,7 +12,9 @@
|
|||
"target": "es2017",
|
||||
"module": "commonjs",
|
||||
"removeComments": false,
|
||||
"noLib": false
|
||||
"noLib": false,
|
||||
"strict": true,
|
||||
"strictNullChecks": false
|
||||
},
|
||||
"compileOnSave": false,
|
||||
"include": [
|
||||
|
|
|
@ -4,6 +4,10 @@ import signout from './scripts/signout';
|
|||
import Progress from './scripts/loading';
|
||||
import HomeStreamManager from './scripts/streaming/home-stream-manager';
|
||||
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
|
||||
declare const _VERSION_: string;
|
||||
|
@ -50,6 +54,16 @@ export default class MiOS extends EventEmitter {
|
|||
*/
|
||||
public stream: HomeStreamManager;
|
||||
|
||||
/**
|
||||
* Connection managers
|
||||
*/
|
||||
public streams: {
|
||||
driveStream: DriveStreamManager;
|
||||
serverStream: ServerStreamManager;
|
||||
requestsStream: RequestsStreamManager;
|
||||
messagingIndexStream: MessagingIndexStreamManager;
|
||||
};
|
||||
|
||||
/**
|
||||
* A registration of service worker
|
||||
*/
|
||||
|
@ -69,6 +83,9 @@ export default class MiOS extends EventEmitter {
|
|||
|
||||
this.shouldRegisterSw = shouldRegisterSw;
|
||||
|
||||
this.streams.serverStream = new ServerStreamManager();
|
||||
this.streams.requestsStream = new RequestsStreamManager();
|
||||
|
||||
//#region BIND
|
||||
this.log = this.log.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.registerSw = this.registerSw.bind(this);
|
||||
//#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) {
|
||||
|
@ -139,8 +165,8 @@ export default class MiOS extends EventEmitter {
|
|||
// When failure
|
||||
.catch(() => {
|
||||
// Render the error screen
|
||||
document.body.innerHTML = '<mk-error />';
|
||||
riot.mount('*');
|
||||
//document.body.innerHTML = '<mk-error />';
|
||||
//riot.mount('*');
|
||||
|
||||
Progress.done();
|
||||
});
|
||||
|
@ -173,10 +199,7 @@ export default class MiOS extends EventEmitter {
|
|||
|
||||
this.i = me;
|
||||
|
||||
// Init home stream manager
|
||||
this.stream = this.isSignedin
|
||||
? new HomeStreamManager(this.i)
|
||||
: null;
|
||||
this.emit('signedin');
|
||||
|
||||
// Finish init
|
||||
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>
|
||||
|
||||
<script lang="typescript">
|
||||
export default {
|
||||
import Vue from 'vue';
|
||||
|
||||
export default Vue.extend({
|
||||
props: ['time', 'mode'],
|
||||
data() {
|
||||
return {
|
||||
mode: 'relative',
|
||||
tickId: null
|
||||
tickId: null,
|
||||
now: new Date()
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
absolute() {
|
||||
return (
|
||||
this.time.getFullYear() + '年' +
|
||||
(this.time.getMonth() + 1) + '月' +
|
||||
this.time.getDate() + '日' +
|
||||
' ' +
|
||||
this.time.getHours() + '時' +
|
||||
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() {
|
||||
this.absolute =
|
||||
this.time.getFullYear() + '年' +
|
||||
(this.time.getMonth() + 1) + '月' +
|
||||
this.time.getDate() + '日' +
|
||||
' ' +
|
||||
this.time.getHours() + '時' +
|
||||
this.time.getMinutes() + '分';
|
||||
|
||||
if (this.mode == 'relative' || this.mode == 'detail') {
|
||||
this.tick();
|
||||
this.tickId = setInterval(this.tick, 1000);
|
||||
|
@ -36,20 +56,8 @@
|
|||
},
|
||||
methods: {
|
||||
tick() {
|
||||
const 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%';
|
||||
this.now = new Date();
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -30,21 +30,21 @@ if (_HOST_ != 'localhost') {
|
|||
document.domain = _HOST_;
|
||||
}
|
||||
|
||||
{ // Set lang attr
|
||||
const html = document.documentElement;
|
||||
html.setAttribute('lang', _LANG_);
|
||||
}
|
||||
//#region Set lang attr
|
||||
const html = document.documentElement;
|
||||
html.setAttribute('lang', _LANG_);
|
||||
//#endregion
|
||||
|
||||
{ // Set description meta tag
|
||||
const head = document.getElementsByTagName('head')[0];
|
||||
const meta = document.createElement('meta');
|
||||
meta.setAttribute('name', 'description');
|
||||
meta.setAttribute('content', '%i18n:common.misskey%');
|
||||
head.appendChild(meta);
|
||||
}
|
||||
//#region Set description meta tag
|
||||
const head = document.getElementsByTagName('head')[0];
|
||||
const meta = document.createElement('meta');
|
||||
meta.setAttribute('name', 'description');
|
||||
meta.setAttribute('content', '%i18n:common.misskey%');
|
||||
head.appendChild(meta);
|
||||
//#endregion
|
||||
|
||||
// Set global configuration
|
||||
(riot as any).mixin(__CONSTS__);
|
||||
//(riot as any).mixin(__CONSTS__);
|
||||
|
||||
// iOSでプライベートモードだとlocalStorageが使えないので既存のメソッドを上書きする
|
||||
try {
|
||||
|
|
|
@ -12,7 +12,9 @@
|
|||
"target": "es2017",
|
||||
"module": "commonjs",
|
||||
"removeComments": false,
|
||||
"noLib": false
|
||||
"noLib": false,
|
||||
"strict": true,
|
||||
"strictNullChecks": false
|
||||
},
|
||||
"compileOnSave": false,
|
||||
"include": [
|
||||
|
|
Loading…
Reference in a new issue