This commit is contained in:
syuilo 2020-09-20 22:05:34 +09:00
parent e1d379aa55
commit 5fa695830d
12 changed files with 36 additions and 42 deletions

View file

@ -66,7 +66,6 @@ import { erase, unique } from '../../prelude/array';
import extractMentions from '../../misc/extract-mentions'; import extractMentions from '../../misc/extract-mentions';
import getAcct from '../../misc/acct/render'; import getAcct from '../../misc/acct/render';
import { formatTimeString } from '../../misc/format-time-string'; import { formatTimeString } from '../../misc/format-time-string';
import { selectDriveFile } from '@/scripts/select-drive-file';
import { Autocomplete } from '@/scripts/autocomplete'; import { Autocomplete } from '@/scripts/autocomplete';
import { noteVisibilities } from '../../types'; import { noteVisibilities } from '../../types';
import { utils } from '@syuilo/aiscript'; import { utils } from '@syuilo/aiscript';
@ -379,7 +378,7 @@ export default defineComponent({
}, },
chooseFileFromDrive() { chooseFileFromDrive() {
selectDriveFile(true).then(files => { os.selectDriveFile(true).then(files => {
for (const file of files) { for (const file of files) {
this.attachMedia(file); this.attachMedia(file);
} }

View file

@ -143,6 +143,31 @@ export function dialog(props: Record<string, any>, opts?: { cancelableByBgClick:
}); });
} }
export function selectDriveFile(multiple) {
return new Promise(async (res, rej) => {
modal(await import('@/components/drive-window.vue'), {
type: 'file',
multiple
}).then(files => {
res(multiple ? files : files[0]);
});
});
}
export function selectDriveFolder(multiple) {
return new Promise((res, rej) => {
import('@/components/drive-window.vue').then(dialog => {
const w = $root.new(dialog, {
type: 'folder',
multiple
});
w.$once('selected', folders => {
res(multiple ? folders : (folders.length === 0 ? null : folders[0]));
});
});
});
}
export function menu(props: Record<string, any>, opts?: { source: any; }) { export function menu(props: Record<string, any>, opts?: { source: any; }) {
return modal(defineAsyncComponent(() => import('@/components/menu.vue')), props, {}, { return modal(defineAsyncComponent(() => import('@/components/menu.vue')), props, {}, {
position: 'source', position: 'source',

View file

@ -13,7 +13,6 @@ import { defineComponent } from 'vue';
import { faCloud, faFolderOpen } from '@fortawesome/free-solid-svg-icons'; import { faCloud, faFolderOpen } from '@fortawesome/free-solid-svg-icons';
import { faClock, faEyeSlash, faTrashAlt } from '@fortawesome/free-regular-svg-icons'; import { faClock, faEyeSlash, faTrashAlt } from '@fortawesome/free-regular-svg-icons';
import MkButton from '@/components/ui/button.vue'; import MkButton from '@/components/ui/button.vue';
import { selectDriveFolder } from '@/scripts/select-drive-folder';
import * as os from '@/os'; import * as os from '@/os';
export default defineComponent({ export default defineComponent({
@ -38,7 +37,7 @@ export default defineComponent({
methods: { methods: {
chooseUploadFolder() { chooseUploadFolder() {
selectDriveFolder(false).then(async folder => { os.selectDriveFolder(false).then(async folder => {
await this.$store.dispatch('settings/set', { key: 'uploadFolder', value: folder ? folder.id : null }); await this.$store.dispatch('settings/set', { key: 'uploadFolder', value: folder ? folder.id : null });
os.dialog({ os.dialog({
type: 'success', type: 'success',

View file

@ -19,7 +19,6 @@ import { faPencilAlt } from '@fortawesome/free-solid-svg-icons';
import { faImage, faFolderOpen } from '@fortawesome/free-regular-svg-icons'; import { faImage, faFolderOpen } from '@fortawesome/free-regular-svg-icons';
import XContainer from '../page-editor.container.vue'; import XContainer from '../page-editor.container.vue';
import MkFileThumbnail from '@/components/drive-file-thumbnail.vue'; import MkFileThumbnail from '@/components/drive-file-thumbnail.vue';
import { selectDriveFile } from '@/scripts/select-drive-file';
import * as os from '@/os'; import * as os from '@/os';
export default defineComponent({ export default defineComponent({
@ -58,7 +57,7 @@ export default defineComponent({
methods: { methods: {
async choose() { async choose() {
selectDriveFile(false).then(file => { os.selectDriveFile(false).then(file => {
this.file = file; this.file = file;
this.value.fileId = file.id; this.value.fileId = file.id;
}); });

View file

@ -106,7 +106,6 @@ import { blockDefs } from '@/scripts/hpml/index';
import { HpmlTypeChecker } from '@/scripts/hpml/type-checker'; import { HpmlTypeChecker } from '@/scripts/hpml/type-checker';
import { url } from '@/config'; import { url } from '@/config';
import { collectPageVars } from '@/scripts/collect-page-vars'; import { collectPageVars } from '@/scripts/collect-page-vars';
import { selectDriveFile } from '@/scripts/select-drive-file';
import * as os from '@/os'; import * as os from '@/os';
export default defineComponent({ export default defineComponent({
@ -414,7 +413,7 @@ export default defineComponent({
}, },
setEyeCatchingImage() { setEyeCatchingImage() {
selectDriveFile(false).then(file => { os.selectDriveFile(false).then(file => {
this.eyeCatchingImageId = file.id; this.eyeCatchingImageId = file.id;
}); });
}, },

View file

@ -58,7 +58,6 @@ import MkButton from '@/components/ui/button.vue';
import MkInput from '@/components/ui/input.vue'; import MkInput from '@/components/ui/input.vue';
import MkSwitch from '@/components/ui/switch.vue'; import MkSwitch from '@/components/ui/switch.vue';
import MkTextarea from '@/components/ui/textarea.vue'; import MkTextarea from '@/components/ui/textarea.vue';
import { selectDriveFile } from '@/scripts/select-drive-file';
import * as os from '@/os'; import * as os from '@/os';
export default defineComponent({ export default defineComponent({
@ -101,7 +100,7 @@ export default defineComponent({
}, },
async selectDriveFile() { async selectDriveFile() {
const files = await selectDriveFile(); const files = await os.selectDriveFile();
} }
} }
}); });

View file

@ -26,8 +26,8 @@
<script lang="ts"> <script lang="ts">
import { defineAsyncComponent, defineComponent } from 'vue'; import { defineAsyncComponent, defineComponent } from 'vue';
import DefaultUI from './default.vue'; import DefaultUI from '@/ui/default.vue';
import DeckUI from './deck.vue'; import DeckUI from '@/ui/deck.vue';
import { instanceName, deckmode } from '@/config'; import { instanceName, deckmode } from '@/config';
export default defineComponent({ export default defineComponent({

View file

@ -1,12 +0,0 @@
import * as os from '@/os';
export function selectDriveFile(multiple) {
return new Promise(async (res, rej) => {
os.modal(await import('@/components/drive-window.vue'), {
type: 'file',
multiple
}).then(files => {
res(multiple ? files : files[0]);
});
});
}

View file

@ -1,13 +0,0 @@
export function selectDriveFolder(multiple) {
return new Promise((res, rej) => {
import('@/components/drive-window.vue').then(dialog => {
const w = $root.new(dialog, {
type: 'folder',
multiple
});
w.$once('selected', folders => {
res(multiple ? folders : (folders.length === 0 ? null : folders[0]));
});
});
});
}

View file

@ -1,5 +1,4 @@
import { faUpload, faCloud } from '@fortawesome/free-solid-svg-icons'; import { faUpload, faCloud } from '@fortawesome/free-solid-svg-icons';
import { selectDriveFile } from './select-drive-file';
import { apiUrl } from '@/config'; import { apiUrl } from '@/config';
import { store } from '@/store'; import { store } from '@/store';
import * as os from '@/os'; import * as os from '@/os';
@ -57,7 +56,7 @@ export function selectFile(src: any, label: string | null, multiple = false) {
}; };
const chooseFileFromDrive = () => { const chooseFileFromDrive = () => {
selectDriveFile(multiple).then(files => { os.selectDriveFile(multiple).then(files => {
res(files); res(files);
}); });
}; };

View file

@ -44,7 +44,7 @@ import DeckColumnCore from '@/components/deck/column-core.vue';
import DeckColumn from '@/components/deck/column.vue'; import DeckColumn from '@/components/deck/column.vue';
import XSidebar from '@/components/sidebar.vue'; import XSidebar from '@/components/sidebar.vue';
import { getScrollContainer } from '@/scripts/scroll'; import { getScrollContainer } from '@/scripts/scroll';
import * as os from './os'; import * as os from '@/os';
export default defineComponent({ export default defineComponent({
components: { components: {

View file

@ -93,10 +93,10 @@ import { v4 as uuid } from 'uuid';
import { host } from '@/config'; import { host } from '@/config';
import { search } from '@/scripts/search'; import { search } from '@/scripts/search';
import { StickySidebar } from '@/scripts/sticky-sidebar'; import { StickySidebar } from '@/scripts/sticky-sidebar';
import { widgets } from './widgets'; import { widgets } from '@/widgets';
import XSidebar from '@/components/sidebar.vue'; import XSidebar from '@/components/sidebar.vue';
import { Autocomplete } from '@/scripts/autocomplete'; import { Autocomplete } from '@/scripts/autocomplete';
import * as os from './os'; import * as os from '@/os';
const DESKTOP_THRESHOLD = 1100; const DESKTOP_THRESHOLD = 1100;