mirror of
https://github.com/veops/cmdb.git
synced 2025-08-08 20:07:16 +08:00
add ui
This commit is contained in:
34
ui/src/core/bootstrap.js
vendored
Normal file
34
ui/src/core/bootstrap.js
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
import Vue from 'vue'
|
||||
import store from '@/store/'
|
||||
import {
|
||||
ACCESS_TOKEN,
|
||||
DEFAULT_COLOR,
|
||||
DEFAULT_THEME,
|
||||
DEFAULT_LAYOUT_MODE,
|
||||
DEFAULT_COLOR_WEAK,
|
||||
SIDEBAR_TYPE,
|
||||
DEFAULT_FIXED_HEADER,
|
||||
DEFAULT_FIXED_HEADER_HIDDEN,
|
||||
DEFAULT_FIXED_SIDEMENU,
|
||||
DEFAULT_CONTENT_WIDTH_TYPE,
|
||||
DEFAULT_MULTI_TAB
|
||||
} from '@/store/mutation-types'
|
||||
import config from '@/config/defaultSettings'
|
||||
|
||||
export default function Initializer () {
|
||||
console.log(`API_URL: ${process.env.VUE_APP_API_BASE_URL}`)
|
||||
|
||||
store.commit('SET_SIDEBAR_TYPE', Vue.ls.get(SIDEBAR_TYPE, true))
|
||||
store.commit('TOGGLE_THEME', Vue.ls.get(DEFAULT_THEME, config.navTheme))
|
||||
store.commit('TOGGLE_LAYOUT_MODE', Vue.ls.get(DEFAULT_LAYOUT_MODE, config.layout))
|
||||
store.commit('TOGGLE_FIXED_HEADER', Vue.ls.get(DEFAULT_FIXED_HEADER, config.fixedHeader))
|
||||
store.commit('TOGGLE_FIXED_SIDERBAR', Vue.ls.get(DEFAULT_FIXED_SIDEMENU, config.fixSiderbar))
|
||||
store.commit('TOGGLE_CONTENT_WIDTH', Vue.ls.get(DEFAULT_CONTENT_WIDTH_TYPE, config.contentWidth))
|
||||
store.commit('TOGGLE_FIXED_HEADER_HIDDEN', Vue.ls.get(DEFAULT_FIXED_HEADER_HIDDEN, config.autoHideHeader))
|
||||
store.commit('TOGGLE_WEAK', Vue.ls.get(DEFAULT_COLOR_WEAK, config.colorWeak))
|
||||
store.commit('TOGGLE_COLOR', Vue.ls.get(DEFAULT_COLOR, config.primaryColor))
|
||||
store.commit('TOGGLE_MULTI_TAB', Vue.ls.get(DEFAULT_MULTI_TAB, config.multiTab))
|
||||
store.commit('SET_TOKEN', Vue.ls.get(ACCESS_TOKEN))
|
||||
|
||||
// last step
|
||||
}
|
34
ui/src/core/directives/action.js
Normal file
34
ui/src/core/directives/action.js
Normal file
@@ -0,0 +1,34 @@
|
||||
import Vue from 'vue'
|
||||
import store from '@/store'
|
||||
|
||||
/**
|
||||
* Action 权限指令
|
||||
* 指令用法:
|
||||
* - 在需要控制 action 级别权限的组件上使用 v-action:[method] , 如下:
|
||||
* <i-button v-action:add >添加用户</a-button>
|
||||
* <a-button v-action:delete>删除用户</a-button>
|
||||
* <a v-action:edit @click="edit(record)">修改</a>
|
||||
*
|
||||
* - 当前用户没有权限时,组件上使用了该指令则会被隐藏
|
||||
* - 当后台权限跟 pro 提供的模式不同时,只需要针对这里的权限过滤进行修改即可
|
||||
*
|
||||
* @see https://github.com/sendya/ant-design-pro-vue/pull/53
|
||||
*/
|
||||
const action = Vue.directive('action', {
|
||||
inserted: function (el, binding, vnode) {
|
||||
const actionName = binding.arg
|
||||
const roles = store.getters.roles
|
||||
const elVal = vnode.context.$route.meta.permission
|
||||
const permissionId = elVal instanceof String && [elVal] || elVal
|
||||
roles.permissions.forEach(p => {
|
||||
if (!permissionId.includes(p.permissionId)) {
|
||||
return
|
||||
}
|
||||
if (p.actionList && !p.actionList.includes(actionName)) {
|
||||
el.parentNode && el.parentNode.removeChild(el) || (el.style.display = 'none')
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
export default action
|
11
ui/src/core/icons.js
Normal file
11
ui/src/core/icons.js
Normal file
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* Custom icon list
|
||||
* All icons are loaded here for easy management
|
||||
* @see https://vue.ant.design/components/icon/#Custom-Font-Icon
|
||||
*
|
||||
* 自定义图标加载表
|
||||
* 所有图标均从这里加载,方便管理
|
||||
*/
|
||||
import bxAnaalyse from '@/assets/icons/bx-analyse.svg?inline' // path to your '*.svg?inline' file.
|
||||
|
||||
export { bxAnaalyse }
|
99
ui/src/core/lazy_lib/components_use.js
Normal file
99
ui/src/core/lazy_lib/components_use.js
Normal file
@@ -0,0 +1,99 @@
|
||||
|
||||
/* eslint-disable */
|
||||
/**
|
||||
* 该文件是为了按需加载,剔除掉了一些不需要的框架组件。
|
||||
* 减少了编译支持库包大小
|
||||
*
|
||||
* 当需要更多组件依赖时,在该文件加入即可
|
||||
*/
|
||||
import Vue from 'vue'
|
||||
import {
|
||||
LocaleProvider,
|
||||
Layout,
|
||||
Input,
|
||||
InputNumber,
|
||||
Button,
|
||||
Switch,
|
||||
Radio,
|
||||
Checkbox,
|
||||
Select,
|
||||
Card,
|
||||
Form,
|
||||
Row,
|
||||
Col,
|
||||
Modal,
|
||||
Table,
|
||||
Tabs,
|
||||
Icon,
|
||||
Badge,
|
||||
Popover,
|
||||
Dropdown,
|
||||
List,
|
||||
Avatar,
|
||||
Breadcrumb,
|
||||
Steps,
|
||||
Spin,
|
||||
Menu,
|
||||
Drawer,
|
||||
Tooltip,
|
||||
Alert,
|
||||
Tag,
|
||||
Divider,
|
||||
DatePicker,
|
||||
TimePicker,
|
||||
Upload,
|
||||
Progress,
|
||||
Skeleton,
|
||||
Popconfirm,
|
||||
message,
|
||||
notification
|
||||
} from 'ant-design-vue'
|
||||
// import VueCropper from 'vue-cropper'
|
||||
|
||||
Vue.use(LocaleProvider)
|
||||
Vue.use(Layout)
|
||||
Vue.use(Input)
|
||||
Vue.use(InputNumber)
|
||||
Vue.use(Button)
|
||||
Vue.use(Switch)
|
||||
Vue.use(Radio)
|
||||
Vue.use(Checkbox)
|
||||
Vue.use(Select)
|
||||
Vue.use(Card)
|
||||
Vue.use(Form)
|
||||
Vue.use(Row)
|
||||
Vue.use(Col)
|
||||
Vue.use(Modal)
|
||||
Vue.use(Table)
|
||||
Vue.use(Tabs)
|
||||
Vue.use(Icon)
|
||||
Vue.use(Badge)
|
||||
Vue.use(Popover)
|
||||
Vue.use(Dropdown)
|
||||
Vue.use(List)
|
||||
Vue.use(Avatar)
|
||||
Vue.use(Breadcrumb)
|
||||
Vue.use(Steps)
|
||||
Vue.use(Spin)
|
||||
Vue.use(Menu)
|
||||
Vue.use(Drawer)
|
||||
Vue.use(Tooltip)
|
||||
Vue.use(Alert)
|
||||
Vue.use(Tag)
|
||||
Vue.use(Divider)
|
||||
Vue.use(DatePicker)
|
||||
Vue.use(TimePicker)
|
||||
Vue.use(Upload)
|
||||
Vue.use(Progress)
|
||||
Vue.use(Skeleton)
|
||||
Vue.use(Popconfirm)
|
||||
// Vue.use(VueCropper)
|
||||
Vue.use(notification)
|
||||
|
||||
Vue.prototype.$confirm = Modal.confirm
|
||||
Vue.prototype.$message = message
|
||||
Vue.prototype.$notification = notification
|
||||
Vue.prototype.$info = Modal.info
|
||||
Vue.prototype.$success = Modal.success
|
||||
Vue.prototype.$error = Modal.error
|
||||
Vue.prototype.$warning = Modal.warning
|
20
ui/src/core/lazy_use.js
Normal file
20
ui/src/core/lazy_use.js
Normal file
@@ -0,0 +1,20 @@
|
||||
import Vue from 'vue'
|
||||
import VueStorage from 'vue-ls'
|
||||
import config from '@/config/defaultSettings'
|
||||
|
||||
// base library
|
||||
import '@/core/lazy_lib/components_use'
|
||||
import Viser from 'viser-vue'
|
||||
|
||||
// ext library
|
||||
import VueClipboard from 'vue-clipboard2'
|
||||
import PermissionHelper from '@/utils/helper/permission'
|
||||
import './directives/action'
|
||||
|
||||
VueClipboard.config.autoSetContainer = true
|
||||
|
||||
Vue.use(Viser)
|
||||
|
||||
Vue.use(VueStorage, config.storageOptions)
|
||||
Vue.use(VueClipboard)
|
||||
Vue.use(PermissionHelper)
|
25
ui/src/core/use.js
Normal file
25
ui/src/core/use.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import Vue from 'vue'
|
||||
import VueStorage from 'vue-ls'
|
||||
import config from '@/config/defaultSettings'
|
||||
|
||||
// base library
|
||||
import Antd from 'ant-design-vue'
|
||||
import Viser from 'viser-vue'
|
||||
import VueCropper from 'vue-cropper'
|
||||
import 'ant-design-vue/dist/antd.less'
|
||||
|
||||
// ext library
|
||||
import VueClipboard from 'vue-clipboard2'
|
||||
import PermissionHelper from '@/utils/helper/permission'
|
||||
// import '@/components/use'
|
||||
import './directives/action'
|
||||
|
||||
VueClipboard.config.autoSetContainer = true
|
||||
|
||||
Vue.use(Antd)
|
||||
Vue.use(Viser)
|
||||
|
||||
Vue.use(VueStorage, config.storageOptions)
|
||||
Vue.use(VueClipboard)
|
||||
Vue.use(PermissionHelper)
|
||||
Vue.use(VueCropper)
|
Reference in New Issue
Block a user