publish: 发布2.7.4版本Beta (#1880)
* 媒体库增加批量导入URL * fix 描述错误 * feature: 自动化代码方法支持增加方法描述 * update: 更新依赖,升级为最新版本 * feature: 自动化代码预览部分支持黑夜模式 * fixed: 修复keepalive上线后失效的bug * feature: 增加自动化基础模板功能 * feature: 增加自动化基础模板功能 * 将用户配置保存到数据库,刷新或者异地登录配置不丢失 * update: 清除无用的userinfo配置信息 * fixed: 清理开发阶段页面无端进入404的bug * feature: 前端主题配置跟随用户,不再单独设置json编译生效。 * feature: 增加个人中心配置兼容性 * fix(package): 包名设置为中文会导致无法自动生成代码,禁止包名设置为中文 * feature: 格式化代码 * feature: 对严格模式新建根角色进行调整。 * feature: 版本变更为2.7.4 --------- Co-authored-by: sliboy <34034053+sliboy@users.noreply.github.com> Co-authored-by: ba0ch3ng <ba0ch3ng@foxmail.com> Co-authored-by: task <121913992@qq.com> Co-authored-by: task <ms.yangdan@gmail.com> Co-authored-by: 爱丽-黑子 <62006632+ailiheizi@users.noreply.github.com> Co-authored-by: sliboy <sliboy@hotmail.com>
This commit is contained in:
@@ -7,7 +7,6 @@ var child_process = require('child_process')
|
||||
|
||||
var url = 'https://www.gin-vue-admin.com'
|
||||
var cmd = ''
|
||||
console.log(process.platform)
|
||||
switch (process.platform) {
|
||||
case 'win32':
|
||||
cmd = 'start'
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "gin-vue-admin",
|
||||
"version": "2.7.3",
|
||||
"version": "2.7.4",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"serve": "node openDocument.js && vite --host --mode development",
|
||||
@@ -10,58 +10,59 @@
|
||||
"fix-memory-limit": "cross-env LIMIT=4096 increase-memory-limit"
|
||||
},
|
||||
"dependencies": {
|
||||
"@element-plus/icons-vue": "^2.1.0",
|
||||
"@vue-office/docx": "^1.3.0",
|
||||
"@vue-office/excel": "^1.4.5",
|
||||
"@vue-office/pdf": "^1.5.3",
|
||||
"@vueuse/core": "^10.7.2",
|
||||
"@element-plus/icons-vue": "^2.3.1",
|
||||
"@vue-office/docx": "^1.6.2",
|
||||
"@vue-office/excel": "^1.7.11",
|
||||
"@vue-office/pdf": "^2.0.2",
|
||||
"@vueuse/core": "^11.0.3",
|
||||
"@wangeditor/editor": "^5.1.23",
|
||||
"@wangeditor/editor-for-vue": "^5.1.12",
|
||||
"axios": "^1.4.0",
|
||||
"core-js": "^3.31.1",
|
||||
"axios": "^1.7.7",
|
||||
"core-js": "^3.38.1",
|
||||
"default-passive-events": "^2.0.0",
|
||||
"echarts": "5.4.3",
|
||||
"element-plus": "^2.7.4",
|
||||
"highlight.js": "^11.8.0",
|
||||
"echarts": "5.5.1",
|
||||
"element-plus": "^2.8.1",
|
||||
"highlight.js": "^11.10.0",
|
||||
"js-cookie": "^3.0.5",
|
||||
"marked": "4.3.0",
|
||||
"marked": "14.1.1",
|
||||
"marked-highlight": "^2.1.4",
|
||||
"mitt": "^3.0.1",
|
||||
"nprogress": "^0.2.0",
|
||||
"path": "^0.12.7",
|
||||
"pinia": "^2.1.4",
|
||||
"qs": "^6.11.2",
|
||||
"pinia": "^2.2.2",
|
||||
"qs": "^6.13.0",
|
||||
"screenfull": "^6.0.2",
|
||||
"sortablejs": "^1.15.2",
|
||||
"sortablejs": "^1.15.3",
|
||||
"spark-md5": "^3.0.2",
|
||||
"tailwindcss": "^3.3.3",
|
||||
"tailwindcss": "^3.4.10",
|
||||
"vite-auto-import-svg": "^1.0.0",
|
||||
"vue": "^3.4.21",
|
||||
"vue-echarts": "^6.7.2",
|
||||
"vue-router": "^4.3.2",
|
||||
"vue": "^3.5.1",
|
||||
"vue-echarts": "^7.0.3",
|
||||
"vue-router": "^4.4.3",
|
||||
"vuedraggable": "^4.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/eslint-parser": "^7.22.9",
|
||||
"@vitejs/plugin-legacy": "^4.1.0",
|
||||
"@vitejs/plugin-vue": "^4.2.3",
|
||||
"@babel/eslint-parser": "^7.25.1",
|
||||
"@vitejs/plugin-legacy": "^5.4.2",
|
||||
"@vitejs/plugin-vue": "^5.1.3",
|
||||
"@vue/cli-plugin-babel": "~5.0.8",
|
||||
"@vue/cli-plugin-eslint": "~5.0.8",
|
||||
"@vue/cli-plugin-router": "~5.0.8",
|
||||
"@vue/cli-plugin-vuex": "~5.0.8",
|
||||
"@vue/cli-service": "~5.0.8",
|
||||
"@vue/compiler-sfc": "^3.3.4",
|
||||
"babel-plugin-import": "^1.13.6",
|
||||
"chalk": "^4.1.2",
|
||||
"dotenv": "^16.3.1",
|
||||
"eslint": "^8.49.0",
|
||||
"eslint-plugin-vue": "^9.15.1",
|
||||
"sass": "^1.54.0",
|
||||
"terser": "^5.19.1",
|
||||
"unplugin-auto-import": "^0.16.6",
|
||||
"unplugin-vue-components": "^0.25.1",
|
||||
"vite": "^4.4.6",
|
||||
"vite-plugin-banner": "^0.7.0",
|
||||
"@vue/compiler-sfc": "^3.5.1",
|
||||
"babel-plugin-import": "^1.13.8",
|
||||
"chalk": "^5.3.0",
|
||||
"dotenv": "^16.4.5",
|
||||
"eslint": "^9.9.1",
|
||||
"eslint-plugin-vue": "^9.28.0",
|
||||
"sass": "^1.78.0",
|
||||
"terser": "^5.31.6",
|
||||
"unplugin-auto-import": "^0.18.2",
|
||||
"unplugin-vue-components": "^0.27.4",
|
||||
"vite": "^5.4.3",
|
||||
"vite-plugin-banner": "^0.8.0",
|
||||
"vite-plugin-importer": "^0.2.5",
|
||||
"vite-plugin-vue-devtools": "^7.3.7"
|
||||
"vite-plugin-vue-devtools": "^7.4.4"
|
||||
}
|
||||
}
|
||||
|
@@ -19,7 +19,7 @@ export const deleteAuthority = (data) => {
|
||||
return service({
|
||||
url: '/authority/deleteAuthority',
|
||||
method: 'post',
|
||||
data
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
||||
|
@@ -42,3 +42,16 @@ export const editFileName = (data) => {
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入URL
|
||||
* @param data
|
||||
* @returns {*}
|
||||
*/
|
||||
export const importURL = (data) => {
|
||||
return service({
|
||||
url: '/fileUploadAndDownload/importURL',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
@@ -126,6 +126,22 @@ export const setSelfInfo = (data) => {
|
||||
})
|
||||
}
|
||||
|
||||
// @Tags SysUser
|
||||
// @Summary 设置自身界面配置
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
// @Produce application/json
|
||||
// @Param data body model.SysUser true "设置自身界面配置"
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"修改成功"}"
|
||||
// @Router /user/setSelfSetting [put]
|
||||
export const setSelfSetting = (data) => {
|
||||
return service({
|
||||
url: '/user/setSelfSetting',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// @Tags User
|
||||
// @Summary 设置用户权限
|
||||
// @Security ApiKeyAuth
|
||||
|
@@ -6,6 +6,7 @@
|
||||
:on-error="uploadError"
|
||||
:on-success="uploadSuccess"
|
||||
:show-file-list="false"
|
||||
multiple
|
||||
class="upload-btn"
|
||||
>
|
||||
<el-button type="primary">普通上传</el-button>
|
||||
|
@@ -1,10 +0,0 @@
|
||||
{"weakness":false,
|
||||
"grey":false,
|
||||
"primaryColor":"#3b82f6",
|
||||
"showTabs":true,
|
||||
"darkMode":"auto",
|
||||
"layout_side_width":200,
|
||||
"layout_side_collapsed_width":60,
|
||||
"layout_side_item_height":44,
|
||||
"show_watermark":true,
|
||||
"side_mode":"normal"}
|
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* 网站配置文件
|
||||
*/
|
||||
import chalk from "chalk";
|
||||
const greenText = (text) => `\x1b[32m${text}\x1b[0m`;
|
||||
|
||||
const config = {
|
||||
appName: 'Gin-Vue-Admin',
|
||||
@@ -12,72 +12,19 @@ const config = {
|
||||
|
||||
export const viteLogo = (env) => {
|
||||
if (config.showViteLogo) {
|
||||
const chalk = require('chalk')
|
||||
console.log(
|
||||
chalk.green(
|
||||
`> 欢迎使用Gin-Vue-Admin,开源地址:https://github.com/flipped-aurora/gin-vue-admin`
|
||||
)
|
||||
)
|
||||
console.log(
|
||||
chalk.green(
|
||||
`> 当前版本:v2.7.3`
|
||||
)
|
||||
)
|
||||
console.log(
|
||||
chalk.green(
|
||||
`> 加群方式:微信:shouzi_1994 QQ群:470239250`
|
||||
)
|
||||
)
|
||||
console.log(
|
||||
chalk.green(
|
||||
`> 项目地址:https://github.com/flipped-aurora/gin-vue-admin`
|
||||
)
|
||||
)
|
||||
console.log(
|
||||
chalk.green(
|
||||
`> 插件市场:https://plugin.gin-vue-admin.com`
|
||||
)
|
||||
)
|
||||
console.log(
|
||||
chalk.green(
|
||||
`> GVA讨论社区:https://support.qq.com/products/371961`
|
||||
)
|
||||
)
|
||||
console.log(
|
||||
chalk.green(
|
||||
`> 默认自动化文档地址:http://127.0.0.1:${env.VITE_SERVER_PORT}/swagger/index.html`
|
||||
)
|
||||
)
|
||||
console.log(
|
||||
chalk.green(
|
||||
`> 默认前端文件运行地址:http://127.0.0.1:${env.VITE_CLI_PORT}`
|
||||
)
|
||||
)
|
||||
|
||||
console.log(
|
||||
chalk.green(
|
||||
`--------------------------------------版权声明--------------------------------------`
|
||||
)
|
||||
)
|
||||
|
||||
console.log(
|
||||
chalk.green(
|
||||
`** 版权所有方:flipped-aurora开源团队 **`
|
||||
)
|
||||
)
|
||||
|
||||
console.log(
|
||||
chalk.green(
|
||||
`** 版权持有公司:北京翻转极光科技有限责任公司 **`
|
||||
)
|
||||
)
|
||||
|
||||
console.log(
|
||||
chalk.green(
|
||||
`** 剔除授权标识需购买商用授权:https://gin-vue-admin.com/empower/index.html **`
|
||||
)
|
||||
)
|
||||
console.log('\n')
|
||||
console.log(greenText(`> 欢迎使用Gin-Vue-Admin,开源地址:https://github.com/flipped-aurora/gin-vue-admin`));
|
||||
console.log(greenText(`> 当前版本:v2.7.4`));
|
||||
console.log(greenText(`> 加群方式:微信:shouzi_1994 QQ群:470239250`));
|
||||
console.log(greenText(`> 项目地址:https://github.com/flipped-aurora/gin-vue-admin`));
|
||||
console.log(greenText(`> 插件市场:https://plugin.gin-vue-admin.com`));
|
||||
console.log(greenText(`> GVA讨论社区:https://support.qq.com/products/371961`));
|
||||
console.log(greenText(`> 默认自动化文档地址:http://127.0.0.1:${env.VITE_SERVER_PORT}/swagger/index.html`));
|
||||
console.log(greenText(`> 默认前端文件运行地址:http://127.0.0.1:${env.VITE_CLI_PORT}`));
|
||||
console.log(greenText(`--------------------------------------版权声明--------------------------------------`));
|
||||
console.log(greenText(`** 版权所有方:flipped-aurora开源团队 **`));
|
||||
console.log(greenText(`** 版权持有公司:北京翻转极光科技有限责任公司 **`));
|
||||
console.log(greenText(`** 剔除授权标识需购买商用授权:https://gin-vue-admin.com/empower/index.html **`));
|
||||
console.log('\n');
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -85,7 +85,6 @@ router.beforeEach(async(to, from) => {
|
||||
} else {
|
||||
// 不在白名单中并且已经登录的时候
|
||||
if (token) {
|
||||
console.log(sessionStorage.getItem("needCloseAll"))
|
||||
if(sessionStorage.getItem("needToHome") === 'true') {
|
||||
sessionStorage.removeItem("needToHome")
|
||||
return { path: '/'}
|
||||
|
@@ -1,49 +1,24 @@
|
||||
|
||||
import { defineStore } from 'pinia'
|
||||
import { ref, watchEffect, reactive } from 'vue'
|
||||
import originSetting from "@/config.json"
|
||||
import { setBodyPrimaryColor } from '@/utils/format'
|
||||
export const useAppStore = defineStore('app', () => {
|
||||
const theme = ref(localStorage.getItem('theme') || originSetting.darkMode || 'auto')
|
||||
|
||||
const device = ref("")
|
||||
const config = reactive({
|
||||
weakness: false,
|
||||
grey: false,
|
||||
primaryColor: '#79B6E7',
|
||||
primaryColor: '#3b82f6',
|
||||
showTabs: true,
|
||||
darkMode: 'light',
|
||||
darkMode: 'auto',
|
||||
layout_side_width : 256,
|
||||
layout_side_collapsed_width : 80,
|
||||
layout_side_item_height : 48,
|
||||
show_watermark: false,
|
||||
|
||||
show_watermark: true,
|
||||
side_mode : 'normal'
|
||||
})
|
||||
|
||||
// 初始化配置
|
||||
Object.keys(originSetting).forEach(key => {
|
||||
config[key] = originSetting[key]
|
||||
if(key === 'primaryColor'){
|
||||
setBodyPrimaryColor(originSetting[key],config.darkMode)
|
||||
}
|
||||
})
|
||||
|
||||
if (localStorage.getItem('darkMode')) {
|
||||
config.darkMode = localStorage.getItem('darkMode')
|
||||
}
|
||||
|
||||
|
||||
watchEffect(() =>{
|
||||
if (theme.value === 'dark'){
|
||||
document.documentElement.classList.add('dark');
|
||||
document.documentElement.classList.remove('light');
|
||||
localStorage.setItem('theme', 'dark');
|
||||
}else{
|
||||
document.documentElement.classList.add('light');
|
||||
document.documentElement.classList.remove('dark');
|
||||
localStorage.setItem('theme', 'light');
|
||||
}
|
||||
})
|
||||
const theme = ref( 'auto')
|
||||
|
||||
const toggleTheme = (dark) => {
|
||||
if (dark) {
|
||||
@@ -55,25 +30,14 @@ export const useAppStore = defineStore('app', () => {
|
||||
|
||||
const toggleWeakness = (e) => {
|
||||
config.weakness = e;
|
||||
if(e) {
|
||||
document.documentElement.classList.add('html-weakenss');
|
||||
}else{
|
||||
document.documentElement.classList.remove('html-weakenss');
|
||||
}
|
||||
}
|
||||
|
||||
const toggleGrey = (e) => {
|
||||
config.grey = e;
|
||||
if(e) {
|
||||
document.documentElement.classList.add('html-grey');
|
||||
}else{
|
||||
document.documentElement.classList.remove('html-grey');
|
||||
}
|
||||
}
|
||||
|
||||
const togglePrimaryColor = (e) => {
|
||||
config.primaryColor = e;
|
||||
setBodyPrimaryColor(e,config.darkMode)
|
||||
}
|
||||
|
||||
const toggleTabs = (e) => {
|
||||
@@ -86,12 +50,6 @@ export const useAppStore = defineStore('app', () => {
|
||||
|
||||
const toggleDarkMode = (e) => {
|
||||
config.darkMode = e
|
||||
localStorage.setItem('darkMode', e)
|
||||
if(e === 'dark'){
|
||||
toggleTheme(true)
|
||||
}else{
|
||||
toggleTheme(false)
|
||||
}
|
||||
}
|
||||
|
||||
const toggleDarkModeAuto = () =>{
|
||||
@@ -124,11 +82,49 @@ export const useAppStore = defineStore('app', () => {
|
||||
config.side_mode = e
|
||||
}
|
||||
|
||||
if(config.darkMode === 'auto'){
|
||||
toggleDarkModeAuto()
|
||||
}
|
||||
watchEffect(() => {
|
||||
if (theme.value === 'dark') {
|
||||
document.documentElement.classList.add('dark');
|
||||
document.documentElement.classList.remove('light');
|
||||
} else {
|
||||
document.documentElement.classList.add('light');
|
||||
document.documentElement.classList.remove('dark');
|
||||
}
|
||||
})
|
||||
watchEffect(() => {
|
||||
// 色弱模式监听处理
|
||||
if (config.weakness) {
|
||||
document.documentElement.classList.add('html-weakenss');
|
||||
} else {
|
||||
document.documentElement.classList.remove('html-weakenss');
|
||||
}
|
||||
})
|
||||
watchEffect(() => {
|
||||
// 灰色模式监听处理
|
||||
if (config.grey) {
|
||||
document.documentElement.classList.add('html-grey');
|
||||
} else {
|
||||
document.documentElement.classList.remove('html-grey');
|
||||
}
|
||||
})
|
||||
|
||||
toggleGrey(config.grey)
|
||||
|
||||
|
||||
watchEffect(() => {
|
||||
if(config.darkMode === 'auto'){
|
||||
toggleDarkModeAuto()
|
||||
}
|
||||
|
||||
if(config.darkMode === 'dark'){
|
||||
toggleTheme(true)
|
||||
}else{
|
||||
toggleTheme(false)
|
||||
}
|
||||
})
|
||||
|
||||
watchEffect(() => {
|
||||
setBodyPrimaryColor(config.primaryColor, theme.value)
|
||||
})
|
||||
|
||||
return {
|
||||
theme,
|
||||
|
@@ -31,9 +31,7 @@ const KeepAliveFilter = (routes) => {
|
||||
routes && routes.forEach(item => {
|
||||
// 子菜单中有 keep-alive 的,父菜单也必须 keep-alive,否则无效。这里将子菜单中有 keep-alive 的父菜单也加入。
|
||||
if ((item.children && item.children.some(ch => ch.meta.keepAlive) || item.meta.keepAlive)) {
|
||||
const regex = /\(\) => import\("([^?]+)\??.*"\)/;
|
||||
const match = String(item.component).match(regex);
|
||||
const path = match ? match[1] : "";
|
||||
const path = item.meta.path
|
||||
keepAliveRoutersArr.push(pathInfo[path])
|
||||
nameMap[item.name] = pathInfo[path]
|
||||
}
|
||||
|
@@ -7,7 +7,10 @@ import { ref, computed, watch } from 'vue'
|
||||
import { useRouterStore } from './router'
|
||||
import cookie from 'js-cookie'
|
||||
|
||||
import {useAppStore} from "@/pinia";
|
||||
|
||||
export const useUserStore = defineStore('user', () => {
|
||||
const appStore = useAppStore()
|
||||
const loadingInstance = ref(null)
|
||||
|
||||
const userInfo = ref({
|
||||
@@ -15,22 +18,25 @@ export const useUserStore = defineStore('user', () => {
|
||||
nickName: '',
|
||||
headerImg: '',
|
||||
authority: {},
|
||||
sideMode: 'dark',
|
||||
baseColor: '#fff'
|
||||
})
|
||||
const token = ref(window.localStorage.getItem('token') || cookie.get('x-token') || '')
|
||||
const setUserInfo = (val) => {
|
||||
userInfo.value = val
|
||||
if(val.originSetting){
|
||||
Object.keys(appStore.config).forEach(key => {
|
||||
appStore.config[key] = val.originSetting[key]
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const setToken = (val) => {
|
||||
token.value = val
|
||||
}
|
||||
|
||||
const NeedInit = () => {
|
||||
const NeedInit = async () => {
|
||||
token.value = ''
|
||||
window.localStorage.removeItem('token')
|
||||
router.push({ name: 'Init', replace: true })
|
||||
await router.push({name: 'Init', replace: true})
|
||||
}
|
||||
|
||||
const ResetUserInfo = (value = {}) => {
|
||||
@@ -89,6 +95,7 @@ export const useUserStore = defineStore('user', () => {
|
||||
window.localStorage.setItem('osType', 'MAC')
|
||||
}
|
||||
|
||||
|
||||
// 全部操作均结束,关闭loading并返回
|
||||
loadingInstance.value.close()
|
||||
return true
|
||||
@@ -114,38 +121,8 @@ export const useUserStore = defineStore('user', () => {
|
||||
sessionStorage.clear()
|
||||
window.localStorage.removeItem('token')
|
||||
cookie.remove('x-token')
|
||||
localStorage.removeItem('originSetting')
|
||||
}
|
||||
/* 设置侧边栏模式*/
|
||||
const changeSideMode = async(data) => {
|
||||
const res = await setSelfInfo({ sideMode: data })
|
||||
if (res.code === 0) {
|
||||
userInfo.value.sideMode = data
|
||||
ElMessage({
|
||||
type: 'success',
|
||||
message: '设置成功'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const mode = computed(() => userInfo.value.sideMode)
|
||||
const sideMode = computed(() => {
|
||||
if (userInfo.value.sideMode === 'dark') {
|
||||
return '#191a23'
|
||||
} else if (userInfo.value.sideMode === 'light') {
|
||||
return '#fff'
|
||||
} else {
|
||||
return userInfo.value.sideMode
|
||||
}
|
||||
})
|
||||
const baseColor = computed(() => {
|
||||
if (userInfo.value.sideMode === 'dark') {
|
||||
return '#fff'
|
||||
} else if (userInfo.value.sideMode === 'light') {
|
||||
return '#191a23'
|
||||
} else {
|
||||
return userInfo.value.baseColor
|
||||
}
|
||||
})
|
||||
|
||||
watch(() => token.value, () => {
|
||||
window.localStorage.setItem('token', token.value)
|
||||
@@ -159,11 +136,7 @@ export const useUserStore = defineStore('user', () => {
|
||||
GetUserInfo,
|
||||
LoginIn,
|
||||
LoginOut,
|
||||
changeSideMode,
|
||||
mode,
|
||||
sideMode,
|
||||
setToken,
|
||||
baseColor,
|
||||
loadingInstance,
|
||||
ClearStorage
|
||||
}
|
||||
|
@@ -4,6 +4,7 @@ const pluginModules = import.meta.glob('../plugin/**/*.vue')
|
||||
export const asyncRouterHandle = (asyncRouter) => {
|
||||
asyncRouter.forEach(item => {
|
||||
if (item.component && typeof item.component === 'string') {
|
||||
item.meta.path = "/src/"+item.component
|
||||
if (item.component.split('/')[0] === 'view') {
|
||||
item.component = dynamicImport(viewModules, item.component)
|
||||
} else if (item.component.split('/')[0] === 'plugin') {
|
||||
|
@@ -101,7 +101,7 @@ function addOpacityToColor(u, opacity) {
|
||||
}
|
||||
|
||||
|
||||
export const setBodyPrimaryColor = ( primaryColor, darkMode ) =>{
|
||||
export const setBodyPrimaryColor = (primaryColor, darkMode) =>{
|
||||
|
||||
let fmtColorFunc = generateAllColors
|
||||
if (darkMode === 'light') {
|
||||
@@ -124,4 +124,16 @@ const baseUrl = ref(import.meta.env.VITE_BASE_API)
|
||||
|
||||
export const getBaseUrl = () => {
|
||||
return baseUrl.value === "/" ? "" : baseUrl.value
|
||||
}
|
||||
}
|
||||
|
||||
export const CreateUUID = () => {
|
||||
let d = new Date().getTime()
|
||||
if (window.performance && typeof window.performance.now === 'function') {
|
||||
d += performance.now()
|
||||
}
|
||||
return '00000000-0000-0000-0000-000000000000'.replace(/0/g, (c) => {
|
||||
const r = (d + Math.random() * 16) % 16 | 0 // d是随机种子
|
||||
d = Math.floor(d / 16)
|
||||
return (c === '0' ? r : (r & 0x3 | 0x8)).toString(16)
|
||||
})
|
||||
}
|
||||
|
@@ -15,9 +15,16 @@
|
||||
:max-w-h="1080"
|
||||
@on-success="getTableData"
|
||||
/>
|
||||
<el-button
|
||||
type="primary"
|
||||
icon="upload"
|
||||
@click="importUrlFunc"
|
||||
>
|
||||
导入URL
|
||||
</el-button>
|
||||
<el-input
|
||||
v-model="search.keyword"
|
||||
class="keyword"
|
||||
class="w-72"
|
||||
placeholder="请输入文件名或备注"
|
||||
/>
|
||||
<el-button
|
||||
@@ -122,12 +129,12 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { getFileList, deleteFile, editFileName } from '@/api/fileUploadAndDownload'
|
||||
import {getFileList, deleteFile, editFileName, importURL} from '@/api/fileUploadAndDownload'
|
||||
import { downloadImage } from '@/utils/downloadImg'
|
||||
import CustomPic from '@/components/customPic/index.vue'
|
||||
import UploadImage from '@/components/upload/image.vue'
|
||||
import UploadCommon from '@/components/upload/common.vue'
|
||||
import { formatDate } from '@/utils/format'
|
||||
import {CreateUUID, formatDate} from '@/utils/format'
|
||||
import WarningBar from '@/components/warningBar/warningBar.vue'
|
||||
|
||||
import { ref } from 'vue'
|
||||
@@ -228,7 +235,7 @@ const editFileNameFunc = async(row) => {
|
||||
type: 'success',
|
||||
message: '编辑成功!',
|
||||
})
|
||||
getTableData()
|
||||
await getTableData()
|
||||
}
|
||||
}).catch(() => {
|
||||
ElMessage({
|
||||
@@ -237,11 +244,61 @@ const editFileNameFunc = async(row) => {
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入URL
|
||||
*/
|
||||
const importUrlFunc = () => {
|
||||
ElMessageBox.prompt('格式:文件名|链接或者仅链接。', '导入', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
inputType: 'textarea',
|
||||
inputPlaceholder: '我的图片|https://my-oss.com/my.png\nhttps://my-oss.com/my_1.png',
|
||||
inputPattern: /\S/,
|
||||
inputErrorMessage: '不能为空',
|
||||
}).then(async({ value }) => {
|
||||
let data = value.split('\n')
|
||||
let importData = []
|
||||
data.forEach(item => {
|
||||
let oneData = item.trim().split('|')
|
||||
let url, name
|
||||
if (oneData.length > 1) {
|
||||
name = oneData[0].trim()
|
||||
url = oneData[1]
|
||||
} else {
|
||||
url = oneData[0].trim()
|
||||
let str = url.substring(url.lastIndexOf('/') + 1)
|
||||
name = str.substring(0, str.lastIndexOf('.'))
|
||||
}
|
||||
if (url) {
|
||||
importData.push({
|
||||
name: name,
|
||||
url: url,
|
||||
tag: url.substring(url.lastIndexOf(".") + 1),
|
||||
key: CreateUUID()
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
const res = await importURL(importData)
|
||||
if (res.code === 0) {
|
||||
ElMessage({
|
||||
type: 'success',
|
||||
message: '导入成功!',
|
||||
})
|
||||
await getTableData()
|
||||
}
|
||||
}).catch(() => {
|
||||
ElMessage({
|
||||
type: 'info',
|
||||
message: '取消导入',
|
||||
})
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.name {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
@@ -191,6 +191,7 @@ const goDoc = () => {
|
||||
const out = ref(false)
|
||||
|
||||
const form = reactive({
|
||||
adminPassword: '123456',
|
||||
dbType: 'mysql',
|
||||
host: '127.0.0.1',
|
||||
port: '3306',
|
||||
@@ -204,7 +205,7 @@ const changeDB = (val) => {
|
||||
switch (val) {
|
||||
case 'mysql':
|
||||
Object.assign(form, {
|
||||
adminPassword:'',
|
||||
adminPassword:'123456',
|
||||
reAdminPassword:'',
|
||||
dbType: 'mysql',
|
||||
host: '127.0.0.1',
|
||||
@@ -217,8 +218,7 @@ const changeDB = (val) => {
|
||||
break
|
||||
case 'pgsql':
|
||||
Object.assign(form, {
|
||||
adminPassword:'',
|
||||
reAdminPassword:'',
|
||||
adminPassword:'123456',
|
||||
dbType: 'pgsql',
|
||||
host: '127.0.0.1',
|
||||
port: '5432',
|
||||
@@ -230,8 +230,7 @@ const changeDB = (val) => {
|
||||
break
|
||||
case 'oracle':
|
||||
Object.assign(form, {
|
||||
adminPassword:'',
|
||||
reAdminPassword:'',
|
||||
adminPassword:'123456',
|
||||
dbType: 'oracle',
|
||||
host: '127.0.0.1',
|
||||
port: '1521',
|
||||
@@ -243,8 +242,7 @@ const changeDB = (val) => {
|
||||
break
|
||||
case 'mssql':
|
||||
Object.assign(form, {
|
||||
adminPassword:'',
|
||||
reAdminPassword:'',
|
||||
adminPassword:'123456',
|
||||
dbType: 'mssql',
|
||||
host: '127.0.0.1',
|
||||
port: '1433',
|
||||
@@ -256,8 +254,7 @@ const changeDB = (val) => {
|
||||
break
|
||||
case 'sqlite':
|
||||
Object.assign(form, {
|
||||
adminPassword:'',
|
||||
reAdminPassword:'',
|
||||
adminPassword:'123456',
|
||||
dbType: 'sqlite',
|
||||
host: '',
|
||||
port: '',
|
||||
@@ -269,8 +266,7 @@ const changeDB = (val) => {
|
||||
break
|
||||
default:
|
||||
Object.assign(form, {
|
||||
adminPassword:'',
|
||||
reAdminPassword:'',
|
||||
adminPassword:'123456',
|
||||
dbType: 'mysql',
|
||||
host: '127.0.0.1',
|
||||
port: '3306',
|
||||
|
@@ -112,14 +112,12 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<el-alert type="warning" :closable="false">
|
||||
<!-- <el-alert type="warning" :closable="false">
|
||||
请注意,所有配置请保存到本地文件的
|
||||
<el-tag>config.json</el-tag> 文件中,否则刷新页面后会丢失配置
|
||||
</el-alert>
|
||||
</el-alert>-->
|
||||
|
||||
<el-button type="primary" class="mt-4" @click="copyConfig"
|
||||
>复制配置json</el-button
|
||||
>
|
||||
<el-button type="primary" class="mt-4" @click="saveConfig">保存配置</el-button>
|
||||
</div>
|
||||
</el-drawer>
|
||||
</template>
|
||||
@@ -129,6 +127,7 @@ import { useAppStore } from "@/pinia";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { ref, computed } from "vue";
|
||||
import { ElMessage } from "element-plus";
|
||||
import {setSelfSetting} from "@/api/user";
|
||||
const appStore = useAppStore();
|
||||
const { config, device } = storeToRefs(appStore);
|
||||
defineOptions({
|
||||
@@ -169,8 +168,8 @@ const sideModes = [
|
||||
}
|
||||
];
|
||||
|
||||
const copyConfig = () => {
|
||||
const input = document.createElement("textarea");
|
||||
const saveConfig = async () => {
|
||||
/*const input = document.createElement("textarea");
|
||||
input.value = JSON.stringify(config.value);
|
||||
// 添加回车
|
||||
input.value = input.value.replace(/,/g, ",\n");
|
||||
@@ -178,14 +177,16 @@ const copyConfig = () => {
|
||||
input.select();
|
||||
document.execCommand("copy");
|
||||
document.body.removeChild(input);
|
||||
ElMessage.success("复制成功, 请自行保存到本地文件中");
|
||||
ElMessage.success("复制成功, 请自行保存到本地文件中");*/
|
||||
const res = await setSelfSetting(config.value)
|
||||
if(res.code === 0){
|
||||
localStorage.setItem('originSetting', JSON.stringify(config.value))
|
||||
ElMessage.success('保存成功')
|
||||
drawer.value = false
|
||||
}
|
||||
};
|
||||
|
||||
const customColor = ref("");
|
||||
|
||||
const handleSideModelChange = (e) => {
|
||||
console.log(e);
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
@@ -231,7 +231,7 @@ const submitForm = () => {
|
||||
message: '请正确填写登录信息',
|
||||
showClose: true,
|
||||
})
|
||||
loginVerify()
|
||||
await loginVerify()
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -240,7 +240,7 @@ const submitForm = () => {
|
||||
|
||||
// 登陆失败,刷新验证码
|
||||
if (!flag) {
|
||||
loginVerify()
|
||||
await loginVerify()
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -255,7 +255,7 @@ const checkInit = async() => {
|
||||
if (res.code === 0) {
|
||||
if (res.data?.needInit) {
|
||||
userStore.NeedInit()
|
||||
router.push({ name: 'Init' })
|
||||
await router.push({name: 'Init'})
|
||||
} else {
|
||||
ElMessage({
|
||||
type: 'info',
|
||||
|
@@ -591,6 +591,7 @@ const enterSyncDialog = async() => {
|
||||
|
||||
const onReset = () => {
|
||||
searchInfo.value = {}
|
||||
getTableData()
|
||||
}
|
||||
// 搜索
|
||||
|
||||
@@ -690,7 +691,6 @@ const onSync = async() => {
|
||||
if (res.code === 0) {
|
||||
res.data.newApis.forEach(item => {
|
||||
item.apiGroup = apiGroupMap.value[item.path.split('/')[1]]
|
||||
console.log(apiGroupMap.value)
|
||||
})
|
||||
|
||||
syncApiData.value = res.data
|
||||
|
@@ -201,7 +201,7 @@ const mustUint = (rule, value, callback) => {
|
||||
const AuthorityOption = ref([
|
||||
{
|
||||
authorityId: 0,
|
||||
authorityName: '根角色'
|
||||
authorityName: '根角色/严格模式下为当前角色'
|
||||
}
|
||||
])
|
||||
const drawer = ref(false)
|
||||
@@ -384,7 +384,7 @@ const setOptions = () => {
|
||||
AuthorityOption.value = [
|
||||
{
|
||||
authorityId: 0,
|
||||
authorityName: '根角色'
|
||||
authorityName: '根角色(严格模式下为当前用户角色)'
|
||||
}
|
||||
]
|
||||
setAuthorityOptions(tableData.value, AuthorityOption.value, false)
|
||||
|
@@ -8,18 +8,30 @@
|
||||
>
|
||||
<div
|
||||
:id="key"
|
||||
class="h-[calc(100vh-110px)] bg-white px-5 overflow-y-scroll"
|
||||
class="h-[calc(100vh-110px)] px-5 overflow-y-scroll"
|
||||
/>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { marked } from 'marked'
|
||||
import { Marked } from "marked";
|
||||
import { markedHighlight } from "marked-highlight";
|
||||
import hljs from 'highlight.js'
|
||||
import 'highlight.js/styles/atom-one-dark.css'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { onMounted, ref } from 'vue'
|
||||
import {useAppStore} from "@/pinia";
|
||||
|
||||
const appStore = useAppStore()
|
||||
|
||||
onMounted(() => {
|
||||
const isDarkMode = appStore.config.darkMode === 'dark';
|
||||
if (isDarkMode) {
|
||||
import('highlight.js/styles/atom-one-dark.css');
|
||||
} else {
|
||||
import('highlight.js/styles/atom-one-light.css');
|
||||
}
|
||||
});
|
||||
|
||||
const props = defineProps({
|
||||
previewCode: {
|
||||
@@ -32,26 +44,24 @@ const props = defineProps({
|
||||
|
||||
const activeName = ref('')
|
||||
onMounted(() => {
|
||||
marked.setOptions({
|
||||
renderer: new marked.Renderer(),
|
||||
highlight: function(code) {
|
||||
return hljs.highlightAuto(code).value
|
||||
},
|
||||
pedantic: false,
|
||||
gfm: true,
|
||||
tables: true,
|
||||
breaks: false,
|
||||
sanitize: false,
|
||||
smartLists: true,
|
||||
smartypants: false,
|
||||
xhtml: false,
|
||||
langPrefix: 'hljs language-'
|
||||
})
|
||||
const marked = new Marked(
|
||||
markedHighlight({
|
||||
langPrefix: 'hljs language-',
|
||||
highlight(code, lang, info) {
|
||||
console.log(code,lang,info)
|
||||
const language = hljs.getLanguage(lang) ? lang : 'plaintext';
|
||||
if (lang === 'vue') {
|
||||
return hljs.highlight(code, { language: 'html' }).value;
|
||||
}
|
||||
return hljs.highlight(code, { language }).value;
|
||||
}
|
||||
})
|
||||
);
|
||||
for (const key in props.previewCode) {
|
||||
if (activeName.value === '') {
|
||||
activeName.value = key
|
||||
}
|
||||
document.getElementById(key).innerHTML = marked(props.previewCode[key])
|
||||
document.getElementById(key).innerHTML = marked.parse(props.previewCode[key])
|
||||
}
|
||||
})
|
||||
|
||||
|
@@ -386,6 +386,20 @@
|
||||
<el-checkbox v-model="form.autoCreateResource" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="3">
|
||||
<el-form-item>
|
||||
<template #label>
|
||||
<el-tooltip
|
||||
content="注:使用基础模板将不会生成任何结构体和CURD,仅仅配置enter等属性方便自行开发非CURD逻辑"
|
||||
placement="bottom"
|
||||
effect="light"
|
||||
>
|
||||
<div> 基础模板 <el-icon><QuestionFilled /></el-icon> </div>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
<el-checkbox v-model="form.onlyTemplate" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
</div>
|
||||
@@ -395,6 +409,7 @@
|
||||
<el-button
|
||||
type="primary"
|
||||
@click="editAndAddField()"
|
||||
:disabled="form.onlyTemplate"
|
||||
>
|
||||
新增字段
|
||||
</el-button>
|
||||
@@ -1013,6 +1028,7 @@ const form = ref({
|
||||
autoMigrate: true,
|
||||
gvaModel: true,
|
||||
autoCreateResource: false,
|
||||
onlyTemplate: false,
|
||||
fields: []
|
||||
})
|
||||
const rules = ref({
|
||||
@@ -1125,6 +1141,9 @@ const deleteField = (index) => {
|
||||
}
|
||||
const autoCodeForm = ref(null)
|
||||
const enterForm = async(isPreview) => {
|
||||
|
||||
if(!form.value.onlyTemplate){
|
||||
|
||||
if (form.value.fields.length <= 0) {
|
||||
ElMessage({
|
||||
type: 'error',
|
||||
@@ -1151,14 +1170,6 @@ const enterForm = async(isPreview) => {
|
||||
return false
|
||||
}
|
||||
|
||||
if (form.value.package === form.value.abbreviation) {
|
||||
ElMessage({
|
||||
type: 'error',
|
||||
message: 'package和结构体简称不可同名'
|
||||
})
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
if (form.value.fields.some(item => !item.fieldType)) {
|
||||
ElMessage({
|
||||
@@ -1168,6 +1179,16 @@ const enterForm = async(isPreview) => {
|
||||
return false
|
||||
}
|
||||
|
||||
if (form.value.package === form.value.abbreviation) {
|
||||
ElMessage({
|
||||
type: 'error',
|
||||
message: 'package和结构体简称不可同名'
|
||||
})
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
autoCodeForm.value.validate(async valid => {
|
||||
if (valid) {
|
||||
for (const key in form.value) {
|
||||
@@ -1366,6 +1387,7 @@ const clearCatch = async () => {
|
||||
autoMigrate: true,
|
||||
gvaModel: true,
|
||||
autoCreateResource: false,
|
||||
onlyTemplate: false,
|
||||
fields: []
|
||||
}
|
||||
await nextTick()
|
||||
@@ -1390,7 +1412,6 @@ const exportJson = () => {
|
||||
const importJson = (file) =>{
|
||||
const reader = new FileReader()
|
||||
reader.onload = (e) => {
|
||||
console.log(e)
|
||||
try {
|
||||
form.value = JSON.parse(e.target.result)
|
||||
ElMessage.success('JSON 文件导入成功')
|
||||
@@ -1402,4 +1423,20 @@ const importJson = (file) =>{
|
||||
return false
|
||||
}
|
||||
|
||||
watch(()=>form.value.onlyTemplate,(val)=>{
|
||||
if(val){
|
||||
ElMessageBox.confirm('使用基础模板将不会生成任何结构体和CURD,仅仅配置enter等属性方便自行开发非CURD逻辑', '注意', {
|
||||
confirmButtonText: '继续',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
})
|
||||
.then(() => {
|
||||
form.value.fields = []
|
||||
})
|
||||
.catch(() => {
|
||||
form.value.onlyTemplate = false
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
</script>
|
||||
|
@@ -177,6 +177,9 @@
|
||||
<el-form-item label="缩写:">
|
||||
<el-input v-model="autoFunc.abbreviation" placeholder="请输入缩写" disabled />
|
||||
</el-form-item>
|
||||
<el-form-item label="方法名:">
|
||||
<el-input v-model="autoFunc.funcDesc" placeholder="请输入方法介绍" />
|
||||
</el-form-item>
|
||||
<el-form-item label="方法名:">
|
||||
<el-input v-model="autoFunc.funcName" placeholder="请输入方法名" />
|
||||
</el-form-item>
|
||||
@@ -238,6 +241,7 @@ const autoFunc = ref({
|
||||
humpPackageName:"",
|
||||
businessDB:"",
|
||||
method:"",
|
||||
funcDesc: ""
|
||||
})
|
||||
|
||||
const addFuncBtn = (row) => {
|
||||
@@ -252,6 +256,7 @@ const addFuncBtn = (row) => {
|
||||
autoFunc.value.method = ""
|
||||
autoFunc.value.funcName = ""
|
||||
autoFunc.value.router = ""
|
||||
autoFunc.value.funcDesc = "方法介绍"
|
||||
funcFlag.value = true;
|
||||
};
|
||||
|
||||
|
@@ -170,8 +170,10 @@ const getTemplates = async ()=>{
|
||||
|
||||
getTemplates()
|
||||
|
||||
const validateNum = (rule, value, callback) => {
|
||||
if ((/^\d+$/.test(value[0]))) {
|
||||
const validateData = (rule, value, callback) => {
|
||||
if (/[\u4E00-\u9FA5]/g.test(value)) {
|
||||
callback(new Error('不能为中文'))
|
||||
} else if ((/^\d+$/.test(value[0]))) {
|
||||
callback(new Error('不能够以数字开头'))
|
||||
} else {
|
||||
callback()
|
||||
@@ -181,11 +183,11 @@ const validateNum = (rule, value, callback) => {
|
||||
const rules = ref({
|
||||
packageName: [
|
||||
{ required: true, message: '请输入包名', trigger: 'blur' },
|
||||
{ validator: validateNum, trigger: 'blur' }
|
||||
{ validator: validateData, trigger: 'blur' }
|
||||
],
|
||||
template:[
|
||||
{ required: true, message: '请选择模板', trigger: 'change' },
|
||||
{ validator: validateNum, trigger: 'blur' }
|
||||
{ validator: validateData, trigger: 'blur' }
|
||||
]
|
||||
})
|
||||
|
||||
|
@@ -13,7 +13,7 @@
|
||||
class="mt-3.5"
|
||||
>
|
||||
<el-form-item label="端口值">
|
||||
<el-input v-model.number="config.system.addr" placeholder="请输入端口值"/>
|
||||
<el-input-number v-model="config.system.addr" placeholder="请输入端口值"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="数据库类型">
|
||||
<el-select
|
||||
@@ -50,7 +50,7 @@
|
||||
<el-switch v-model="config.system['use-mongo']"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="严格角色模式">
|
||||
<el-checkbox v-model="config.system['use-strict-auth']">开启</el-checkbox>
|
||||
<el-switch v-model="config.system['use-strict-auth']"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="限流次数">
|
||||
<el-input-number v-model.number="config.system['iplimit-count']"/>
|
||||
@@ -75,7 +75,7 @@
|
||||
<el-form-item label="jwt签名">
|
||||
<el-input v-model.trim="config.jwt['signing-key']" placeholder="请输入jwt签名">
|
||||
<template #append>
|
||||
<el-button @click="CreateUUID">生成</el-button>
|
||||
<el-button @click="getUUID">生成</el-button>
|
||||
</template>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
@@ -682,6 +682,7 @@ import { ref } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { Minus, Plus } from '@element-plus/icons-vue'
|
||||
import { emailTest } from '@/api/email'
|
||||
import {CreateUUID} from "@/utils/format";
|
||||
|
||||
defineOptions({
|
||||
name: 'Config',
|
||||
@@ -795,16 +796,8 @@ const email = async() => {
|
||||
}
|
||||
}
|
||||
|
||||
const CreateUUID = () => {
|
||||
let d = new Date().getTime()
|
||||
if (window.performance && typeof window.performance.now === 'function') {
|
||||
d += performance.now()
|
||||
}
|
||||
config.value.jwt['signing-key'] = '00000000-0000-0000-0000-000000000000'.replace(/0/g, (c) => {
|
||||
const r = (d + Math.random() * 16) % 16 | 0 // d是随机种子
|
||||
d = Math.floor(d / 16)
|
||||
return (c === '0' ? r : (r & 0x3 | 0x8)).toString(16)
|
||||
})
|
||||
const getUUID = () => {
|
||||
config.value.jwt['signing-key'] = CreateUUID()
|
||||
}
|
||||
|
||||
const addNode = () => {
|
||||
|
@@ -55,49 +55,19 @@ const vueFilePathPlugin = (outputFilePath) => {
|
||||
});
|
||||
};
|
||||
|
||||
const injectBeforeUnloadScript = () => {
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
return {
|
||||
name: 'inject-before-unload-script',
|
||||
transformIndexHtml(html) {
|
||||
return html.replace(
|
||||
'</body>',
|
||||
`<script>
|
||||
const isWindowActive = () => !document.hidden;
|
||||
window.addEventListener('beforeunload', function () {
|
||||
if (!isWindowActive()) {
|
||||
return;
|
||||
}
|
||||
fetch('/generate-path-name-map');
|
||||
});
|
||||
</script></body>`
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
return {}
|
||||
};
|
||||
|
||||
|
||||
return {
|
||||
name: 'vue-file-path-plugin',
|
||||
configResolved(resolvedConfig) {
|
||||
root = resolvedConfig.root;
|
||||
},
|
||||
configureServer(server) {
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
server.middlewares.use('/generate-path-name-map', (req, res) => {
|
||||
generatePathNameMap();
|
||||
res.end('Path name map generated');
|
||||
});
|
||||
}
|
||||
},
|
||||
buildEnd() {
|
||||
generatePathNameMap();
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
watchDirectoryChanges();
|
||||
}
|
||||
},
|
||||
...injectBeforeUnloadScript()
|
||||
};
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user