diff --git a/logo.png b/logo.png
deleted file mode 100644
index 5c5eefbb2..000000000
Binary files a/logo.png and /dev/null differ
diff --git a/package.json b/package.json
index 332c7f7d6..8f7ffd2e6 100644
--- a/package.json
+++ b/package.json
@@ -42,7 +42,7 @@
"keycode": "^2.2.0",
"lodash-id": "^0.14.0",
"lowdb": "^1.0.0",
- "picgo": "^1.4.5",
+ "picgo": "^1.4.6",
"vue": "^2.6.10",
"vue-gallery": "^2.0.1",
"vue-lazyload": "^1.2.6",
diff --git a/src/renderer/components/InputBoxDialog.vue b/src/renderer/components/InputBoxDialog.vue
index e1f977dd8..886a2ae2d 100644
--- a/src/renderer/components/InputBoxDialog.vue
+++ b/src/renderer/components/InputBoxDialog.vue
@@ -39,15 +39,15 @@ export default class extends Vue {
this.initInputBoxValue(options)
}
initInputBoxValue (options: IShowInputBoxOption) {
- this.inputBoxValue = ''
+ this.inputBoxValue = options.value || ''
this.inputBoxOptions.title = options.title || ''
this.inputBoxOptions.placeholder = options.placeholder || ''
this.showInputBoxVisible = true
}
handleInputBoxClose () {
// TODO: RPCServer
- ipcRenderer.send(SHOW_INPUT_BOX, this.inputBoxValue)
- this.$bus.$emit(SHOW_INPUT_BOX_RESPONSE, this.inputBoxValue)
+ ipcRenderer.send(SHOW_INPUT_BOX, '')
+ this.$bus.$emit(SHOW_INPUT_BOX_RESPONSE, '')
}
beforeDestroy () {
ipcRenderer.removeListener(SHOW_INPUT_BOX, this.ipcEventHandler)
diff --git a/src/renderer/pages/Upload.vue b/src/renderer/pages/Upload.vue
index 4428f9088..feacb4fc1 100644
--- a/src/renderer/pages/Upload.vue
+++ b/src/renderer/pages/Upload.vue
@@ -48,8 +48,8 @@
快捷上传
- 剪贴板
- URL
+ 剪贴板图片
+ URL
@@ -67,6 +67,9 @@ import {
SHOW_INPUT_BOX,
SHOW_INPUT_BOX_RESPONSE
} from '~/universal/events/constants'
+import {
+ isUrl
+} from '~/universal/utils/common'
const { Menu } = remote
@Component({
name: 'upload'
@@ -118,7 +121,34 @@ export default class extends Vue {
}
onDrop (e: DragEvent) {
this.dragover = false
- this.ipcSendFiles(e.dataTransfer!.files)
+ const items = e.dataTransfer!.items
+ if (items.length === 2 && items[0].type === 'text/uri-list') {
+ this.handleURLDrag(items, e.dataTransfer!)
+ } else if (items[0].type === 'text/plain') {
+ const str = e.dataTransfer!.getData(items[0].type)
+ if (isUrl(str)) {
+ ipcRenderer.send('uploadChoosedFiles', [{ path: str }])
+ } else {
+ this.$message.error('请拖入合法的图片文件或者图片URL地址')
+ }
+ } else {
+ this.ipcSendFiles(e.dataTransfer!.files)
+ }
+ }
+ handleURLDrag (items: DataTransferItemList, dataTransfer: DataTransfer) {
+ // text/html
+ // Use this data to get a more precise URL
+ const urlString = dataTransfer.getData(items[1].type)
+ const urlMatch = urlString.match(/
diff --git a/src/universal/types/types.d.ts b/src/universal/types/types.d.ts
index 32632d190..3305c1016 100644
--- a/src/universal/types/types.d.ts
+++ b/src/universal/types/types.d.ts
@@ -179,6 +179,7 @@ interface IGuiApi {
showMessageBox: (options?: IShowMessageBoxOption) => Promise
}
interface IShowInputBoxOption {
+ value?: string
title: string
placeholder: string
}
diff --git a/src/universal/utils/common.ts b/src/universal/utils/common.ts
new file mode 100644
index 000000000..36762c455
--- /dev/null
+++ b/src/universal/utils/common.ts
@@ -0,0 +1 @@
+export const isUrl = (url: string): boolean => (url.startsWith('http://') || url.startsWith('https://'))
diff --git a/yarn.lock b/yarn.lock
index 4e9ff0ab7..5e43266dc 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -8292,10 +8292,10 @@ performance-now@^2.1.0:
resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b"
integrity sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=
-picgo@^1.4.5:
- version "1.4.5"
- resolved "https://registry.yarnpkg.com/picgo/-/picgo-1.4.5.tgz#3579aea9017a68c4b1e80e7af9060eb70ab98a9a"
- integrity sha512-uef5tkOsswj6XJX2kYlUkuIPhaUS4PNSCMZ3IYgSCZvvxC4e1o8Qro4PIYlMAIEDPqP30OrKNab/wmaJxizv+g==
+picgo@^1.4.6:
+ version "1.4.6"
+ resolved "https://registry.yarnpkg.com/picgo/-/picgo-1.4.6.tgz#aa90439a253c5a07068b136a0d1426f63236735b"
+ integrity sha512-VNh5el0hkh0OrxqTPGkRAUtGmncr7cdKrjdvp6yf2Iwx+O+uJ4IHgKMmzAj+siJGTBENL0eWoujmzX07zAt30g==
dependencies:
chalk "^2.4.1"
commander "^2.17.0"