wip
This commit is contained in:
		
							parent
							
								
									edeeca8b5f
								
							
						
					
					
						commit
						0397a5046d
					
				|  | @ -71,8 +71,6 @@ const ok = async () => { | |||
| 		}); | ||||
| 	}); | ||||
| 
 | ||||
| 	os.promiseDialog(promise); | ||||
| 
 | ||||
| 	const f = await promise; | ||||
| 
 | ||||
| 	emit('ok', f); | ||||
|  |  | |||
|  | @ -67,33 +67,32 @@ watch(description, () => { | |||
| 	}); | ||||
| }); | ||||
| 
 | ||||
| function setAvatar(ev) { | ||||
| 	os.chooseFileFromPc({ multiple: false }).then(async (files) => { | ||||
| 		const file = files[0]; | ||||
| async function setAvatar(ev) { | ||||
| 	const files = await os.chooseFileFromPc({ multiple: false }); | ||||
| 	const file = files[0]; | ||||
| 
 | ||||
| 		let originalOrCropped = file; | ||||
| 	let originalOrCropped = file; | ||||
| 
 | ||||
| 		const { canceled } = await os.confirm({ | ||||
| 			type: 'question', | ||||
| 			text: i18n.ts.cropImageAsk, | ||||
| 			okText: i18n.ts.cropYes, | ||||
| 			cancelText: i18n.ts.cropNo, | ||||
| 		}); | ||||
| 
 | ||||
| 		if (!canceled) { | ||||
| 			originalOrCropped = await os.cropImageFile(file, { | ||||
| 				aspectRatio: 1, | ||||
| 			}); | ||||
| 		} | ||||
| 
 | ||||
| 		const driveFile = (await os.launchUploader([originalOrCropped], {}))[0]; | ||||
| 
 | ||||
| 		const i = await os.apiWithDialog('i/update', { | ||||
| 			avatarId: driveFile.id, | ||||
| 		}); | ||||
| 		$i.avatarId = i.avatarId; | ||||
| 		$i.avatarUrl = i.avatarUrl; | ||||
| 	const { canceled } = await os.confirm({ | ||||
| 		type: 'question', | ||||
| 		text: i18n.ts.cropImageAsk, | ||||
| 		okText: i18n.ts.cropYes, | ||||
| 		cancelText: i18n.ts.cropNo, | ||||
| 	}); | ||||
| 
 | ||||
| 	if (!canceled) { | ||||
| 		originalOrCropped = await os.cropImageFile(file, { | ||||
| 			aspectRatio: 1, | ||||
| 		}); | ||||
| 	} | ||||
| 
 | ||||
| 	const driveFile = (await os.launchUploader([originalOrCropped], {}))[0]; | ||||
| 
 | ||||
| 	const i = await os.apiWithDialog('i/update', { | ||||
| 		avatarId: driveFile.id, | ||||
| 	}); | ||||
| 	$i.avatarId = i.avatarId; | ||||
| 	$i.avatarUrl = i.avatarUrl; | ||||
| } | ||||
| </script> | ||||
| 
 | ||||
|  |  | |||
|  | @ -257,54 +257,100 @@ function save() { | |||
| } | ||||
| 
 | ||||
| function changeAvatar(ev) { | ||||
| 	selectFile(ev.currentTarget ?? ev.target, i18n.ts.avatar).then(async (file) => { | ||||
| 		let originalOrCropped = file; | ||||
| 
 | ||||
| 		const { canceled } = await os.confirm({ | ||||
| 			type: 'question', | ||||
| 			text: i18n.ts.cropImageAsk, | ||||
| 			okText: i18n.ts.cropYes, | ||||
| 			cancelText: i18n.ts.cropNo, | ||||
| 		}); | ||||
| 
 | ||||
| 		if (!canceled) { | ||||
| 			originalOrCropped = await os.createCroppedImageDriveFileFromImageDriveFile(file, { | ||||
| 				aspectRatio: 1, | ||||
| 			}); | ||||
| 		} | ||||
| 
 | ||||
| 	async function done(driveFile) { | ||||
| 		const i = await os.apiWithDialog('i/update', { | ||||
| 			avatarId: originalOrCropped.id, | ||||
| 			avatarId: driveFile.id, | ||||
| 		}); | ||||
| 		$i.avatarId = i.avatarId; | ||||
| 		$i.avatarUrl = i.avatarUrl; | ||||
| 		claimAchievement('profileFilled'); | ||||
| 	}); | ||||
| 	} | ||||
| 
 | ||||
| 	os.popupMenu([{ | ||||
| 		text: i18n.ts.avatar, | ||||
| 		type: 'label', | ||||
| 	}, { | ||||
| 		text: i18n.ts.upload, | ||||
| 		icon: 'ti ti-upload', | ||||
| 		action: async () => { | ||||
| 			const files = await os.chooseFileFromPc({ multiple: false }); | ||||
| 			const file = files[0]; | ||||
| 
 | ||||
| 			let originalOrCropped = file; | ||||
| 
 | ||||
| 			const { canceled } = await os.confirm({ | ||||
| 				type: 'question', | ||||
| 				text: i18n.ts.cropImageAsk, | ||||
| 				okText: i18n.ts.cropYes, | ||||
| 				cancelText: i18n.ts.cropNo, | ||||
| 			}); | ||||
| 
 | ||||
| 			if (!canceled) { | ||||
| 				originalOrCropped = await os.cropImageFile(file, { | ||||
| 					aspectRatio: 1, | ||||
| 				}); | ||||
| 			} | ||||
| 
 | ||||
| 			const driveFile = (await os.launchUploader([originalOrCropped], {}))[0]; | ||||
| 			done(driveFile); | ||||
| 		}, | ||||
| 	}, { | ||||
| 		text: i18n.ts.fromDrive, | ||||
| 		icon: 'ti ti-cloud', | ||||
| 		action: () => { | ||||
| 			os.selectDriveFile(false).then(files => { | ||||
| 				done(files[0]); | ||||
| 			}); | ||||
| 		}, | ||||
| 	}], ev.currentTarget ?? ev.target); | ||||
| } | ||||
| 
 | ||||
| function changeBanner(ev) { | ||||
| 	selectFile(ev.currentTarget ?? ev.target, i18n.ts.banner).then(async (file) => { | ||||
| 		let originalOrCropped = file; | ||||
| 
 | ||||
| 		const { canceled } = await os.confirm({ | ||||
| 			type: 'question', | ||||
| 			text: i18n.ts.cropImageAsk, | ||||
| 			okText: i18n.ts.cropYes, | ||||
| 			cancelText: i18n.ts.cropNo, | ||||
| 		}); | ||||
| 
 | ||||
| 		if (!canceled) { | ||||
| 			originalOrCropped = await os.createCroppedImageDriveFileFromImageDriveFile(file, { | ||||
| 				aspectRatio: 2, | ||||
| 			}); | ||||
| 		} | ||||
| 
 | ||||
| 	async function done(driveFile) { | ||||
| 		const i = await os.apiWithDialog('i/update', { | ||||
| 			bannerId: originalOrCropped.id, | ||||
| 			bannerId: driveFile.id, | ||||
| 		}); | ||||
| 		$i.bannerId = i.bannerId; | ||||
| 		$i.bannerUrl = i.bannerUrl; | ||||
| 	}); | ||||
| 	} | ||||
| 
 | ||||
| 	os.popupMenu([{ | ||||
| 		text: i18n.ts.banner, | ||||
| 		type: 'label', | ||||
| 	}, { | ||||
| 		text: i18n.ts.upload, | ||||
| 		icon: 'ti ti-upload', | ||||
| 		action: async () => { | ||||
| 			const files = await os.chooseFileFromPc({ multiple: false }); | ||||
| 			const file = files[0]; | ||||
| 
 | ||||
| 			let originalOrCropped = file; | ||||
| 
 | ||||
| 			const { canceled } = await os.confirm({ | ||||
| 				type: 'question', | ||||
| 				text: i18n.ts.cropImageAsk, | ||||
| 				okText: i18n.ts.cropYes, | ||||
| 				cancelText: i18n.ts.cropNo, | ||||
| 			}); | ||||
| 
 | ||||
| 			if (!canceled) { | ||||
| 				originalOrCropped = await os.cropImageFile(file, { | ||||
| 					aspectRatio: 2, | ||||
| 				}); | ||||
| 			} | ||||
| 
 | ||||
| 			const driveFile = (await os.launchUploader([originalOrCropped], {}))[0]; | ||||
| 			done(driveFile); | ||||
| 		}, | ||||
| 	}, { | ||||
| 		text: i18n.ts.fromDrive, | ||||
| 		icon: 'ti ti-cloud', | ||||
| 		action: () => { | ||||
| 			os.selectDriveFile(false).then(files => { | ||||
| 				done(files[0]); | ||||
| 			}); | ||||
| 		}, | ||||
| 	}], ev.currentTarget ?? ev.target); | ||||
| } | ||||
| 
 | ||||
| const headerActions = computed(() => []); | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue