diff options
Diffstat (limited to 'UI source code/dns_mapping_ui-master/src/store/modules')
7 files changed, 595 insertions, 0 deletions
diff --git a/UI source code/dns_mapping_ui-master/src/store/modules/api.js b/UI source code/dns_mapping_ui-master/src/store/modules/api.js new file mode 100644 index 0000000..f65785e --- /dev/null +++ b/UI source code/dns_mapping_ui-master/src/store/modules/api.js @@ -0,0 +1,28 @@ +// 适配 Nginx 反向代理 +const baseUrl = process.env.VUE_APP_BASE_API === '/' ? '' : process.env.VUE_APP_BASE_API +const api = { + state: { + // 部署包上传 + deployUploadApi: baseUrl + '/api/deploy/upload', + // SQL脚本上传 + databaseUploadApi: baseUrl + '/api/database/upload', + // 实时控制台 + socketApi: baseUrl + '/websocket?token=kl', + // 图片上传 + imagesUploadApi: baseUrl + '/api/localStorage/pictures', + // 修改头像 + updateAvatarApi: baseUrl + '/api/users/updateAvatar', + // 上传文件到七牛云 + qiNiuUploadApi: baseUrl + '/api/qiNiuContent', + // Sql 监控 + sqlApi: baseUrl + '/druid/index.html', + // swagger + swaggerApi: baseUrl + '/swagger-ui.html', + // 文件上传 + fileUploadApi: baseUrl + '/api/localStorage', + // baseUrl, + baseApi: baseUrl + } +} + +export default api diff --git a/UI source code/dns_mapping_ui-master/src/store/modules/app.js b/UI source code/dns_mapping_ui-master/src/store/modules/app.js new file mode 100644 index 0000000..a384479 --- /dev/null +++ b/UI source code/dns_mapping_ui-master/src/store/modules/app.js @@ -0,0 +1,56 @@ +import Cookies from 'js-cookie' + +const state = { + sidebar: { + opened: Cookies.get('sidebarStatus') ? !!+Cookies.get('sidebarStatus') : true, + withoutAnimation: false + }, + device: 'desktop', + size: Cookies.get('size') || 'small' +} + +const mutations = { + TOGGLE_SIDEBAR: state => { + state.sidebar.opened = !state.sidebar.opened + state.sidebar.withoutAnimation = false + if (state.sidebar.opened) { + Cookies.set('sidebarStatus', 1) + } else { + Cookies.set('sidebarStatus', 0) + } + }, + CLOSE_SIDEBAR: (state, withoutAnimation) => { + Cookies.set('sidebarStatus', 0) + state.sidebar.opened = false + state.sidebar.withoutAnimation = withoutAnimation + }, + TOGGLE_DEVICE: (state, device) => { + state.device = device + }, + SET_SIZE: (state, size) => { + state.size = size + Cookies.set('size', size) + } +} + +const actions = { + toggleSideBar({ commit }) { + commit('TOGGLE_SIDEBAR') + }, + closeSideBar({ commit }, { withoutAnimation }) { + commit('CLOSE_SIDEBAR', withoutAnimation) + }, + toggleDevice({ commit }, device) { + commit('TOGGLE_DEVICE', device) + }, + setSize({ commit }, size) { + commit('SET_SIZE', size) + } +} + +export default { + namespaced: true, + state, + mutations, + actions +} diff --git a/UI source code/dns_mapping_ui-master/src/store/modules/permission.js b/UI source code/dns_mapping_ui-master/src/store/modules/permission.js new file mode 100644 index 0000000..513e259 --- /dev/null +++ b/UI source code/dns_mapping_ui-master/src/store/modules/permission.js @@ -0,0 +1,83 @@ +import { constantRouterMap } from '@/router/routers' +import Layout from '@/layout/index' +import ParentView from '@/components/ParentView' + +const permission = { + state: { + routers: constantRouterMap, + addRouters: [], + sidebarRouters: [] + }, + mutations: { + SET_ROUTERS: (state, routers) => { + state.addRouters = routers + state.routers = constantRouterMap.concat(routers) + }, + SET_SIDEBAR_ROUTERS: (state, routers) => { + state.sidebarRouters = constantRouterMap.concat(routers) + } + }, + actions: { + GenerateRoutes({ commit }, asyncRouter) { + commit('SET_ROUTERS', asyncRouter) + }, + SetSidebarRouters({ commit }, sidebarRouter) { + commit('SET_SIDEBAR_ROUTERS', sidebarRouter) + } + } +} + +export const filterAsyncRouter = (routers, lastRouter = false, type = false) => { // 遍历后台传来的路由字符串,转换为组件对象 + return routers.filter(router => { + if (type && router.children) { + router.children = filterChildren(router.children) + } + if (router.component) { + if (router.component === 'Layout') { // Layout组件特殊处理 + router.component = Layout + } else if (router.component === 'ParentView') { + router.component = ParentView + } else { + const component = router.component + router.component = loadView(component) + } + } + if (router.children != null && router.children && router.children.length) { + router.children = filterAsyncRouter(router.children, router, type) + } else { + delete router['children'] + delete router['redirect'] + } + return true + }) +} + +function filterChildren(childrenMap, lastRouter = false) { + var children = [] + childrenMap.forEach((el, index) => { + if (el.children && el.children.length) { + if (el.component === 'ParentView') { + el.children.forEach(c => { + c.path = el.path + '/' + c.path + if (c.children && c.children.length) { + children = children.concat(filterChildren(c.children, c)) + return + } + children.push(c) + }) + return + } + } + if (lastRouter) { + el.path = lastRouter.path + '/' + el.path + } + children = children.concat(el) + }) + return children +} + +export const loadView = (view) => { + return (resolve) => require([`@/views/${view}`], resolve) +} + +export default permission diff --git a/UI source code/dns_mapping_ui-master/src/store/modules/searchlist.js b/UI source code/dns_mapping_ui-master/src/store/modules/searchlist.js new file mode 100644 index 0000000..f083461 --- /dev/null +++ b/UI source code/dns_mapping_ui-master/src/store/modules/searchlist.js @@ -0,0 +1,131 @@ +import { getsearchList, getleftList, getmapList } from '../../api/search' + +const state = { + list: [], // 搜索列表 + size: 10, // 每页多少条数据 + page: 1, // 当前第几页 + pages: 1, // 一共多少页 + resultTotal: 6, // 共多少条数据,分页 + left: [], // 左侧列表 + maplist: [], + Loging:true, +} + +const mutations = { + changeList(state, arr) { + state.list = arr + console.log(state.list, 222) + }, + changeLoging(state,loging){ + state.Loging = loging + // console.log(state.Loging,111); + }, + // 改变右侧列表 + changeLeft(state, left) { + state.left = left + // console.log(state.left, 333) + }, + // 地图 + changeMaplist(state, map) { + state.maplist = map + // console.log(state.maplist, 444) + }, + // 改变页数 + changePage(state, page) { + state.page = page + }, + // 改变每页请求条数 + changeSize(state, size) { + state.size = size + } +} + +const actions = { + listActions(context, obj) { + + const params = { + ip: obj.ip ? obj.ip :"", + port: obj.port ? obj.port : "", + service: obj.service ? obj.service : "", + size: state.size, + page: state.page + } + getsearchList(params).then(res => { + // console.log(params,555); + if (res.status === 200) { + if ((res.data.list === null || res.data.list.length === 0) && state.page > 1) { + // console.log(456); + const page = state.page - 1 + context.commit('changePage', page) + context.dispatch('listActions') + return + } + // console.log(res,"res"); + context.commit('changeList', res.data) + context.commit('changeLoging',false) + } + }).catch(() => console.log('列表请求未执行')) + }, + // 左侧列表请求 + leftlistActions(context, obj) { + const params = { + ip: obj.ip, + port: obj.port, + service: obj.service + } + // console.log(params); + getleftList(params).then(res => { + if (res.status === 200) { + context.commit('changeLeft', res.data) + } + }).catch(() => console.log('左侧列表请求未执行')) + }, + // 地图请求 + maplistActions(context) { + getmapList().then(res => { + // console.log(res.data); + if (res.status === 200) { + context.commit('changeMaplist', res.data) + } + }).catch(() => console.log('地图请求未执行')) + }, + // 修改当前页码数 + pageActions(context, page) { + context.commit('changePage', page) + }, + // 修改每页请求条数 + sizeActions(context, size) { + context.commit('changeSize', size) + } +} +// 派生状态 +const getters = { + // 系统自动注入参数state + list(state) { + return state.list + }, + left(state) { + return state.left + }, + maplist(state) { + return state.maplist + }, + size(state) { + return state.size + }, + total(state) { + return state.resultTotal + }, + Loging(state){ + return state.Loging + } +} + +// 导出 +export default { + state, + mutations, + actions, + getters, + namespaced: true// 使用命名空间 +} diff --git a/UI source code/dns_mapping_ui-master/src/store/modules/settings.js b/UI source code/dns_mapping_ui-master/src/store/modules/settings.js new file mode 100644 index 0000000..715ef48 --- /dev/null +++ b/UI source code/dns_mapping_ui-master/src/store/modules/settings.js @@ -0,0 +1,38 @@ +import variables from '@/assets/styles/element-variables.scss' +import defaultSettings from '@/settings' +const { tagsView, fixedHeader, sidebarLogo, uniqueOpened, showFooter, footerTxt, caseNumber, menuInLeft } = defaultSettings + +const state = { + theme: variables.theme, + showSettings: false, + tagsView: tagsView, + fixedHeader: fixedHeader, + sidebarLogo: sidebarLogo, + uniqueOpened: uniqueOpened, + showFooter: showFooter, + footerTxt: footerTxt, + caseNumber: caseNumber, + menuInLeft: false +} + +const mutations = { + CHANGE_SETTING: (state, { key, value }) => { + if (state.hasOwnProperty(key)) { + state[key] = value + } + } +} + +const actions = { + changeSetting({ commit }, data) { + commit('CHANGE_SETTING', data) + } +} + +export default { + namespaced: true, + state, + mutations, + actions +} + diff --git a/UI source code/dns_mapping_ui-master/src/store/modules/tagsView.js b/UI source code/dns_mapping_ui-master/src/store/modules/tagsView.js new file mode 100644 index 0000000..3e2c170 --- /dev/null +++ b/UI source code/dns_mapping_ui-master/src/store/modules/tagsView.js @@ -0,0 +1,165 @@ +const state = { + visitedViews: [], + cachedViews: [] +} + +const mutations = { + ADD_VISITED_VIEW: (state, view) => { + if (state.visitedViews.some(v => v.path === view.path)) return + state.visitedViews.push( + Object.assign({}, view, { + title: view.meta.title || 'no-name' + }) + ) + }, + ADD_CACHED_VIEW: (state, view) => { + if (state.cachedViews.includes(view.name)) return + if (!view.meta.noCache) { + state.cachedViews.push(view.name) + } + }, + + DEL_VISITED_VIEW: (state, view) => { + for (const [i, v] of state.visitedViews.entries()) { + if (v.path === view.path) { + state.visitedViews.splice(i, 1) + break + } + } + }, + DEL_CACHED_VIEW: (state, view) => { + for (const i of state.cachedViews) { + if (i === view.name) { + const index = state.cachedViews.indexOf(i) + state.cachedViews.splice(index, 1) + break + } + } + }, + + DEL_OTHERS_VISITED_VIEWS: (state, view) => { + state.visitedViews = state.visitedViews.filter(v => { + return v.meta.affix || v.path === view.path + }) + }, + DEL_OTHERS_CACHED_VIEWS: (state, view) => { + for (const i of state.cachedViews) { + if (i === view.name) { + const index = state.cachedViews.indexOf(i) + state.cachedViews = state.cachedViews.slice(index, index + 1) + break + } + } + }, + + DEL_ALL_VISITED_VIEWS: state => { + // keep affix tags + const affixTags = state.visitedViews.filter(tag => tag.meta.affix) + state.visitedViews = affixTags + }, + DEL_ALL_CACHED_VIEWS: state => { + state.cachedViews = [] + }, + + UPDATE_VISITED_VIEW: (state, view) => { + for (let v of state.visitedViews) { + if (v.path === view.path) { + v = Object.assign(v, view) + break + } + } + } +} + +const actions = { + addView({ dispatch }, view) { + dispatch('addVisitedView', view) + dispatch('addCachedView', view) + }, + addVisitedView({ commit }, view) { + commit('ADD_VISITED_VIEW', view) + }, + addCachedView({ commit }, view) { + commit('ADD_CACHED_VIEW', view) + }, + + delView({ dispatch, state }, view) { + return new Promise(resolve => { + dispatch('delVisitedView', view) + dispatch('delCachedView', view) + resolve({ + visitedViews: [...state.visitedViews], + cachedViews: [...state.cachedViews] + }) + }) + }, + delVisitedView({ commit, state }, view) { + return new Promise(resolve => { + commit('DEL_VISITED_VIEW', view) + resolve([...state.visitedViews]) + }) + }, + delCachedView({ commit, state }, view) { + return new Promise(resolve => { + commit('DEL_CACHED_VIEW', view) + resolve([...state.cachedViews]) + }) + }, + + delOthersViews({ dispatch, state }, view) { + return new Promise(resolve => { + dispatch('delOthersVisitedViews', view) + dispatch('delOthersCachedViews', view) + resolve({ + visitedViews: [...state.visitedViews], + cachedViews: [...state.cachedViews] + }) + }) + }, + delOthersVisitedViews({ commit, state }, view) { + return new Promise(resolve => { + commit('DEL_OTHERS_VISITED_VIEWS', view) + resolve([...state.visitedViews]) + }) + }, + delOthersCachedViews({ commit, state }, view) { + return new Promise(resolve => { + commit('DEL_OTHERS_CACHED_VIEWS', view) + resolve([...state.cachedViews]) + }) + }, + + delAllViews({ dispatch, state }, view) { + return new Promise(resolve => { + dispatch('delAllVisitedViews', view) + dispatch('delAllCachedViews', view) + resolve({ + visitedViews: [...state.visitedViews], + cachedViews: [...state.cachedViews] + }) + }) + }, + delAllVisitedViews({ commit, state }) { + return new Promise(resolve => { + commit('DEL_ALL_VISITED_VIEWS') + resolve([...state.visitedViews]) + }) + }, + delAllCachedViews({ commit, state }) { + return new Promise(resolve => { + commit('DEL_ALL_CACHED_VIEWS') + resolve([...state.cachedViews]) + }) + }, + + updateVisitedView({ commit }, view) { + commit('UPDATE_VISITED_VIEW', view) + } +} + +export default { + namespaced: true, + state, + mutations, + actions +} diff --git a/UI source code/dns_mapping_ui-master/src/store/modules/user.js b/UI source code/dns_mapping_ui-master/src/store/modules/user.js new file mode 100644 index 0000000..3b1c7fb --- /dev/null +++ b/UI source code/dns_mapping_ui-master/src/store/modules/user.js @@ -0,0 +1,94 @@ +import { login, getInfo, logout } from '@/api/login' +import { getToken, setToken, removeToken } from '@/utils/auth' + +const user = { + state: { + token: getToken(), + user: {}, + roles: [], + // 第一次加载菜单时用到 + loadMenus: false + }, + + mutations: { + SET_TOKEN: (state, token) => { + state.token = token + }, + SET_USER: (state, user) => { + state.user = user + }, + SET_ROLES: (state, roles) => { + state.roles = roles + }, + SET_LOAD_MENUS: (state, loadMenus) => { + state.loadMenus = loadMenus + } + }, + + actions: { + // 登录 + Login({ commit }, userInfo) { + const rememberMe = userInfo.rememberMe + return new Promise((resolve, reject) => { + login(userInfo.username, userInfo.password, userInfo.code, userInfo.uuid).then(res => { + setToken(res.token, rememberMe) + commit('SET_TOKEN', res.token) + setUserInfo(res.user, commit) + // 第一次加载菜单时用到, 具体见 src 目录下的 permission.js + commit('SET_LOAD_MENUS', true) + resolve() + }).catch(error => { + reject(error) + }) + }) + }, + + // 获取用户信息 + GetInfo({ commit }) { + return new Promise((resolve, reject) => { + getInfo().then(res => { + setUserInfo(res, commit) + resolve(res) + }).catch(error => { + reject(error) + }) + }) + }, + // 登出 + LogOut({ commit }) { + return new Promise((resolve, reject) => { + logout().then(res => { + logOut(commit) + resolve() + }).catch(error => { + logOut(commit) + reject(error) + }) + }) + }, + + updateLoadMenus({ commit }) { + return new Promise((resolve, reject) => { + commit('SET_LOAD_MENUS', false) + }) + } + } +} + +export const logOut = (commit) => { + commit('SET_TOKEN', '') + commit('SET_ROLES', []) + removeToken() +} + +export const setUserInfo = (res, commit) => { + // 如果没有任何权限,则赋予一个默认的权限,避免请求死循环 + if (res.roles.length === 0) { + commit('SET_ROLES', ['ROLE_SYSTEM_DEFAULT']) + } else { + commit('SET_ROLES', res.roles) + } + commit('SET_USER', res.user) +} + +export default user |
