优化vite配置
This commit is contained in:
1 parent
17caf491f1
commit
84025a83ab
5 files changed
+60
-2
No files matched your search
@@ -8,5 +8,6 @@
|
|||||||
"cloudCapacity":2147483648
|
"cloudCapacity":2147483648
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"enableGuest":false
|
"enableGuest":false,
|
||||||
|
"tokenExpiresIn":168
|
||||||
}
|
}
|
||||||
@@ -12,6 +12,7 @@ import { v4 as uuid4 } from "uuid";
|
|||||||
import jwt from "jsonwebtoken";
|
import jwt from "jsonwebtoken";
|
||||||
import sha256 from "crypto-js/sha256.js";
|
import sha256 from "crypto-js/sha256.js";
|
||||||
import Config from './miaoShareConfig.json' assert { type: 'json' };
|
import Config from './miaoShareConfig.json' assert { type: 'json' };
|
||||||
|
import { verify } from "crypto";
|
||||||
// function loadJSON(path){
|
// function loadJSON(path){
|
||||||
// return JSON.parse(fs.readFileSync(path).toString());
|
// return JSON.parse(fs.readFileSync(path).toString());
|
||||||
// }
|
// }
|
||||||
@@ -327,13 +328,42 @@ app.post("/user/login", express.json(),function (req, res) {
|
|||||||
let userGroup = db_getPermissionGroup(id, pwdH);
|
let userGroup = db_getPermissionGroup(id, pwdH);
|
||||||
if (userGroup !== null) {
|
if (userGroup !== null) {
|
||||||
res.writeHead(200);
|
res.writeHead(200);
|
||||||
let token = jwt.sign({ id, pwd }, JWT_SK, { expiresIn: "168h" });
|
let token = jwt.sign({ id, pwd }, JWT_SK, { expiresIn: `${Config.tokenExpiresIn}h` });
|
||||||
res.end(JSON.stringify({ status: "Success", userGroup, token }));
|
res.end(JSON.stringify({ status: "Success", userGroup, token }));
|
||||||
} else {
|
} else {
|
||||||
res.end(JSON.stringify({ status: "Error" }));
|
res.end(JSON.stringify({ status: "Error" }));
|
||||||
}
|
}
|
||||||
// console.log(req)
|
// console.log(req)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
app.post("/user/refrashToken", express.json(),function (req, res) {
|
||||||
|
res.header("Access-Control-Allow-Origin", "*");
|
||||||
|
res.header("Access-Control-Allow-Headers", "*");
|
||||||
|
res.header("Access-Control-Allow-Methods", "POST");
|
||||||
|
// console.log(req.body)
|
||||||
|
let { token } = req.body;
|
||||||
|
console.log(req.body)
|
||||||
|
|
||||||
|
let verifyData = jwt.verify(token, JWT_SK);
|
||||||
|
if (verifyData.exp > parseInt(Date.now())) {
|
||||||
|
return res.status(401).json({ message: "Invalid token" });
|
||||||
|
}
|
||||||
|
let id = verifyData.id
|
||||||
|
let pwd = verifyData.pwd
|
||||||
|
let new_token = jwt.sign({ id, pwd }, JWT_SK, { expiresIn: `${Config.tokenExpiresIn}h` });
|
||||||
|
res.end(JSON.stringify({ status: "Success", token }));
|
||||||
|
// let pwdH = sha256(id + pwd).toString();
|
||||||
|
// let userGroup = db_getPermissionGroup(id, pwdH);
|
||||||
|
// if (userGroup !== null) {
|
||||||
|
// res.writeHead(200);
|
||||||
|
// let token = jwt.sign({ id, pwd }, JWT_SK, { expiresIn: `${Config.tokenExpiresIn}h` });
|
||||||
|
// res.end(JSON.stringify({ status: "Success", userGroup, token }));
|
||||||
|
// } else {
|
||||||
|
// res.end(JSON.stringify({ status: "Error" }));
|
||||||
|
// }
|
||||||
|
// console.log(req)
|
||||||
|
});
|
||||||
// app.all()
|
// app.all()
|
||||||
app.post("/file/upload", verifyToken, function (req, res) {
|
app.post("/file/upload", verifyToken, function (req, res) {
|
||||||
res.header("Access-Control-Allow-Origin", "*");
|
res.header("Access-Control-Allow-Origin", "*");
|
||||||
|
|||||||
@@ -100,6 +100,8 @@ onMounted(()=>{
|
|||||||
activePage.value = aP
|
activePage.value = aP
|
||||||
w()
|
w()
|
||||||
})
|
})
|
||||||
|
}else{
|
||||||
|
// 刷新token
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -4,7 +4,14 @@ import config from "../../miaoShareConfig.json"
|
|||||||
const userID = localStorage.getItem('userID');
|
const userID = localStorage.getItem('userID');
|
||||||
const userGroup = localStorage.getItem('userGroup');
|
const userGroup = localStorage.getItem('userGroup');
|
||||||
|
|
||||||
|
const tokenExpiresIn = config.tokenExpiresIn
|
||||||
|
if(!localStorage.getItem('tokenExpiredTime') ||
|
||||||
|
parseInt(localStorage.getItem('tokenExpiredTime')) < parseInt(Date.now())){
|
||||||
|
localStorage.removeItem('token')
|
||||||
|
}
|
||||||
|
|
||||||
const token = localStorage.getItem('token');
|
const token = localStorage.getItem('token');
|
||||||
|
|
||||||
// console.log(token)
|
// console.log(token)
|
||||||
|
|
||||||
var activeFuctionLocal = localStorage.getItem('activeFuction')
|
var activeFuctionLocal = localStorage.getItem('activeFuction')
|
||||||
|
|||||||
@@ -21,4 +21,22 @@ export default defineConfig({
|
|||||||
esbuild: {
|
esbuild: {
|
||||||
drop: ['console', 'debugger'],
|
drop: ['console', 'debugger'],
|
||||||
},
|
},
|
||||||
|
build: {
|
||||||
|
minify: true,
|
||||||
|
rollupOptions: {
|
||||||
|
output: {
|
||||||
|
// 打包输出的配置
|
||||||
|
manualChunks: id => {
|
||||||
|
// 这个ID,就是所有文件的绝对路径
|
||||||
|
if (id.includes("node_modules")) {
|
||||||
|
// 因为 node_modules 中的依赖通常是不会改变的
|
||||||
|
// 所以直接单独打包出去
|
||||||
|
// 这个return 的值就是打包的名称
|
||||||
|
// return id.split('node_modules')[1]
|
||||||
|
return "modules";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
Reference in new issue
Block a user