refactor(client): ✨
This commit is contained in:
parent
980a99b6c9
commit
46c0280764
|
@ -74,7 +74,7 @@ import { formatTimeString } from '@/scripts/format-time-string';
|
||||||
import { Autocomplete } from '@/scripts/autocomplete';
|
import { Autocomplete } from '@/scripts/autocomplete';
|
||||||
import { noteVisibilities } from 'misskey-js';
|
import { noteVisibilities } from 'misskey-js';
|
||||||
import * as os from '@/os';
|
import * as os from '@/os';
|
||||||
import { selectFile } from '@/scripts/select-file';
|
import { selectFiles } from '@/scripts/select-file';
|
||||||
import { defaultStore, notePostInterruptors, postFormActions } from '@/store';
|
import { defaultStore, notePostInterruptors, postFormActions } from '@/store';
|
||||||
import { throttle } from 'throttle-debounce';
|
import { throttle } from 'throttle-debounce';
|
||||||
import MkInfo from '@/components/ui/info.vue';
|
import MkInfo from '@/components/ui/info.vue';
|
||||||
|
@ -456,7 +456,7 @@ export default defineComponent({
|
||||||
},
|
},
|
||||||
|
|
||||||
chooseFileFrom(ev) {
|
chooseFileFrom(ev) {
|
||||||
selectFile(ev.currentTarget || ev.target, this.$ts.attachFile, true).then(files => {
|
selectFiles(ev.currentTarget || ev.target, this.$ts.attachFile).then(files => {
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
this.files.push(file);
|
this.files.push(file);
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ import MkButton from '@/components/ui/button.vue';
|
||||||
import MkInput from '@/components/form/input.vue';
|
import MkInput from '@/components/form/input.vue';
|
||||||
import MkPagination from '@/components/ui/pagination.vue';
|
import MkPagination from '@/components/ui/pagination.vue';
|
||||||
import MkTab from '@/components/tab.vue';
|
import MkTab from '@/components/tab.vue';
|
||||||
import { selectFile } from '@/scripts/select-file';
|
import { selectFiles } from '@/scripts/select-file';
|
||||||
import * as os from '@/os';
|
import * as os from '@/os';
|
||||||
import * as symbols from '@/symbols';
|
import * as symbols from '@/symbols';
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ export default defineComponent({
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
async add(e) {
|
async add(e) {
|
||||||
const files = await selectFile(e.currentTarget || e.target, null, true);
|
const files = await selectFiles(e.currentTarget || e.target, null);
|
||||||
|
|
||||||
const promise = Promise.all(files.map(file => os.api('admin/emoji/add', {
|
const promise = Promise.all(files.map(file => os.api('admin/emoji/add', {
|
||||||
fileId: file.id,
|
fileId: file.id,
|
||||||
|
|
|
@ -112,7 +112,7 @@ export default defineComponent({
|
||||||
},
|
},
|
||||||
|
|
||||||
setBannerImage(e) {
|
setBannerImage(e) {
|
||||||
selectFile(e.currentTarget || e.target, null, false).then(file => {
|
selectFile(e.currentTarget || e.target, null).then(file => {
|
||||||
this.bannerId = file.id;
|
this.bannerId = file.id;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -37,7 +37,7 @@ import FormTuple from '@/components/debobigego/tuple.vue';
|
||||||
import FormBase from '@/components/debobigego/base.vue';
|
import FormBase from '@/components/debobigego/base.vue';
|
||||||
import FormGroup from '@/components/debobigego/group.vue';
|
import FormGroup from '@/components/debobigego/group.vue';
|
||||||
import FormSuspense from '@/components/debobigego/suspense.vue';
|
import FormSuspense from '@/components/debobigego/suspense.vue';
|
||||||
import { selectFile } from '@/scripts/select-file';
|
import { selectFiles } from '@/scripts/select-file';
|
||||||
import * as os from '@/os';
|
import * as os from '@/os';
|
||||||
import * as symbols from '@/symbols';
|
import * as symbols from '@/symbols';
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ export default defineComponent({
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
selectFile(e) {
|
selectFile(e) {
|
||||||
selectFile(e.currentTarget || e.target, null, true).then(files => {
|
selectFiles(e.currentTarget || e.target, null).then(files => {
|
||||||
this.files = this.files.concat(files);
|
this.files = this.files.concat(files);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -152,7 +152,7 @@ export default defineComponent({
|
||||||
},
|
},
|
||||||
|
|
||||||
chooseFile(e) {
|
chooseFile(e) {
|
||||||
selectFile(e.currentTarget || e.target, this.$ts.selectFile, false).then(file => {
|
selectFile(e.currentTarget || e.target, this.$ts.selectFile).then(file => {
|
||||||
this.file = file;
|
this.file = file;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -448,7 +448,7 @@ export default defineComponent({
|
||||||
},
|
},
|
||||||
|
|
||||||
setEyeCatchingImage(e) {
|
setEyeCatchingImage(e) {
|
||||||
selectFile(e.currentTarget || e.target, null, false).then(file => {
|
selectFile(e.currentTarget || e.target, null).then(file => {
|
||||||
this.eyeCatchingImageId = file.id;
|
this.eyeCatchingImageId = file.id;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -210,7 +210,7 @@ export default defineComponent({
|
||||||
},
|
},
|
||||||
|
|
||||||
chooseImage(key, e) {
|
chooseImage(key, e) {
|
||||||
selectFile(e.currentTarget || e.target, null, false).then(file => {
|
selectFile(e.currentTarget || e.target, null).then(file => {
|
||||||
room.updateProp(key, `/proxy/?${urlQuery({ url: file.thumbnailUrl })}`);
|
room.updateProp(key, `/proxy/?${urlQuery({ url: file.thumbnailUrl })}`);
|
||||||
this.$refs.preview.selected(room.getSelectedObject());
|
this.$refs.preview.selected(room.getSelectedObject());
|
||||||
this.changed = true;
|
this.changed = true;
|
||||||
|
|
|
@ -188,7 +188,7 @@ export default defineComponent({
|
||||||
themesCount,
|
themesCount,
|
||||||
wallpaper,
|
wallpaper,
|
||||||
setWallpaper(e) {
|
setWallpaper(e) {
|
||||||
selectFile(e.currentTarget || e.target, null, false).then(file => {
|
selectFile(e.currentTarget || e.target, null).then(file => {
|
||||||
wallpaper.value = file.url;
|
wallpaper.value = file.url;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
import * as os from '@/os';
|
import * as os from '@/os';
|
||||||
import { i18n } from '@/i18n';
|
import { i18n } from '@/i18n';
|
||||||
import { defaultStore } from '@/store';
|
import { defaultStore } from '@/store';
|
||||||
|
import { DriveFile } from 'misskey-js/built/entities';
|
||||||
|
|
||||||
export function selectFile(src: any, label: string | null, multiple = false) {
|
function select(src: any, label: string | null, multiple: boolean): Promise<DriveFile | DriveFile[]> {
|
||||||
return new Promise((res, rej) => {
|
return new Promise((res, rej) => {
|
||||||
const chooseFileFromPc = () => {
|
const chooseFileFromPc = () => {
|
||||||
const input = document.createElement('input');
|
const input = document.createElement('input');
|
||||||
|
@ -86,3 +87,11 @@ export function selectFile(src: any, label: string | null, multiple = false) {
|
||||||
}], src);
|
}], src);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function selectFile(src: any, label: string | null = null): Promise<DriveFile> {
|
||||||
|
return select(src, label, false) as Promise<DriveFile>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function selectFiles(src: any, label: string | null = null): Promise<DriveFile[]> {
|
||||||
|
return select(src, label, true) as Promise<DriveFile[]>;
|
||||||
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ import * as Acct from 'misskey-js/built/acct';
|
||||||
import { formatTimeString } from '@/scripts/format-time-string';
|
import { formatTimeString } from '@/scripts/format-time-string';
|
||||||
import { Autocomplete } from '@/scripts/autocomplete';
|
import { Autocomplete } from '@/scripts/autocomplete';
|
||||||
import * as os from '@/os';
|
import * as os from '@/os';
|
||||||
import { selectFile } from '@/scripts/select-file';
|
import { selectFiles } from '@/scripts/select-file';
|
||||||
import { notePostInterruptors, postFormActions } from '@/store';
|
import { notePostInterruptors, postFormActions } from '@/store';
|
||||||
import { throttle } from 'throttle-debounce';
|
import { throttle } from 'throttle-debounce';
|
||||||
|
|
||||||
|
@ -342,7 +342,7 @@ export default defineComponent({
|
||||||
},
|
},
|
||||||
|
|
||||||
chooseFileFrom(ev) {
|
chooseFileFrom(ev) {
|
||||||
selectFile(ev.currentTarget || ev.target, this.$ts.attachFile, true).then(files => {
|
selectFiles(ev.currentTarget || ev.target, this.$ts.attachFile).then(files => {
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
this.files.push(file);
|
this.files.push(file);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue