diff --git a/.gitignore b/.gitignore index 722d5e71..5680164d 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .vscode +nohup.out diff --git a/README.md b/README.md index 2cc178d6..a7d2a64f 100644 --- a/README.md +++ b/README.md @@ -9,14 +9,18 @@ 4. 不需要更多花哨功能,简单够用就行 5. 尽量少依赖三方库,也不花心思维护,杂凑在一起的功能,恰好工作即可 ^_^ -## 使用 -+ 后端: `cd backend; node main.js` -+ 后端: `cd frontend; yarn run dev` +## 直接使用 ++ `cd backend; yarn; node main.js` ++ 访问 `http://localhost:3000` + 新增文件:`双击目录` + 删除文件/目录:`shift + 右键文件/目录` + 重命名文件/目录:`ctrl + 右键文件/目录` + 文件加密:以 `.c.md` 结尾的文件视为加密文件 +## 开发 ++ 后端: `cd backend; node main.js` ++ 后端: `cd frontend; yarn run dev` + ## 开发计划 + [x] 回收站 @@ -29,8 +33,8 @@ + [x] 图片粘贴预览 + [x] 未保存切换文件自动保存 + [x] 密码输入优化 ++ [x] nodejs静态文件 + [ ] 认证 -+ [ ] nodejs静态文件 + [ ] 全文查找 Ctrl + p + [ ] 微信结合 + [ ] git备份 diff --git a/backend/main.js b/backend/main.js index 326f9af3..58f96401 100644 --- a/backend/main.js +++ b/backend/main.js @@ -1,5 +1,7 @@ +const path = require('path') const Koa = require('koa') const bodyParser = require('koa-body') +const static = require('koa-static') const mime = require('mime') const file = require('./file') @@ -46,6 +48,10 @@ const attachment = (ctx, next) => { const app = new Koa() +app.use(static( + path.join(__dirname, '../static') +)) + app.use(bodyParser({multipart: true})) app.use(async (ctx, next) => fileContent(ctx, next)) app.use(async (ctx, next) => attachment(ctx, next)) diff --git a/backend/package.json b/backend/package.json index 12fd08f4..d6954e67 100644 --- a/backend/package.json +++ b/backend/package.json @@ -2,6 +2,7 @@ "dependencies": { "koa": "^2.4.1", "koa-body": "^2.5.0", + "koa-static": "^4.0.2", "mime": "^2.2.0" } } diff --git a/backend/yarn.lock b/backend/yarn.lock index c969fba2..0be5d82a 100644 --- a/backend/yarn.lock +++ b/backend/yarn.lock @@ -9,7 +9,7 @@ accepts@^1.2.2: mime-types "~2.1.16" negotiator "0.6.1" -any-promise@^1.1.0: +any-promise@^1.0.0, any-promise@^1.1.0: version "1.3.0" resolved "http://registry.npm.taobao.org/any-promise/download/any-promise-1.3.0.tgz#abc6afeedcea52e809cdc0376aed3ce39635d17f" @@ -51,6 +51,12 @@ debug@*: dependencies: ms "2.0.0" +debug@^2.6.3, debug@^2.6.8: + version "2.6.9" + resolved "http://registry.npm.taobao.org/debug/download/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" + dependencies: + ms "2.0.0" + deep-equal@~1.0.1: version "1.0.1" resolved "http://registry.npm.taobao.org/deep-equal/download/deep-equal-1.0.1.tgz#f5d260292b660e084eff4cdbc9f08ad3247448b5" @@ -98,7 +104,7 @@ http-assert@^1.1.0: deep-equal "~1.0.1" http-errors "~1.6.1" -http-errors@1.6.2, http-errors@^1.2.8, http-errors@~1.6.1: +http-errors@1.6.2, http-errors@^1.2.8, http-errors@^1.6.1, http-errors@~1.6.1, http-errors@~1.6.2: version "1.6.2" resolved "http://registry.npm.taobao.org/http-errors/download/http-errors-1.6.2.tgz#0a002cc85707192a7e7946ceedc11155f60ec736" dependencies: @@ -155,6 +161,22 @@ koa-is-json@^1.0.0: version "1.0.0" resolved "http://registry.npm.taobao.org/koa-is-json/download/koa-is-json-1.0.0.tgz#273c07edcdcb8df6a2c1ab7d59ee76491451ec14" +koa-send@^4.1.0: + version "4.1.3" + resolved "http://registry.npm.taobao.org/koa-send/download/koa-send-4.1.3.tgz#0822207bbf5253a414c8f1765ebc29fa41353cb6" + dependencies: + debug "^2.6.3" + http-errors "^1.6.1" + mz "^2.6.0" + resolve-path "^1.4.0" + +koa-static@^4.0.2: + version "4.0.2" + resolved "http://registry.npm.taobao.org/koa-static/download/koa-static-4.0.2.tgz#6cda92d88d771dcaad9f0d825cd94a631c861a1a" + dependencies: + debug "^2.6.8" + koa-send "^4.1.0" + koa@^2.4.1: version "2.4.1" resolved "http://registry.npm.taobao.org/koa/download/koa-2.4.1.tgz#d449cfb970a7e9da571f699eda40bb9e32eb1484" @@ -206,10 +228,22 @@ ms@2.0.0: version "2.0.0" resolved "http://registry.npm.taobao.org/ms/download/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" +mz@^2.6.0: + version "2.7.0" + resolved "http://registry.npm.taobao.org/mz/download/mz-2.7.0.tgz#95008057a56cafadc2bc63dde7f9ff6955948e32" + dependencies: + any-promise "^1.0.0" + object-assign "^4.0.1" + thenify-all "^1.0.0" + negotiator@0.6.1: version "0.6.1" resolved "http://registry.npm.taobao.org/negotiator/download/negotiator-0.6.1.tgz#2b327184e8992101177b28563fb5e7102acd0ca9" +object-assign@^4.0.1: + version "4.1.1" + resolved "http://registry.npm.taobao.org/object-assign/download/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" + on-finished@^2.1.0: version "2.3.0" resolved "http://registry.npm.taobao.org/on-finished/download/on-finished-2.3.0.tgz#20f1336481b083cd75337992a16971aa2d906947" @@ -224,6 +258,10 @@ parseurl@^1.3.0: version "1.3.2" resolved "http://registry.npm.taobao.org/parseurl/download/parseurl-1.3.2.tgz#fc289d4ed8993119460c156253262cdc8de65bf3" +path-is-absolute@1.0.1: + version "1.0.1" + resolved "http://registry.npm.taobao.org/path-is-absolute/download/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" + qs@^6.4.0: version "6.5.1" resolved "http://registry.npm.taobao.org/qs/download/qs-6.5.1.tgz#349cdf6eef89ec45c12d7d5eb3fc0c870343a6d8" @@ -237,6 +275,13 @@ raw-body@^2.2.0: iconv-lite "0.4.19" unpipe "1.0.0" +resolve-path@^1.4.0: + version "1.4.0" + resolved "http://registry.npm.taobao.org/resolve-path/download/resolve-path-1.4.0.tgz#c4bda9f5efb2fce65247873ab36bb4d834fe16f7" + dependencies: + http-errors "~1.6.2" + path-is-absolute "1.0.1" + setprototypeof@1.0.3: version "1.0.3" resolved "http://registry.npm.taobao.org/setprototypeof/download/setprototypeof-1.0.3.tgz#66567e37043eeb4f04d91bd658c0cbefb55b8e04" @@ -245,6 +290,18 @@ setprototypeof@1.0.3: version "1.4.0" resolved "http://registry.npm.taobao.org/statuses/download/statuses-1.4.0.tgz#bb73d446da2796106efcc1b601a253d6c46bd087" +thenify-all@^1.0.0: + version "1.6.0" + resolved "http://registry.npm.taobao.org/thenify-all/download/thenify-all-1.6.0.tgz#1a1918d402d8fc3f98fbf234db0bcc8cc10e9726" + dependencies: + thenify ">= 3.1.0 < 4" + +"thenify@>= 3.1.0 < 4": + version "3.3.0" + resolved "http://registry.npm.taobao.org/thenify/download/thenify-3.3.0.tgz#e69e38a1babe969b0108207978b9f62b88604839" + dependencies: + any-promise "^1.0.0" + type-is@^1.5.5, type-is@^1.6.14: version "1.6.15" resolved "http://registry.npm.taobao.org/type-is/download/type-is-1.6.15.tgz#cab10fb4909e441c82842eafe1ad646c81804410" diff --git a/frontend/build/webpack.prod.conf.js b/frontend/build/webpack.prod.conf.js index d9f99f65..9d037a39 100644 --- a/frontend/build/webpack.prod.conf.js +++ b/frontend/build/webpack.prod.conf.js @@ -32,6 +32,10 @@ const webpackConfig = merge(baseWebpackConfig, { new webpack.DefinePlugin({ 'process.env': env }), + new CopyWebpackPlugin([{ + from: 'node_modules/monaco-editor/min/vs', + to: 'vs', + }]), new UglifyJsPlugin({ uglifyOptions: { compress: { @@ -46,7 +50,7 @@ const webpackConfig = merge(baseWebpackConfig, { filename: utils.assetsPath('css/[name].[contenthash].css'), // Setting the following option to `false` will not extract CSS from codesplit chunks. // Their CSS will instead be inserted dynamically with style-loader when the codesplit chunk has been loaded by webpack. - // It's currently set to `true` because we are seeing that sourcemaps are included in the codesplit bundle as well when it's `false`, + // It's currently set to `true` because we are seeing that sourcemaps are included in the codesplit bundle as well when it's `false`, // increasing file size: https://github.com/vuejs-templates/webpack/issues/1110 allChunks: true, }), diff --git a/frontend/package.json b/frontend/package.json index fb3bc20f..b978d7a4 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -8,7 +8,8 @@ "dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js", "start": "npm run dev", "lint": "eslint --ext .js,.vue src", - "build": "node build/build.js" + "build": "node build/build.js", + "dist": "npm run build && cp -r dist/* ../static/" }, "dependencies": { "crypto-js": "^3.1.9-1",