This commit is contained in:
parent
f2dcb13e0d
commit
13e4006592
@ -41,6 +41,7 @@
|
|||||||
"echarts": "^5.4.3",
|
"echarts": "^5.4.3",
|
||||||
"lodash-es": "^4.17.21",
|
"lodash-es": "^4.17.21",
|
||||||
"md-editor-v3": "^4.7.0",
|
"md-editor-v3": "^4.7.0",
|
||||||
|
"mitt": "^3.0.1",
|
||||||
"mockjs": "^1.1.0",
|
"mockjs": "^1.1.0",
|
||||||
"pinia": "^2.1.6",
|
"pinia": "^2.1.6",
|
||||||
"vite": "^4.4.11",
|
"vite": "^4.4.11",
|
||||||
|
8
web/pnpm-lock.yaml
generated
8
web/pnpm-lock.yaml
generated
@ -38,6 +38,9 @@ importers:
|
|||||||
md-editor-v3:
|
md-editor-v3:
|
||||||
specifier: ^4.7.0
|
specifier: ^4.7.0
|
||||||
version: 4.7.0(@codemirror/state@6.2.1)(@codemirror/view@6.21.3)(@lezer/common@1.1.0)(vue@3.3.4)
|
version: 4.7.0(@codemirror/state@6.2.1)(@codemirror/view@6.21.3)(@lezer/common@1.1.0)(vue@3.3.4)
|
||||||
|
mitt:
|
||||||
|
specifier: ^3.0.1
|
||||||
|
version: 3.0.1
|
||||||
mockjs:
|
mockjs:
|
||||||
specifier: ^1.1.0
|
specifier: ^1.1.0
|
||||||
version: 1.1.0
|
version: 1.1.0
|
||||||
@ -3014,6 +3017,9 @@ packages:
|
|||||||
minimist@1.2.8:
|
minimist@1.2.8:
|
||||||
resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==}
|
resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==}
|
||||||
|
|
||||||
|
mitt@3.0.1:
|
||||||
|
resolution: {integrity: sha512-vKivATfr97l2/QBCYAkXYDbrIWPM2IIKEl7YPhjCvKlG3kE2gm+uBo6nEXK3M5/Ffh/FLpKExzOQ3JJoJGFKBw==}
|
||||||
|
|
||||||
mixin-deep@1.3.2:
|
mixin-deep@1.3.2:
|
||||||
resolution: {integrity: sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==}
|
resolution: {integrity: sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==}
|
||||||
engines: {node: '>=0.10.0'}
|
engines: {node: '>=0.10.0'}
|
||||||
@ -7599,6 +7605,8 @@ snapshots:
|
|||||||
|
|
||||||
minimist@1.2.8: {}
|
minimist@1.2.8: {}
|
||||||
|
|
||||||
|
mitt@3.0.1: {}
|
||||||
|
|
||||||
mixin-deep@1.3.2:
|
mixin-deep@1.3.2:
|
||||||
dependencies:
|
dependencies:
|
||||||
for-in: 1.0.2
|
for-in: 1.0.2
|
||||||
|
@ -47,6 +47,10 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import api from '@/api/setting'
|
import api from '@/api/setting'
|
||||||
import { ArchiveOutline as ArchiveIcon } from "@vicons/ionicons5";
|
import { ArchiveOutline as ArchiveIcon } from "@vicons/ionicons5";
|
||||||
|
import { router } from '@/router'
|
||||||
|
import event from '@/utils/event/event'
|
||||||
|
|
||||||
|
const { $bus } = event();
|
||||||
|
|
||||||
const showImportUploader = ref(false)
|
const showImportUploader = ref(false)
|
||||||
const uploadRef = ref(null)
|
const uploadRef = ref(null)
|
||||||
@ -100,6 +104,14 @@ function customRequest(file) {
|
|||||||
}).then(response => {
|
}).then(response => {
|
||||||
if (response.data.code === 200) {
|
if (response.data.code === 200) {
|
||||||
showImportUploader.value = false;
|
showImportUploader.value = false;
|
||||||
|
switch (router.options.history.location) {
|
||||||
|
case "/client":
|
||||||
|
$bus.emit('refreshClients',true);
|
||||||
|
break;
|
||||||
|
case "/setting":
|
||||||
|
$bus.emit('refreshSetting',true)
|
||||||
|
break;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$message.error(response.data.message);
|
$message.error(response.data.message);
|
||||||
}
|
}
|
||||||
|
@ -72,8 +72,11 @@
|
|||||||
import { useUserStore } from '@/store'
|
import { useUserStore } from '@/store'
|
||||||
import { renderIcon } from '@/utils'
|
import { renderIcon } from '@/utils'
|
||||||
import api from '@/api/user'
|
import api from '@/api/user'
|
||||||
|
import event from '@/utils/event/event'
|
||||||
|
import { router } from '@/router'
|
||||||
|
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
|
const { $bus } = event();
|
||||||
|
|
||||||
const options = [
|
const options = [
|
||||||
{
|
{
|
||||||
@ -212,6 +215,9 @@ async function updateInfo() {
|
|||||||
infoFormModel.value = ref(null)
|
infoFormModel.value = ref(null)
|
||||||
showInfoModel.value = false
|
showInfoModel.value = false
|
||||||
await useUserStore().getUserInfo()
|
await useUserStore().getUserInfo()
|
||||||
|
if (router.options.history.location === '/user') {
|
||||||
|
$bus.emit('refreshUserInfo',true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -9,10 +9,14 @@ import { setupRouter } from '@/router'
|
|||||||
import { setupStore } from '@/store'
|
import { setupStore } from '@/store'
|
||||||
import App from './App.vue'
|
import App from './App.vue'
|
||||||
import { setupNaiveDiscreteApi } from './utils'
|
import { setupNaiveDiscreteApi } from './utils'
|
||||||
|
import mitt from 'mitt'
|
||||||
|
|
||||||
|
const EventMitt = mitt();
|
||||||
|
|
||||||
async function setupApp() {
|
async function setupApp() {
|
||||||
const app = createApp(App)
|
const app = createApp(App)
|
||||||
setupStore(app)
|
setupStore(app)
|
||||||
|
app.config.globalProperties.$bus = EventMitt;
|
||||||
await setupRouter(app)
|
await setupRouter(app)
|
||||||
app.mount('#app')
|
app.mount('#app')
|
||||||
setupNaiveDiscreteApi()
|
setupNaiveDiscreteApi()
|
||||||
|
7
web/src/utils/event/event.js
Normal file
7
web/src/utils/event/event.js
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import { getCurrentInstance } from "vue";
|
||||||
|
|
||||||
|
export default function event() {
|
||||||
|
const instance = getCurrentInstance();
|
||||||
|
const globalProperties = instance?.appContext.config.globalProperties;
|
||||||
|
return { ...globalProperties };
|
||||||
|
}
|
1
web/src/utils/event/index.js
Normal file
1
web/src/utils/event/index.js
Normal file
@ -0,0 +1 @@
|
|||||||
|
export * from './event'
|
@ -2,3 +2,4 @@ export * from './common'
|
|||||||
export * from './storage'
|
export * from './storage'
|
||||||
export * from './http'
|
export * from './http'
|
||||||
export * from './auth'
|
export * from './auth'
|
||||||
|
export * from './event'
|
@ -335,6 +335,9 @@ import { NButton } from 'naive-ui'
|
|||||||
import { debounce, ellipsis } from '@/utils'
|
import { debounce, ellipsis } from '@/utils'
|
||||||
import clientApi from '@/views/client/api'
|
import clientApi from '@/views/client/api'
|
||||||
import QueryBar from '@/components/query-bar/QueryBar.vue'
|
import QueryBar from '@/components/query-bar/QueryBar.vue'
|
||||||
|
import event from '@/utils/event/event'
|
||||||
|
|
||||||
|
const { $bus } = event();
|
||||||
|
|
||||||
const selOptions = [
|
const selOptions = [
|
||||||
{
|
{
|
||||||
@ -658,6 +661,13 @@ function search() {
|
|||||||
getClientList()
|
getClientList()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 监听事件
|
||||||
|
$bus.on("refreshClients",value => {
|
||||||
|
if (value) {
|
||||||
|
getClientList();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
getClientList()
|
getClientList()
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
@ -209,6 +209,10 @@ import AppPage from '@/components/page/AppPage.vue'
|
|||||||
import api from '@/views/setting/api'
|
import api from '@/views/setting/api'
|
||||||
import { NButton } from 'naive-ui'
|
import { NButton } from 'naive-ui'
|
||||||
import { renderIcon } from '@/utils'
|
import { renderIcon } from '@/utils'
|
||||||
|
import event from '@/utils/event/event'
|
||||||
|
|
||||||
|
const { $bus } = event();
|
||||||
|
const tabCode = ref("")
|
||||||
|
|
||||||
// 表头
|
// 表头
|
||||||
const tableColumns = [
|
const tableColumns = [
|
||||||
@ -401,12 +405,15 @@ function tabChange(code) {
|
|||||||
switch (code) {
|
switch (code) {
|
||||||
case "Server":
|
case "Server":
|
||||||
getServerConfig()
|
getServerConfig()
|
||||||
|
tabCode.value = "Server"
|
||||||
break;
|
break;
|
||||||
case "Global":
|
case "Global":
|
||||||
getGlobalConfig()
|
getGlobalConfig()
|
||||||
|
tabCode.value = "Global"
|
||||||
break;
|
break;
|
||||||
case "Other":
|
case "Other":
|
||||||
allSetting()
|
allSetting()
|
||||||
|
tabCode.value = "Other"
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -480,6 +487,22 @@ async function addSetting() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$bus.on("refreshSetting",value => {
|
||||||
|
if (value) {
|
||||||
|
if (tabCode.value === "" || tabCode.value === undefined) {
|
||||||
|
getServerConfig()
|
||||||
|
} else {
|
||||||
|
switch (tabCode.value) {
|
||||||
|
case "Server":
|
||||||
|
getServerConfig()
|
||||||
|
break;
|
||||||
|
case "Global":
|
||||||
|
getGlobalConfig()
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
getServerConfig()
|
getServerConfig()
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
@ -106,6 +106,9 @@ import userApi from '@/api/user'
|
|||||||
import { NAvatar,NTag,NButton } from 'naive-ui'
|
import { NAvatar,NTag,NButton } from 'naive-ui'
|
||||||
import { renderIcon } from '@/utils'
|
import { renderIcon } from '@/utils'
|
||||||
import { useUserStore } from '@/store'
|
import { useUserStore } from '@/store'
|
||||||
|
import event from '@/utils/event/event'
|
||||||
|
|
||||||
|
const { $bus } = event();
|
||||||
|
|
||||||
const infoFormRef = ref()
|
const infoFormRef = ref()
|
||||||
|
|
||||||
@ -400,6 +403,12 @@ function addUser() {
|
|||||||
showInfoModel.value = true
|
showInfoModel.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$bus.on('refreshUserInfo',value => {
|
||||||
|
if (value) {
|
||||||
|
getUserList();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
getUserList()
|
getUserList()
|
||||||
</script>
|
</script>
|
||||||
<style></style>
|
<style></style>
|
Loading…
x
Reference in New Issue
Block a user