wip
This commit is contained in:
parent
2f23776a90
commit
a003c3f7e9
|
@ -2,7 +2,7 @@
|
||||||
* Client entry point
|
* Client entry point
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import Vue from 'vue';
|
import { createApp } from 'vue';
|
||||||
import Vuex from 'vuex';
|
import Vuex from 'vuex';
|
||||||
import VueMeta from 'vue-meta';
|
import VueMeta from 'vue-meta';
|
||||||
import PortalVue from 'portal-vue';
|
import PortalVue from 'portal-vue';
|
||||||
|
@ -13,8 +13,7 @@ import { AiScript } from '@syuilo/aiscript';
|
||||||
import { deserialize } from '@syuilo/aiscript/built/serializer';
|
import { deserialize } from '@syuilo/aiscript/built/serializer';
|
||||||
|
|
||||||
import VueHotkey from './scripts/hotkey';
|
import VueHotkey from './scripts/hotkey';
|
||||||
import App from './app.vue';
|
import Root from './root.vue';
|
||||||
import Deck from './deck.vue';
|
|
||||||
import MiOS from './mios';
|
import MiOS from './mios';
|
||||||
import { version, langs, instanceName, getLocale, deckmode } from './config';
|
import { version, langs, instanceName, getLocale, deckmode } from './config';
|
||||||
import PostFormDialog from './components/post-form-dialog.vue';
|
import PostFormDialog from './components/post-form-dialog.vue';
|
||||||
|
@ -29,19 +28,21 @@ import { clientDb, get, count } from './db';
|
||||||
import { setI18nContexts } from './scripts/set-i18n-contexts';
|
import { setI18nContexts } from './scripts/set-i18n-contexts';
|
||||||
import { createPluginEnv } from './scripts/aiscript/api';
|
import { createPluginEnv } from './scripts/aiscript/api';
|
||||||
|
|
||||||
Vue.use(Vuex);
|
const app = createApp(Root);
|
||||||
Vue.use(VueHotkey);
|
|
||||||
Vue.use(VueMeta);
|
app.use(Vuex);
|
||||||
Vue.use(PortalVue);
|
app.use(VueHotkey);
|
||||||
Vue.use(VAnimateCss);
|
app.use(VueMeta);
|
||||||
Vue.use(VueI18n);
|
app.use(PortalVue);
|
||||||
Vue.component('fa', FontAwesomeIcon);
|
app.use(VAnimateCss);
|
||||||
|
app.use(VueI18n);
|
||||||
|
app.component('fa', FontAwesomeIcon);
|
||||||
|
|
||||||
require('./directives');
|
require('./directives');
|
||||||
require('./components');
|
require('./components');
|
||||||
require('./widgets');
|
require('./widgets');
|
||||||
|
|
||||||
Vue.mixin({
|
app.mixin({
|
||||||
methods: {
|
methods: {
|
||||||
destroyDom() {
|
destroyDom() {
|
||||||
this.$destroy();
|
this.$destroy();
|
||||||
|
@ -140,68 +141,7 @@ os.init(async () => {
|
||||||
});
|
});
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
const app = new Vue({
|
app.mount('#app');
|
||||||
store: store,
|
|
||||||
i18n,
|
|
||||||
metaInfo: {
|
|
||||||
title: null,
|
|
||||||
titleTemplate: title => title ? `${title} | ${(instanceName || 'Misskey')}` : (instanceName || 'Misskey')
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
stream: os.stream,
|
|
||||||
isMobile: isMobile,
|
|
||||||
i18n // TODO: 消せないか考える SEE: https://github.com/syuilo/misskey/pull/6396#discussion_r429511030
|
|
||||||
};
|
|
||||||
},
|
|
||||||
// TODO: ここらへんのメソッド全部Vuexに移したい
|
|
||||||
methods: {
|
|
||||||
dialog(opts) {
|
|
||||||
const vm = this.new(Dialog, opts);
|
|
||||||
const p: any = new Promise((res) => {
|
|
||||||
vm.$once('ok', result => res({ canceled: false, result }));
|
|
||||||
vm.$once('cancel', () => res({ canceled: true }));
|
|
||||||
});
|
|
||||||
p.close = () => {
|
|
||||||
vm.close();
|
|
||||||
};
|
|
||||||
return p;
|
|
||||||
},
|
|
||||||
menu(opts) {
|
|
||||||
const vm = this.new(Menu, opts);
|
|
||||||
const p: any = new Promise((res) => {
|
|
||||||
vm.$once('closed', () => res());
|
|
||||||
});
|
|
||||||
return p;
|
|
||||||
},
|
|
||||||
form(title, form) {
|
|
||||||
const vm = this.new(Form, { title, form });
|
|
||||||
return new Promise((res) => {
|
|
||||||
vm.$once('ok', result => res({ canceled: false, result }));
|
|
||||||
vm.$once('cancel', () => res({ canceled: true }));
|
|
||||||
});
|
|
||||||
},
|
|
||||||
post(opts, cb) {
|
|
||||||
if (!this.$store.getters.isSignedIn) return;
|
|
||||||
const vm = this.new(PostFormDialog, opts);
|
|
||||||
if (cb) vm.$once('closed', cb);
|
|
||||||
(vm as any).focus();
|
|
||||||
},
|
|
||||||
sound(type: string) {
|
|
||||||
if (this.$store.state.device.sfxVolume === 0) return;
|
|
||||||
const sound = this.$store.state.device['sfx' + type.substr(0, 1).toUpperCase() + type.substr(1)];
|
|
||||||
if (sound == null) return;
|
|
||||||
const audio = new Audio(`/assets/sounds/${sound}.mp3`);
|
|
||||||
audio.volume = this.$store.state.device.sfxVolume;
|
|
||||||
audio.play();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
router: router,
|
|
||||||
render: createEl => createEl(deckmode ? Deck : App)
|
|
||||||
});
|
|
||||||
|
|
||||||
// マウント
|
|
||||||
app.$mount('#app');
|
|
||||||
|
|
||||||
store.watch(state => state.device.darkMode, darkMode => {
|
store.watch(state => state.device.darkMode, darkMode => {
|
||||||
import('./scripts/theme').then(({ builtinThemes }) => {
|
import('./scripts/theme').then(({ builtinThemes }) => {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<component :is="deck ? DeckUI : DefaultUI"/>
|
<component :is="deck ? DeckUI : DefaultUI"/>
|
||||||
|
<!-- Render modals here -->
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
@ -13,14 +14,22 @@ export default Vue.extend({
|
||||||
DeckUI,
|
DeckUI,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
metaInfo: {
|
||||||
|
title: null,
|
||||||
|
titleTemplate: title => title ? `${title} | ${(instanceName || 'Misskey')}` : (instanceName || 'Misskey')
|
||||||
|
},
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
stream: os.stream,
|
||||||
|
isMobile: isMobile,
|
||||||
|
i18n // TODO: 消せないか考える SEE: https://github.com/syuilo/misskey/pull/6396#discussion_r429511030
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
dialog(opts) {
|
dialog(opts) {
|
||||||
//this.$store.openDialog();
|
this.$store.commit('showDialog', opts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -97,6 +97,13 @@ export default () => new Vuex.Store({
|
||||||
i: null,
|
i: null,
|
||||||
pendingApiRequestsCount: 0,
|
pendingApiRequestsCount: 0,
|
||||||
spinner: null,
|
spinner: null,
|
||||||
|
dialogs: [] as {
|
||||||
|
id: any;
|
||||||
|
type: 'info' | 'question' | 'warn' | 'success' | 'error';
|
||||||
|
title: string;
|
||||||
|
text: string;
|
||||||
|
result: any;
|
||||||
|
}[],
|
||||||
|
|
||||||
// Plugin
|
// Plugin
|
||||||
pluginContexts: new Map<string, AiScript>(),
|
pluginContexts: new Map<string, AiScript>(),
|
||||||
|
@ -237,6 +244,10 @@ export default () => new Vuex.Store({
|
||||||
state.i[key] = value;
|
state.i[key] = value;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
showDialog(state, dialog) {
|
||||||
|
state.dialogs.push(dialog);
|
||||||
|
},
|
||||||
|
|
||||||
initPlugin(state, { plugin, aiscript }) {
|
initPlugin(state, { plugin, aiscript }) {
|
||||||
state.pluginContexts.set(plugin.id, aiscript);
|
state.pluginContexts.set(plugin.id, aiscript);
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue