Skip to content

Commit

Permalink
feat: add env
Browse files Browse the repository at this point in the history
  • Loading branch information
wushengzhu committed Oct 30, 2023
1 parent e8f96f1 commit 05d2ef2
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 11 deletions.
1 change: 1 addition & 0 deletions .env.development
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_NODE_ENV = 'development'
1 change: 1 addition & 0 deletions .env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_NODE_ENV = 'production'
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vue-tsc && vite build",
"dev": "vite --mode development",
"build": "vue-tsc && vite build --mode production",
"preview": "vite preview",
"bash": "bash deploy.sh"
},
Expand Down
34 changes: 25 additions & 9 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,31 @@ onMounted(() => {
getLunarTime()
})
// 屏蔽右键
// document.oncontextmenu = () => {
// ElMessage({
// message: "为了浏览体验,本站禁用右键",
// grouping: true,
// duration: 2000
// });
// return false;
// };
if (import.meta.env.VITE_NODE_ENV === 'production') {
console.log(import.meta.env)
// 屏蔽右键
document.oncontextmenu = () => {
ElMessage({
message: '为了浏览体验,本站禁用右键',
grouping: true,
duration: 2000,
})
return false
}
document.addEventListener('keydown', (e) => {
// 禁止f12,禁用ctrl+shift+i,禁用shift+f10
if (
e.code === 'F12' ||
(e.ctrlKey && e.shiftKey && e.code === 'KeyI') ||
(e.shiftKey && e.code === 'F10')
) {
e.preventDefault()
}
})
setInterval(() => {
debugger
}, 1000)
}
})
// 监听当前页面宽度
Expand Down
3 changes: 3 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ export default ({ mode }) =>
},
}),
],
build: {
sourcemap: 'hidden',
},
resolve: {
alias: [
{
Expand Down

0 comments on commit 05d2ef2

Please sign in to comment.