├── LICENSE ├── README.md ├── about.html ├── assets ├── android-chrome-96x96.png ├── apple-touch-icon.png ├── browserconfig.xml ├── favicon-16x16.png ├── favicon-32x32.png ├── favicon.ico ├── img-placeholder.svg ├── mstile-150x150.png ├── safari-pinned-tab.svg └── site.webmanifest ├── index.html ├── main.js └── style.css /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Guo Shuai 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # [IMG-Paste](https://zjuguoshuai.github.io/img-paste/) 2 | 3 | 直接粘贴截图获得外链,自动生成 Markdown 图片格式并复制到系统剪贴板。 4 | 5 | !!! 目前网站不可用,详情见 https://github.com/ZJUGuoShuai/img-paste/issues/6 6 | 7 | 8 | 9 | 本仓库使用[SM.MS](https://sm.ms/)公共图床API。 10 | 11 | ![github.gif](https://i.loli.net/2019/03/30/5c9f2ea0bfc04.gif) 12 | 13 | 已测试支持截图类型: 14 | 15 | - QQ/TIM/微信截图 16 | - Windows 10 系统截图(Win+Shift+S) 17 | - Firefox 自带截图 18 | - Flameshot 截图 19 | - macOS 系统截图(+++3/4) 20 | 21 | 基于 *Bootstrap* 和 *Vue* 构建前端页面。 22 | 23 | ## 替代品 24 | 25 | 如果遇到 SM.MS 访问速度不稳或加载失败,可以选择 [im.sb](https://im.sb/),此图床也支持粘贴截图上传。 26 | -------------------------------------------------------------------------------- /about.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 13 | 14 | 15 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | IMG-Paste 26 | 27 | 28 | 29 | 30 | 54 | 55 | 56 |
57 | 63 |

关于

64 |

粘贴截图,获得 Markdown 链接。如果你想上传本机图片,请直接访问 SM.MS

65 |

通过 Bootstrap 和 Vue 构建,欢迎 PR 让本站变得更好!

66 | 67 |

About

68 |

Paste your screenshot and get the Markdown image link. If you want to upload existing images in your host, go straight to SM.MS.

69 |

Built on Bootstrap and Vue.js, PR welcomed!

70 |
71 | 72 | 73 | 74 | 82 | 83 | 84 | 85 | 86 | 89 | 92 | 95 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /assets/android-chrome-96x96.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZJUGuoShuai/img-paste/c7d9547fe1692ec96a48e57d9dd020792c3e6460/assets/android-chrome-96x96.png -------------------------------------------------------------------------------- /assets/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZJUGuoShuai/img-paste/c7d9547fe1692ec96a48e57d9dd020792c3e6460/assets/apple-touch-icon.png -------------------------------------------------------------------------------- /assets/browserconfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | #da532c 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /assets/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZJUGuoShuai/img-paste/c7d9547fe1692ec96a48e57d9dd020792c3e6460/assets/favicon-16x16.png -------------------------------------------------------------------------------- /assets/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZJUGuoShuai/img-paste/c7d9547fe1692ec96a48e57d9dd020792c3e6460/assets/favicon-32x32.png -------------------------------------------------------------------------------- /assets/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZJUGuoShuai/img-paste/c7d9547fe1692ec96a48e57d9dd020792c3e6460/assets/favicon.ico -------------------------------------------------------------------------------- /assets/img-placeholder.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /assets/mstile-150x150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZJUGuoShuai/img-paste/c7d9547fe1692ec96a48e57d9dd020792c3e6460/assets/mstile-150x150.png -------------------------------------------------------------------------------- /assets/safari-pinned-tab.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | Created by potrace 1.11, written by Peter Selinger 2001-2013 9 | 10 | 12 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /assets/site.webmanifest: -------------------------------------------------------------------------------- 1 | { 2 | "name": "", 3 | "short_name": "", 4 | "icons": [ 5 | { 6 | "src": "/android-chrome-96x96.png", 7 | "sizes": "96x96", 8 | "type": "image/png" 9 | } 10 | ], 11 | "theme_color": "#ffffff", 12 | "background_color": "#ffffff", 13 | "display": "standalone" 14 | } 15 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 13 | 14 | 15 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | IMG-Paste 26 | 27 | 28 | 29 | 30 | 55 | 56 | 57 |
58 |
59 |
60 |
61 |

Press {{controls}} + V to paste your 62 | screenshot here.

63 | 64 |
65 |

Status: {{ status }} 66 |

67 |

URL: {{ url }}

68 |

Delete URL: 69 | {{ deleteurl }}
请妥善保管好您的所有链接~

70 |
71 | 73 | 75 |
76 |
77 |
78 |
79 |
80 |
81 | 82 | 83 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 107 | 110 | 113 | 114 | 115 | -------------------------------------------------------------------------------- /main.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | let app = new Vue({ 4 | el: "#app", 5 | data: { 6 | status: "Ready.", 7 | url: "None.", 8 | deleteurl: "None.", 9 | alertType: "alert-success", 10 | copyBtnDisable: true 11 | }, 12 | computed: { 13 | controls: () => { 14 | if (navigator.platform === "MacIntel") { 15 | return "⌘"; 16 | } 17 | return "Ctrl"; 18 | } 19 | }, 20 | methods: { 21 | markdowncopyToClip: () => { 22 | let el = document.createElement("textarea"); 23 | el.value = app.url; 24 | document.body.appendChild(el); 25 | el.select(); 26 | document.execCommand("copy"); 27 | document.body.removeChild(el); 28 | app.status = "[OK] Markdown Link Copied to system clipboard."; 29 | }, 30 | deletecopyToClip: () => { 31 | let el = document.createElement("textarea"); 32 | el.value = app.deleteurl; 33 | document.body.appendChild(el); 34 | el.select(); 35 | document.execCommand("copy"); 36 | document.body.removeChild(el); 37 | app.status = "[OK] Delete Link copied to system clipboard."; 38 | } 39 | } 40 | }); 41 | 42 | document.addEventListener("paste", event => { 43 | let blob; 44 | app.status = "Processing..."; 45 | app.alertType = "alert-warning"; 46 | app.copyBtnDisable = true; 47 | 48 | if (event.clipboardData || event.originalEvent) { 49 | let clipboardData = 50 | event.clipboardData || event.originalEvent.clipboardData; 51 | if (clipboardData.items) { 52 | for (let i = 0; i < clipboardData.items.length; i++) { 53 | if (clipboardData.items[i].type.indexOf("image") !== -1) { 54 | blob = clipboardData.items[i].getAsFile(); 55 | } 56 | } 57 | } 58 | } 59 | let render = new FileReader(); 60 | render.onload = event => { 61 | let base64 = event.target.result; 62 | document.getElementById("img").setAttribute("src", base64); 63 | }; 64 | try { 65 | render.readAsDataURL(blob); 66 | } catch (error) { 67 | app.status = "[Error] Sorry, you didn't paste an image."; 68 | app.alertType = "alert-warning"; 69 | return; 70 | } 71 | 72 | let formData = new FormData(); 73 | formData.append("smfile", blob); 74 | 75 | axios 76 | .post("https://sm.ms/api/upload", formData) 77 | .then(response => { 78 | let r = response.data; 79 | if (r.code == "success") { 80 | app.status = "[OK] Upload finished."; 81 | app.alertType = "alert-success"; 82 | app.url = `![](${r.data.url})`; 83 | app.deleteurl = `${r.data.delete}`; 84 | app.copyBtnDisable = false; 85 | } else { 86 | app.status = `[Error: ${r.msg}] Upload failed. `; 87 | app.alertType = "alert-danger"; 88 | } 89 | }) 90 | .catch(error => { 91 | app.status = `[Error: ${error}] Upload failed. `; 92 | app.alertType = "alert-danger"; 93 | }); 94 | }); 95 | -------------------------------------------------------------------------------- /style.css: -------------------------------------------------------------------------------- 1 | body { 2 | padding-bottom: 70px; 3 | } 4 | 5 | footer { 6 | color: white; 7 | } 8 | 9 | .bg-black { 10 | background-color: #000; 11 | } 12 | 13 | .navbar-brand { 14 | font-weight: bold; 15 | font-style: italic; 16 | } 17 | 18 | a.nav-link:hover{ 19 | border-bottom: 0.2em solid white; 20 | margin-bottom: -0.2em; 21 | } 22 | 23 | #img { 24 | max-width: 90%; 25 | margin: 0 auto; 26 | } 27 | 28 | .alert { 29 | margin: auto; display: table; 30 | } --------------------------------------------------------------------------------