diff --git a/src/client/components/acct.vue b/src/client/components/acct.vue
index ce39678f5c..c2640291aa 100644
--- a/src/client/components/acct.vue
+++ b/src/client/components/acct.vue
@@ -8,7 +8,8 @@
diff --git a/src/client/components/ui/info.vue b/src/client/components/ui/info.vue
index 1cacea4c54..62ab5c8116 100644
--- a/src/client/components/ui/info.vue
+++ b/src/client/components/ui/info.vue
@@ -9,6 +9,7 @@
diff --git a/src/client/scripts/aiscript/api.ts b/src/client/scripts/aiscript/api.ts
index babf83bc03..181ab8e833 100644
--- a/src/client/scripts/aiscript/api.ts
+++ b/src/client/scripts/aiscript/api.ts
@@ -9,14 +9,14 @@ export function createAiScriptEnv(vm, opts) {
USER_NAME: vm.$store.getters.isSignedIn ? values.STR(vm.$store.state.i.name) : values.NULL,
USER_USERNAME: vm.$store.getters.isSignedIn ? values.STR(vm.$store.state.i.username) : values.NULL,
'Mk:dialog': values.FN_NATIVE(async ([title, text, type]) => {
- await vm.$store.dispatch('showDialog', {
+ await vm.os.dialog({
type: type ? type.value : 'info',
title: title.value,
text: text.value,
});
}),
'Mk:confirm': values.FN_NATIVE(async ([title, text, type]) => {
- const confirm = await vm.$store.dispatch('showDialog', {
+ const confirm = await vm.os.dialog({
type: type ? type.value : 'question',
showCancelButton: true,
title: title.value,
@@ -28,7 +28,7 @@ export function createAiScriptEnv(vm, opts) {
if (token) utils.assertString(token);
apiRequests++;
if (apiRequests > 16) return values.NULL;
- const res = await vm.$root.api(ep.value, utils.valToJs(param), token ? token.value : (opts.token || null));
+ const res = await vm.os.api(ep.value, utils.valToJs(param), token ? token.value : (opts.token || null));
return utils.jsToVal(res);
}),
'Mk:save': values.FN_NATIVE(([key, value]) => {
diff --git a/src/client/scripts/gen-search-query.ts b/src/client/scripts/gen-search-query.ts
index 2520da75df..670d915104 100644
--- a/src/client/scripts/gen-search-query.ts
+++ b/src/client/scripts/gen-search-query.ts
@@ -1,5 +1,5 @@
import parseAcct from '../../misc/acct/parse';
-import { host as localHost } from '../config';
+import { host as localHost } from '@/config';
export async function genSearchQuery(v: any, q: string) {
let host: string;
@@ -13,7 +13,7 @@ export async function genSearchQuery(v: any, q: string) {
host = at;
}
} else {
- const user = await v.$root.api('users/show', parseAcct(at)).catch(x => null);
+ const user = await v.os.api('users/show', parseAcct(at)).catch(x => null);
if (user) {
userId = user.id;
} else {
diff --git a/src/client/scripts/get-static-image-url.ts b/src/client/scripts/get-static-image-url.ts
index eff76af256..e932eb6da5 100644
--- a/src/client/scripts/get-static-image-url.ts
+++ b/src/client/scripts/get-static-image-url.ts
@@ -1,4 +1,4 @@
-import { url as instanceUrl } from '../config';
+import { url as instanceUrl } from '@/config';
import * as url from '../../prelude/url';
export function getStaticImageUrl(baseUrl: string): string {
diff --git a/src/client/scripts/hpml/evaluator.ts b/src/client/scripts/hpml/evaluator.ts
index 8c8dcc82c0..6ca9eccc6f 100644
--- a/src/client/scripts/hpml/evaluator.ts
+++ b/src/client/scripts/hpml/evaluator.ts
@@ -1,7 +1,7 @@
import autobind from 'autobind-decorator';
import * as seedrandom from 'seedrandom';
import { Variable, PageVar, envVarsDef, funcDefs, Block, isFnBlock } from '.';
-import { version } from '../../config';
+import { version } from '@/config';
import { AiScript, utils, values } from '@syuilo/aiscript';
import { createAiScriptEnv } from '../aiscript/api';
import { collectPageVars } from '../collect-page-vars';
@@ -42,7 +42,7 @@ export class Hpml {
}), ...initLib(this)}, {
in: (q) => {
return new Promise(ok => {
- vm.$store.dispatch('showDialog', {
+ vm.os.dialog({
title: q,
input: {}
}).then(({ canceled, result: a }) => {
diff --git a/src/client/scripts/paging.ts b/src/client/scripts/paging.ts
index 129c96004f..debb81db44 100644
--- a/src/client/scripts/paging.ts
+++ b/src/client/scripts/paging.ts
@@ -1,3 +1,4 @@
+import * as os from '@/os';
import { onScrollTop, isTopVisible } from './scroll';
const SECOND_FETCH_LIMIT = 30;
@@ -85,7 +86,7 @@ export default (opts) => ({
let params = typeof this.pagination.params === 'function' ? this.pagination.params(true) : this.pagination.params;
if (params && params.then) params = await params;
const endpoint = typeof this.pagination.endpoint === 'function' ? this.pagination.endpoint() : this.pagination.endpoint;
- await this.$root.api(endpoint, {
+ await os.api(endpoint, {
...params,
limit: this.pagination.noPaging ? (this.pagination.limit || 10) : (this.pagination.limit || 10) + 1,
}).then(items => {
@@ -117,7 +118,7 @@ export default (opts) => ({
let params = typeof this.pagination.params === 'function' ? this.pagination.params(false) : this.pagination.params;
if (params && params.then) params = await params;
const endpoint = typeof this.pagination.endpoint === 'function' ? this.pagination.endpoint() : this.pagination.endpoint;
- await this.$root.api(endpoint, {
+ await os.api(endpoint, {
...params,
limit: SECOND_FETCH_LIMIT + 1,
...(this.pagination.offsetMode ? {
diff --git a/src/client/scripts/please-login.ts b/src/client/scripts/please-login.ts
index 78e9d99e60..6ca78d3cc9 100644
--- a/src/client/scripts/please-login.ts
+++ b/src/client/scripts/please-login.ts
@@ -1,7 +1,7 @@
export default ($root: any) => {
if ($root.$store.getters.isSignedIn) return;
- $store.dispatch('showDialog', {
+ os.dialog({
title: $root.$t('signinRequired'),
text: null
});
diff --git a/src/client/scripts/search.ts b/src/client/scripts/search.ts
index a9ab19d7c8..1f6ec5fa1c 100644
--- a/src/client/scripts/search.ts
+++ b/src/client/scripts/search.ts
@@ -26,7 +26,7 @@ export async function search(v: any, q: string) {
}
v.$root.$emit('warp', date);
- v.$store.dispatch('showDialog', {
+ v.os.dialog({
icon: faHistory,
iconOnly: true, autoClose: true
});
@@ -34,7 +34,7 @@ export async function search(v: any, q: string) {
}
if (q.startsWith('https://')) {
- const dialog = v.$store.dispatch('showDialog', {
+ const dialog = v.os.dialog({
type: 'waiting',
text: v.$t('fetchingAsApObject') + '...',
showOkButton: false,
@@ -43,7 +43,7 @@ export async function search(v: any, q: string) {
});
try {
- const res = await v.$root.api('ap/show', {
+ const res = await v.os.api('ap/show', {
uri: q
});
dialog.close();
diff --git a/src/client/scripts/select-drive-file.ts b/src/client/scripts/select-drive-file.ts
index cd36ea55a5..9459bd604b 100644
--- a/src/client/scripts/select-drive-file.ts
+++ b/src/client/scripts/select-drive-file.ts
@@ -1,6 +1,6 @@
export function selectDriveFile($root: any, multiple) {
return new Promise((res, rej) => {
- import('../components/drive-window.vue').then(dialog => {
+ import('@/components/drive-window.vue').then(dialog => {
const w = $root.new(dialog, {
type: 'file',
multiple
diff --git a/src/client/scripts/select-drive-folder.ts b/src/client/scripts/select-drive-folder.ts
index 9814dac86c..ee6e5c1551 100644
--- a/src/client/scripts/select-drive-folder.ts
+++ b/src/client/scripts/select-drive-folder.ts
@@ -1,6 +1,6 @@
export function selectDriveFolder($root: any, multiple) {
return new Promise((res, rej) => {
- import('../components/drive-window.vue').then(dialog => {
+ import('@/components/drive-window.vue').then(dialog => {
const w = $root.new(dialog, {
type: 'folder',
multiple
diff --git a/src/client/scripts/select-file.ts b/src/client/scripts/select-file.ts
index a89aaddbf3..c56e39c313 100644
--- a/src/client/scripts/select-file.ts
+++ b/src/client/scripts/select-file.ts
@@ -1,6 +1,6 @@
import { faUpload, faCloud } from '@fortawesome/free-solid-svg-icons';
import { selectDriveFile } from './select-drive-file';
-import { apiUrl } from '../config';
+import { apiUrl } from '@/config';
// TODO: component引数は消せる(各種操作がstoreに移動し、かつstoreが複数ファイルで共有されるようになったため)
export function selectFile(component: any, src: any, label: string | null, multiple = false) {
@@ -10,7 +10,7 @@ export function selectFile(component: any, src: any, label: string | null, multi
input.type = 'file';
input.multiple = multiple;
input.onchange = () => {
- const dialog = component.$store.dispatch('showDialog', {
+ const dialog = component.os.dialog({
type: 'waiting',
text: component.$t('uploading') + '...',
showOkButton: false,
@@ -35,7 +35,7 @@ export function selectFile(component: any, src: any, label: string | null, multi
Promise.all(promises).then(driveFiles => {
res(multiple ? driveFiles : driveFiles[0]);
}).catch(e => {
- component.$store.dispatch('showDialog', {
+ component.os.dialog({
type: 'error',
text: e
});
@@ -65,7 +65,7 @@ export function selectFile(component: any, src: any, label: string | null, multi
};
- component.$store.dispatch('showMenu', {
+ component.os.menu({
items: [label ? {
text: label,
type: 'label'
diff --git a/src/client/scripts/stream.ts b/src/client/scripts/stream.ts
index 86fa90e8fd..a7b37722e5 100644
--- a/src/client/scripts/stream.ts
+++ b/src/client/scripts/stream.ts
@@ -1,7 +1,7 @@
import autobind from 'autobind-decorator';
import { EventEmitter } from 'eventemitter3';
import ReconnectingWebsocket from 'reconnecting-websocket';
-import { wsUrl } from '../config';
+import { wsUrl } from '@/config';
/**
* Misskey stream connection
diff --git a/src/client/store.ts b/src/client/store.ts
index dee551bf88..8dd682a8e9 100644
--- a/src/client/store.ts
+++ b/src/client/store.ts
@@ -5,7 +5,7 @@ import * as nestedProperty from 'nested-property';
import { faSatelliteDish, faTerminal, faHashtag, faBroadcastTower, faFireAlt, faSearch, faStar, faAt, faListUl, faUserClock, faUsers, faCloud, faGamepad, faFileAlt, faSatellite, faDoorClosed, faColumns } from '@fortawesome/free-solid-svg-icons';
import { faBell, faEnvelope, faComments } from '@fortawesome/free-regular-svg-icons';
import { AiScript, utils, values } from '@syuilo/aiscript';
-import { apiUrl, deckmode } from './config';
+import { apiUrl, deckmode } from '@/config';
import { erase } from '../prelude/array';
export const defaultSettings = {
@@ -110,13 +110,10 @@ export const store = createStore({
spinner: null,
dialogs: [] as {
id: any;
- type: 'info' | 'question' | 'warn' | 'success' | 'error';
- title: string;
- text: string;
+ component: any;
+ props: Record;
result: any;
}[],
- menus: [],
- postForm: null,
fullView: false,
// Plugin
@@ -278,24 +275,6 @@ export const store = createStore({
state.dialogs = state.dialogs.filter(d => d.id !== dialogId);
},
- addMenu(state, menu) {
- state.menus.push(menu);
- },
-
- menuDone(state, { id: menuId }) {
- const menu = state.menus.find(d => d.id === menuId);
- menu.result = 'hoge';
- },
-
- removeMenu(state, menuId) {
- state.menus = state.menus.filter(d => d.id !== menuId);
- },
-
- setPostForm(state, postForm) {
- if (state.postForm != null && postForm != null) return;
- state.postForm = postForm;
- },
-
setFullView(state, v) {
state.fullView = v;
},
@@ -391,12 +370,17 @@ export const store = createStore({
}
},
- showDialog(ctx, opts) {
+ showDialog(ctx, { component, props }) {
return new Promise((res, rej) => {
+ const id = Math.random().toString(); // TODO: uuidとか使う
const dialog = reactive({
- ...opts,
+ component,
+ props: {
+ ...props,
+ id
+ },
result: null,
- id: Math.random().toString() // TODO: uuidとか使う
+ id,
});
ctx.commit('addDialog', dialog);
const unwatch = watch(() => dialog.result, result => {
@@ -406,21 +390,6 @@ export const store = createStore({
});
},
- showMenu(ctx, opts) {
- return new Promise((res, rej) => {
- const menu = reactive({
- ...opts,
- result: null,
- id: Math.random().toString() // TODO: uuidとか使う
- });
- ctx.commit('addMenu', menu);
- const unwatch = watch(() => menu.result, result => {
- unwatch();
- res(result);
- });
- });
- },
-
api(ctx, { endpoint, data, token }) {
if (++ctx.state.pendingApiRequestsCount === 1) {
// TODO: spinnerの表示はstoreでやらない
diff --git a/src/client/sw.ts b/src/client/sw.ts
index 341198852e..01ed216029 100644
--- a/src/client/sw.ts
+++ b/src/client/sw.ts
@@ -3,7 +3,7 @@
*/
declare var self: ServiceWorkerGlobalScope;
-import composeNotification from './scripts/compose-notification';
+import composeNotification from '@/scripts/compose-notification';
// eslint-disable-next-line no-undef
const version = _VERSION_;
diff --git a/src/client/tsconfig.json b/src/client/tsconfig.json
index aac0d1bfe7..6b6213ee26 100644
--- a/src/client/tsconfig.json
+++ b/src/client/tsconfig.json
@@ -17,7 +17,10 @@
"strict": true,
"strictNullChecks": false,
"experimentalDecorators": true,
- "resolveJsonModule": true,
+ "resolveJsonModule": true,
+ "paths": {
+ "@/*": ["./*"]
+ },
"typeRoots": [
"node_modules/@types",
"src/@types"
diff --git a/src/client/widgets/activity.calendar.vue b/src/client/widgets/activity.calendar.vue
index 70d9dbfec0..b833bd65ca 100644
--- a/src/client/widgets/activity.calendar.vue
+++ b/src/client/widgets/activity.calendar.vue
@@ -25,6 +25,7 @@