summaryrefslogtreecommitdiff
path: root/src/client/app/desktop/api/choose-drive-file.ts
blob: a362a1289b82c4f86805499c304593231cb57023 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import OS from '../../mios';
import { url } from '../../config';
import MkChooseFileFromDriveWindow from '../views/components/choose-file-from-drive-window.vue';

export default (os: OS) => opts => {
	return new Promise((res, rej) => {
		const o = opts || {};

		if (document.body.clientWidth > 800) {
			const w = os.new(MkChooseFileFromDriveWindow, {
				title: o.title,
				multiple: o.multiple,
				initFolder: o.currentFolder
			});
			w.$once('selected', file => {
				res(file);
			});
			document.body.appendChild(w.$el);
		} else {
			window['cb'] = file => {
				res(file);
			};

			window.open(url + `/selectdrive?multiple=${o.multiple}`,
				'choose_drive_window',
				'height=500, width=800');
		}
	});
};