Skip to content

Commit

Permalink
修改源码目录配置
Browse files Browse the repository at this point in the history
  • Loading branch information
im3x-dev committed Nov 2, 2020
1 parent cc7ad75 commit 67525f7
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 111 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ node_modules/
package-lock.json
Widget.js
「源码」*.js
.DS_File
.DS_File
Editors/
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@
交流群:
https://x.im3x.cn/images/qun1.jpeg

小程序:
![](https://x.im3x.cn/images/qr.png)

![](https://x.im3x.cn/images/qr2.png)
File renamed without changes.
11 changes: 6 additions & 5 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const bodyParser = require('body-parser')

const HTTP_PORT = 5566
const WORK_DIR = path.dirname(__filename)
const SCRIPTS_DIR = path.join(WORK_DIR, "Scripts")

const app = express()
const upload = multer({
Expand All @@ -27,13 +28,13 @@ app.get('/ping', (req, res) => {
})

let FILE_DATE = null
// const WIDGET_FILE = path.join(WORK_DIR, "Widget.js")

app.get('/sync', (req, res) => {
// console.log('[-] 等待同步到手机..')
const { name } = req.query

const WIDGET_FILE = path.join(WORK_DIR, name + '.js')
const WIDGET_FILE = path.join(SCRIPTS_DIR, name + '.js')
if (!fs.existsSync(WIDGET_FILE)) return res.send("nofile").end()

setTimeout(() => {
// 判断文件时间
Expand All @@ -57,20 +58,20 @@ app.post("/sync", (req, res) => {
console.log('[+] Scriptalbe App 已连接')
const _file = req.files[0]
const FILE_NAME = _file['originalname'] + '.js'
const WIDGET_FILE = path.join(WORK_DIR, FILE_NAME)
const WIDGET_FILE = path.join(SCRIPTS_DIR, FILE_NAME)
fs.renameSync(_file['path'], WIDGET_FILE)
res.send("ok")
console.log(`[*] 小组件源码(${_file['originalname']})已同步,请打开编辑`)
FILE_DATE = fs.statSync(WIDGET_FILE).mtimeMs
// 尝试打开
let cmd = `code ./"${FILE_NAME}"`
let cmd = `code "${WIDGET_FILE}"`
if (os.platform() === "win32") {
cmd = `cmd.exe /c ${cmd}`
} else if (os.platform() === "linux") {
let shell = process.env["SHELL"]
cmd = `${shell} -c ${cmd}`
} else {
cmd = `"/Applications/Visual Studio Code.app/Contents/MacOS/Electron" ./"${FILE_NAME}"`
cmd = `"/Applications/Visual Studio Code.app/Contents/MacOS/Electron" "${WIDGET_FILE}"`
}
child_process.execSync(cmd)
})
Expand Down
103 changes: 0 additions & 103 deletions 「小件件」小组件示例.js

This file was deleted.

0 comments on commit 67525f7

Please sign in to comment.