This commit is contained in:
zhang zhuo 2025-05-26 18:08:25 +08:00
commit 8c9532125b
21 changed files with 502 additions and 0 deletions

8
.env.development Normal file
View File

@ -0,0 +1,8 @@
# 页面标题
VITE_APP_TITLE=里派基础框架
# 开发环境配置
VITE_APP_ENV='development'
# 开发环境
VITE_APP_BASE_API='/dev-api'

11
.env.production Normal file
View File

@ -0,0 +1,11 @@
# 页面标题
VITE_APP_TITLE=里派基础框架
# 生产环境配置
VITE_APP_ENV='production'
# 生产环境
VITE_APP_BASE_API='/prod-api'
# 是否在打包时开启压缩,支持 gzip 和 brotli
VITE_BUILD_COMPRESS=gzip

11
.env.staging Normal file
View File

@ -0,0 +1,11 @@
# 页面标题
VITE_APP_TITLE=里派基础框架
# 生产环境配置
VITE_APP_ENV='staging'
# 生产环境
VITE_APP_BASE_API='/staging-api'
# 是否在打包时开启压缩,支持 gzip 和 brotli
VITE_BUILD_COMPRESS=gzip

25
.gitignore vendored Normal file
View File

@ -0,0 +1,25 @@
.DS_Store
node_modules/
dist/
src/views/system/menu/test
npm-debug.log*
yarn-debug.log*
yarn-error.log*
**/*.log
tests/**/coverage/
tests/e2e/reports
selenium-debug.log
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.hbuilder
package-lock.json
yarn.lock
vite.config.js.*

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2025 leapy
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

0
README.md Normal file
View File

174
index.html Normal file
View File

@ -0,0 +1,174 @@
<!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="images/logo.png">
<title>%VITE_APP_TITLE%</title>
<script type="text/javascript">
document.write("<script src='config.ts?" + new Date().getTime() + "'><\/script>");
</script>
</head>
<body>
<noscript>
<strong>We're sorry but %VITE_APP_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">
<div class="app-loading">
<div class="app-loading__logo">
<img src="images/logo.png"/>
</div>
<div class="app-loading__loader"></div>
<div class="app-loading__title">%VITE_APP_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="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>
<script type="module" src="/src/main.ts"></script>
</html>

34
package.json Normal file
View File

@ -0,0 +1,34 @@
{
"name": "admin",
"version": "1.0.0",
"description": "one basic framework",
"author": "cfn",
"type": "module",
"scripts": {
"dev": "vite",
"build:prod": "vite build",
"build:stage": "vite build --mode staging",
"preview": "vite preview"
},
"dependencies": {
"@element-plus/icons-vue": "^2.3.1",
"axios": "^1.9.0",
"crypto-js": "^4.2.0",
"element-plus": "^2.9.10",
"nprogress": "^0.2.0",
"sortablejs": "^1.15.6",
"vue": "^3.5.14",
"vue-i18n": "^12.0.0-alpha.2",
"vue-router": "^4.5.1",
"vuedraggable": "^2.24.3",
"vuex": "^4.1.0"
},
"devDependencies": {
"@types/node": "^22.15.21",
"@vitejs/plugin-vue": "^5.2.4",
"eslint": "^9.27.0",
"sass": "^1.89.0",
"vite": "^6.3.5"
},
"license": "MIT"
}

0
public/config.ts Normal file
View File

BIN
public/images/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

24
src/App.vue Normal file
View File

@ -0,0 +1,24 @@
<template>
<el-config-provider :locale="locale" :size="config.size" :zIndex="config.zIndex" :button="config.button">
<router-view></router-view>
</el-config-provider>
</template>
<script setup>
import { useI18n } from 'vue-i18n'
import { computed } from 'vue'
const config = {
size: "default",
zIndex: 2000,
button: {
autoInsertSpace: false
}
}
const locale = computed(() => {
const {locale, messages} = useI18n()
return messages.value[locale.value]
})
</script>

8
src/api/index.ts Normal file
View File

@ -0,0 +1,8 @@
const modules = import.meta.glob('./model/**/*.ts') // 异步加载
// 使用示例
const loadModel = async (modelName: string) => {
const path = `./model/${modelName}.ts`
const module = await modules[path]()
return module.default
}

4
src/config/index.ts Normal file
View File

@ -0,0 +1,4 @@
export default {
//语言
LANG: 'zh-cn',
}

29
src/locales/index.ts Normal file
View File

@ -0,0 +1,29 @@
import { createI18n } from 'vue-i18n'
import el_zh_cn from 'element-plus/dist/locale/zh-cn'
import el_en from 'element-plus/dist/locale/en'
import config from "@/config"
import tools from '@/utils/tools'
import zh_cn from './lang/zh-cn.js'
import en from './lang/en.js'
const messages = {
'zh-cn': {
el: el_zh_cn,
...zh_cn
},
'en': {
el: el_en,
...en
}
}
const i18n = createI18n({
legacy: false,
fallbackLocale: 'zh-cn',
locale: tools.data.get("APP_LANG") || config.LANG,
globalInjection: true,
messages,
})
export default i18n;

6
src/locales/lang/en.ts Normal file
View File

@ -0,0 +1,6 @@
export default {
system: {
webTitleDev: 'Property Management System (Testing)',
webTitle: 'Property Management System',
}
}

View File

@ -0,0 +1,6 @@
export default {
system: {
webTitleDev: '物业管理系统(测试)',
webTitle: '物业管理系统',
}
}

21
src/main.ts Normal file
View File

@ -0,0 +1,21 @@
import { createApp } from 'vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import 'element-plus/theme-chalk/display.css'
import i18n from './locales'
// import leapy from './leapy'
// import router from './router'
// import store from './store'
import App from './App.vue'
const app = createApp(App);
// app.use(store);
// app.use(router);
app.use(ElementPlus);
app.use(i18n);
// app.use(leapy);
//挂载app
app.mount('#app');

45
src/utils/tools.ts Normal file
View File

@ -0,0 +1,45 @@
import CryptoJS from 'crypto-js';
const tools = {
data: {
set(cacheKey, data, expireIn = 0) {
let cacheValue = {
content: data,
expireIn: expireIn === 0 ? 0 : new Date().getTime() + expireIn * 1000
}
return localStorage.setItem(cacheKey, tools.base64.encrypt(JSON.stringify(cacheValue)))
},
get(cacheKey) {
try {
const cacheValue = JSON.parse(tools.base64.decrypt(localStorage.getItem(cacheKey)))
if (cacheValue) {
let nowTime = new Date().getTime()
if (nowTime > cacheValue.expireIn && cacheValue.expireIn !== 0) {
localStorage.removeItem(cacheKey)
return null;
}
return cacheValue.content
}
return null
} catch (err) {
return null
}
},
remove(cacheKey) {
return localStorage.removeItem(cacheKey)
},
clear() {
return localStorage.clear()
}
},
base64: {
encrypt(data){
return CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(data))
},
decrypt(cipher){
return CryptoJS.enc.Base64.parse(cipher).toString(CryptoJS.enc.Utf8)
}
}
}
export default tools

13
tsconfig.json Normal file
View File

@ -0,0 +1,13 @@
{
"compilerOptions": {
"module": "ESNext",
"moduleResolution": "node",
"types": ["node"],
"baseUrl": "./",
"paths": {
"@/*": ["src/*"]
},
"esModuleInterop": true,
"allowSyntheticDefaultImports": true
}
}

5
vite-env.d.ts vendored Normal file
View File

@ -0,0 +1,5 @@
declare module "*.vue" {
import { DefineComponent } from "vue";
const component: DefineComponent<{}, {}, any>;
export default component;
}

57
vite.config.ts Normal file
View File

@ -0,0 +1,57 @@
import {defineConfig, loadEnv} from 'vite'
import vue from '@vitejs/plugin-vue'
import * as path from 'path'
export default defineConfig(({mode, command}) => {
const env = loadEnv(mode, process.cwd())
const {VITE_APP_ENV} = env
return {
resolve: {
alias: {
// 设置路径
'~': path.resolve(__dirname, './'),
// 设置别名
'@': path.resolve(__dirname, './src'),
// 资源地址
'@assets': path.resolve(__dirname, './src/assets')
},
extensions: ['.ts', '.json', '.vue', '.js']
},
base: '/',
// vite 相关配置
server: {
port: 8611,
host: true,
// open: true,
proxy: {
'/api': {
target: 'http://dev.api.eswhyf.cn',
changeOrigin: true,
rewrite: (p) => p.replace(/^\/api/, '')
}
}
},
build: {
outDir: 'dist',
assetsDir: 'static',
sourcemap: true,
rollupOptions: {
output: {
manualChunks(id) {
if (id.includes('node_modules')) {
return 'vendor'
}
}
}
}
},
plugins: [vue()],
css: {
preprocessorOptions: {
scss: {
additionalData: `@use "@/styles/variables.scss" as *;`
}
}
}
}
})