Skip to content

Commit

Permalink
更新vite
Browse files Browse the repository at this point in the history
  • Loading branch information
wangraoji committed Jul 7, 2023
1 parent eb0357f commit 924527d
Show file tree
Hide file tree
Showing 65 changed files with 564 additions and 291 deletions.
14 changes: 6 additions & 8 deletions .env.development
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
# 本地环境
NODE_ENV = development
VITE_NODE_ENV = development

# 标题
VUE_APP_TITLE = Meta LowCode(dev)
VITE_APP_TITLE = Meta LowCode(dev)

# 接口转发
VUE_APP_BASE_API = '/api'


VITE_APP_BASE_API = '/api'

# 接口地址
DEV_API_SERVER = http://localhost:8080
VITE_API_SERVER = 'http://192.168.18.29:7070/'

# 本地端口
VUE_APP_PORT = 8021
VITE_APP_PORT = 8022

# 是否开启代理
VUE_APP_PROXY = true
VITE_APP_PROXY = true
8 changes: 4 additions & 4 deletions .env.production
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# 生产环境
NODE_ENV = production
VITE_NODE_ENV = production

# 标题
VUE_APP_TITLE = Meta LowCode
VITE_APP_TITLE = Meta LowCode

# 接口转发
VUE_APP_BASE_API = '/'
VITE_APP_BASE_API = '/'

# 接口地址
DEV_API_SERVER = http://localhost:8080
VITE_API_SERVER = http://localhost:8080
4 changes: 2 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ module.exports = {
'no-unused-vars': 'off',
'vue/no-mutating-props': 'off',
'vue/no-unused-components': 'off',
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-console': import.meta.env.VITE_NODE_ENV === 'production' ? 'warn' : 'off',
'no-debugger': import.meta.env.VITE_NODE_ENV === 'production' ? 'warn' : 'off',
// 关闭驼峰命名规则
'vue/multi-word-component-names': 0

Expand Down
File renamed without changes.
111 changes: 111 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="./favicon.ico">
<title>vite title</title>
<script type="text/javascript">
document.write("<script src='config.js?"+new Date().getTime()+"'><\/script>");
</script>
</head>
<body>
<noscript>
<strong>We're sorry but vite title doesn't work properly without JavaScript
enabled. Please enable it to continue.</strong>
</noscript>
<script type="text/javascript">
var dark = window.localStorage.getItem('APP_DARK');
if(dark){
document.documentElement.classList.add("dark")
}
</script>
<div id="app" class="aminui">
<div class="app-loading">
<div class="app-loading__logo">
<img src="img/logo.png"/>
</div>
<div class="app-loading__loader"></div>
<div class="app-loading__title">vite title</div>
</div>
<style>
.app-loading {position: absolute;top:0px;left:0px;right:0px;bottom:0px;display: flex;justify-content: center;align-items: center;flex-direction: column;background: #fff;}
.app-loading__logo {margin-bottom: 30px;}
.app-loading__logo img {width: 90px;vertical-align: bottom;}
.app-loading__loader {box-sizing: border-box;width: 35px;height: 35px;border: 5px solid transparent;border-top-color: #000;border-radius: 50%;animation: .5s loader linear infinite;position: relative;}
.app-loading__loader:before {box-sizing: border-box;content: '';display: block;width: inherit;height: inherit;position: absolute;top: -5px;left: -5px;border: 5px solid #ccc;border-radius: 50%;opacity: .5;}
.app-loading__title {font-size: 24px;color: #333;margin-top: 30px;}
.dark .app-loading {background: #222225;}
.dark .app-loading__loader {border-top-color: #fff;}
.dark .app-loading__title {color: #d0d0d0;}
@keyframes loader {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
</style>
</div>
<!-- built files will be auto injected -->
</body>
<div id="versionCheck" style="display: none;position: absolute;z-index: 99;top:0;left:0;right:0;bottom:0;padding:40px;background:rgba(255,255,255,0.9);color: #333;">
<h2 style="line-height: 1;margin: 0;font-size: 24px;">当前使用的浏览器内核版本过低 :(</h2>
<p style="line-height: 1;margin: 0;font-size: 14px;margin-top: 20px;opacity: 0.8;">当前版本:<span id="versionCheck-type">--</span> <span id="versionCheck-version">--</span></p>
<p style="line-height: 1;margin: 0;font-size: 14px;margin-top: 10px;opacity: 0.8;">最低版本要求:Chrome 71+、Firefox 65+、Safari 12+、Edge 97+。</p>
<p style="line-height: 1;margin: 0;font-size: 14px;margin-top: 10px;opacity: 0.8;">请升级浏览器版本,或更换现代浏览器,如果你使用的是双核浏览器,请切换到极速/高速模式。</p>
</div>
<script type="module" src="/src/main.js"></script>
<script type="text/javascript">
function getBrowerInfo(){
var userAgent = window.navigator.userAgent;
var browerInfo = {
type: 'unknown',
version: 'unknown',
userAgent: userAgent
};
if(document.documentMode){
browerInfo.type = "IE"
browerInfo.version = document.documentMode + ''
}else if(indexOf(userAgent, "Firefox")){
browerInfo.type = "Firefox"
browerInfo.version = userAgent.match(/Firefox\/([\d.]+)/)[1]
}else if(indexOf(userAgent, "Opera")){
browerInfo.type = "Opera"
browerInfo.version = userAgent.match(/Opera\/([\d.]+)/)[1]
}else if(indexOf(userAgent, "Edg")){
browerInfo.type = "Edg"
browerInfo.version = userAgent.match(/Edg\/([\d.]+)/)[1]
}else if(indexOf(userAgent, "Chrome")){
browerInfo.type = "Chrome"
browerInfo.version = userAgent.match(/Chrome\/([\d.]+)/)[1]
}else if(indexOf(userAgent, "Safari")){
browerInfo.type = "Safari"
browerInfo.version = userAgent.match(/Safari\/([\d.]+)/)[1]
}
return browerInfo
}
function indexOf(userAgent, brower) {
return userAgent.indexOf(brower) > -1
}
function isSatisfyBrower(){
var minVer = {
"Chrome": 71,
"Firefox": 65,
"Safari": 12,
"Edg": 97,
"IE": 999
}
var browerInfo = getBrowerInfo()
var materVer = browerInfo.version.split('.')[0]
return materVer >= minVer[browerInfo.type]
}
if(!isSatisfyBrower()){
document.getElementById('versionCheck').style.display = 'block';
document.getElementById('versionCheck-type').innerHTML = getBrowerInfo().type;
document.getElementById('versionCheck-version').innerHTML = getBrowerInfo().version;
}
</script>
</html>
6 changes: 4 additions & 2 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{
"compilerOptions": {
"target": "es5",
"target": "esnext",
"module": "esnext",
"baseUrl": "./",
"moduleResolution": "node",
"paths": {
"@/*": ["src/*"]
"@/*": [
"src/*"
]
},
"lib": [
"esnext",
Expand Down
File renamed without changes.
25 changes: 13 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@
"version": "1.0.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build --report",
"lint": "vue-cli-service lint"
"dev": "vite",
"serve": "vite",
"start": "vite",
"preview": "vite preview",
"vite-build": "vite build"
},
"dependencies": {
"@element-plus/icons-vue": "2.0.10",
"@tinymce/tinymce-vue": "5.0.0",
"@vitejs/plugin-legacy": "^4.1.0",
"@vitejs/plugin-vue": "^4.2.3",
"axios": "1.3.4",
"china-area-data": "^5.0.1",
"codemirror": "5.65.5",
Expand All @@ -20,28 +24,25 @@
"element-plus": "2.2.32",
"mitt": "^3.0.0",
"nprogress": "0.2.0",
"qrcodejs2": "0.0.2",
"pinia": "^2.0.35",
"qrcodejs2-fix": "^0.0.1",
"sortablejs": "1.15.0",
"tinymce": "6.3.2",
"vue": "3.2.47",
"vue": "^3.2.47",
"vue-i18n": "9.2.2",
"vue-router": "4.1.6",
"vue3-quill": "0.2.6",
"vuedraggable": "4.0.3",
"vuex": "4.1.0",
"xgplayer": "2.32.2",
"xgplayer-hls": "2.5.2"
"vuex": "^4.1.0"
},
"devDependencies": {
"@babel/core": "7.21.00",
"@babel/eslint-parser": "7.19.1",
"@vue/cli-plugin-babel": "5.0.8",
"@vue/cli-plugin-eslint": "5.0.8",
"@vue/cli-service": "5.0.8",
"eslint": "8.35.0",
"eslint-plugin-vue": "9.9.0",
"sass": "1.58.3",
"sass-loader": "10.1.1"
"sass-loader": "10.1.1",
"vite": "^4.4.1"
},
"eslintConfig": {
"root": true,
Expand Down
37 changes: 30 additions & 7 deletions src/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,38 @@
* @description 自动import导入所有 api 模块
*/

const files = require.context('./model', false, /\.js$/)
const modules = {}
files.keys().forEach((key) => {
modules[key.replace(/(\.\/|\.js)/g, '')] = files(key).default
const files = import.meta.globEager('./model/*.js')
for (const key in files) {
modules[key.replace(/^\.\/model\/(.*)\.\w+$/, '$1')]=files[key].default
}

Object.keys(modules).forEach(item => {
// 为每个模块添加一个前缀名,保证模块命明不冲突
modules[item]['namespaced'] = true
})
// const files = require.context('./model', false, /\.js$/)
// const files = import.meta.globEager("/modules/*.js");
// const files = import.meta.globEager('./modules/*.js')
// console.log(files, 'files')
// const modules = {}

// for (const key in files) {
// modules[key.replace(/^\.\/modules\/(.*)\.\w+$/, '$1')] = files[key].default
// }

// Object.keys(modules).forEach(item => {
// // 为每个模块添加一个前缀名,保证模块命明不冲突
// modules[item]['namespaced'] = true
// })

// console.log(modules, 'modules')



import approval from './approval.js'
import common from './common.js'
// 审批流程
const approval = require('./approval');
const common = require('./common');
modules.approval = approval.default;
modules.common = common.default;
modules.approval = approval;
modules.common = common;
export default modules
4 changes: 2 additions & 2 deletions src/api/system-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,15 @@ export function saveTagItems(entity, field, tagItems) {
}

export function getPictureUploadAction() {
return process.env.VUE_APP_BASE_API + '/picture/upload'
return import.meta.env.VITE_APP_BASE_API + '/picture/upload'
}

export function getPictureUrlPrefix() {
return SERVER_URL + '/picture/get'
}

export function getFileUploadAction() {
return process.env.VUE_APP_BASE_API + '/file/upload'
return import.meta.env.VITE_APP_BASE_API + '/file/upload'
}

export function getFileUrlPrefix() {
Expand Down
Loading

0 comments on commit 924527d

Please sign in to comment.