This commit is contained in:
syuilo
2020-09-06 12:30:27 +09:00
parent 256307f1a9
commit e33f2398f5
270 changed files with 1173 additions and 961 deletions

View File

@@ -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]) => {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 }) => {

View File

@@ -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 ? {

View File

@@ -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
});

View File

@@ -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();

View File

@@ -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

View File

@@ -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

View File

@@ -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'

View File

@@ -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