├── fileManager.js ├── .gitignore ├── uploads ├── 1.png └── 04C83953-C82D-43C3-AE96-E0A271419633.jpeg ├── index.html ├── package.json ├── app.js ├── backend.js ├── main.js └── public └── index.html /fileManager.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | package-lock.json 3 | secret_keys.js -------------------------------------------------------------------------------- /uploads/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RumbleKAT/WindowsAirdrop/HEAD/uploads/1.png -------------------------------------------------------------------------------- /uploads/04C83953-C82D-43C3-AE96-E0A271419633.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RumbleKAT/WindowsAirdrop/HEAD/uploads/04C83953-C82D-43C3-AE96-E0A271419633.jpeg -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | WindowsAirdrop 6 | 7 | 8 |
9 | 10 |
11 |
12 | 13 |
14 | 16 | 17 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "myapp", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "app.js", 6 | "scripts": { 7 | "start": "electron ." 8 | }, 9 | "author": "songmyeongjin", 10 | "license": "ISC", 11 | "dependencies": { 12 | "electron": "^7.2.4", 13 | "electron-reload": "^1.4.0", 14 | "express": "^4.16.4", 15 | "http": "0.0.0", 16 | "jquery": "^3.3.1", 17 | "multer": "^1.4.1", 18 | "node-powershell": "^3.3.1", 19 | "request": "^2.88.2" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app.js: -------------------------------------------------------------------------------- 1 | const { app, BrowserWindow } = require('electron') 2 | require('./backend') 3 | require('electron-reload')(__dirname,{ 4 | electron: require(`${__dirname}/node_modules/electron`) 5 | }); 6 | 7 | let win 8 | function createWindow(){ 9 | win = new BrowserWindow({width: 800, height: 600 , backgroundColor : "#fff", titleBarStyle : 'hiddenInset'}) 10 | win.loadURL(`file://${__dirname}/index.html`) 11 | win.webContents.openDevTools() 12 | win.setMenu(null) 13 | 14 | win.once('ready-to-show', ()=>{ 15 | win.show() 16 | }) 17 | 18 | win.on('closed', ()=>{ 19 | win = null 20 | }) 21 | } 22 | 23 | app.on('ready',createWindow) 24 | 25 | app.on('window-all-closed',()=>{ 26 | if(process.platform !== 'darwin'){ 27 | app.quit() 28 | } 29 | }) 30 | 31 | app.on('activate',()=>{ 32 | if(win === null){ 33 | createWindow() 34 | } 35 | }) -------------------------------------------------------------------------------- /backend.js: -------------------------------------------------------------------------------- 1 | const express = require('express') 2 | const http = require('http') 3 | const port = 8080; 4 | 5 | const server = express() 6 | const client = require('./secret_keys') 7 | const request = require('request') 8 | 9 | const multer = require('multer'); 10 | const storage = multer.diskStorage({ 11 | destination: function (req, file, cb) { 12 | cb(null, 'uploads/') 13 | }, 14 | filename: function (req, file, cb) { 15 | cb(null, new Date().valueOf() + path.extname(file.originalname)); 16 | } 17 | }) 18 | const upload = multer({ dest: 'uploads/', storage: storage}); 19 | 20 | server.use(express.json()) 21 | server.use(express.static('public')) 22 | server.use('/files', express.static('uploads')); 23 | 24 | 25 | server.get('/upload',(req,res)=>{ 26 | res.render('index.html'); 27 | }) 28 | 29 | server.post('/upload', upload.single('userfile'), function(req, res){ 30 | let fullUrl = req.protocol + '://' + req.get('host'); 31 | console.log('업로드 성공!...'); 32 | res.redirect(fullUrl); 33 | }); 34 | 35 | server.post('/shortenUrl',(req,res)=>{ 36 | let query = encodeURI(req.body.url) 37 | const option = { 38 | url : 'https://openapi.naver.com/v1/util/shorturl', 39 | form : {'url' : query}, 40 | headers : { 'X-Naver-Client-Id' : client.id, 41 | 'X-Naver-Client-Secret' : client.pw 42 | } 43 | } 44 | 45 | request.post(option, (err,response,body) => { 46 | if(!err && response.statusCode === 200){ 47 | res.json(body); 48 | }else{ 49 | res.status(response.statusCode).end(); 50 | console.log('error = ' + response.statusCode); 51 | } 52 | }) 53 | }) 54 | 55 | http.createServer(server).listen(port,()=>{ 56 | console.log('localhost:8080 is running...') 57 | }) -------------------------------------------------------------------------------- /main.js: -------------------------------------------------------------------------------- 1 | const shell = require('node-powershell'); 2 | var currentIP; 3 | let $ = require('jquery') 4 | console.log($('#shortenUrl')); 5 | const regExp = /([A-Za-z1-9.:])\w+/g; 6 | 7 | let ps = new shell({ 8 | executionPolicy: 'Bypass', 9 | noProfile: true 10 | }); 11 | 12 | function findIP(){ 13 | return new Promise((resolve) =>{ 14 | ps.addCommand('ipconfig') 15 | ps.invoke() 16 | .then(output => { 17 | let total_arr = output.match(regExp) 18 | let idx = total_arr.findIndex((element)=> element === 'IPv4') 19 | currentIP = 'http://' + total_arr.filter((element,index) => index > idx && index <= idx + 4).join("")+":8080"; 20 | resolve(currentIP); 21 | }) 22 | .catch(err => { 23 | console.log(err); 24 | ps.dispose(); 25 | }); 26 | }) 27 | } 28 | 29 | function ajax(url){ 30 | return new Promise((resolve)=>{ 31 | var req = new XMLHttpRequest(); 32 | req.open('POST','http://localhost:8080/shortenUrl',false) 33 | req.setRequestHeader('Content-Type','application/json;charset=UTF=8'); 34 | req.onreadystatechange = function(evt){ 35 | if(req.readyState === 4){ 36 | if(req.status === 200){ 37 | resolve(JSON.parse(JSON.parse(req.responseText))); 38 | } 39 | } 40 | } 41 | req.send(JSON.stringify({ 42 | 'url' : url 43 | })) 44 | }); 45 | } 46 | 47 | function InitPage(param){ 48 | document.getElementById('content').innerText = param 49 | ajax(param).then((result)=>{ 50 | console.log(result); 51 | document.getElementById('shortenUrl').innerText = result.result.url; 52 | }) 53 | } 54 | 55 | findIP().then((result)=>InitPage(result)); -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | First 7 | 8 | 9 | 10 |

Good!bb

11 | 14 | 17 | 18 |
19 |
20 | 21 | 22 |
23 |
24 | 25 |
26 | 27 | W3Schools 28 | 29 |
30 | 31 | 37 | 38 | 90 | 91 | --------------------------------------------------------------------------------