Browse Source

【更新】优化前端代码,更改模块坞名称、删除无用的工具类、操作日志增加IP跟IP地址显示、修复文件上传组件

pull/46/head^2
小诺 2 years ago
parent
commit
9c0a63b9fd
  1. 33
      snowy-admin-web/src/components/XnUpload/index.vue
  2. 2
      snowy-admin-web/src/config/index.js
  3. 2
      snowy-admin-web/src/layout/components/setting.vue
  4. 8
      snowy-admin-web/src/layout/index.vue
  5. 2
      snowy-admin-web/src/locales/index.js
  6. 2
      snowy-admin-web/src/store/modules/global.js
  7. 156
      snowy-admin-web/src/utils/print.js
  8. 2
      snowy-admin-web/src/utils/smCrypto.js
  9. 52
      snowy-admin-web/src/utils/tool.js
  10. 2
      snowy-admin-web/src/views/dev/log/oplog/detail.vue
  11. 8
      snowy-admin-web/src/views/dev/log/oplog/index.vue

33
snowy-admin-web/src/components/XnUpload/index.vue

@ -36,6 +36,7 @@
import tool from '@/utils/tool'
import sysConfig from '@/config/index'
const fileList = ref([])
const emit = defineEmits({ uploadDone: null })
const headers = ref({
token: tool.data.get('TOKEN')
})
@ -45,12 +46,6 @@
default: '/dev/file/uploadDynamicReturnUrl',
required: false
},
//
allowMultiple: {
type: Boolean,
default: false,
required: false
},
// defaults || drag
uploadMode: {
type: String,
@ -66,22 +61,16 @@
})
const action = sysConfig.API_URL + props.action
const handleChange = () => {}
//
const getUploadData = () => {
return fileList.value.map((item) => {
return {
uid: item.uid,
name: item.name,
status: item.status,
url: item.response.data
const handleChange = () => {
let result = []
for (let a = 0; a < props.uploadMumber; a++) {
const file = fileList.value[a]
if (file.status === 'done' && file.response && file.response.code === 200) {
result.push(file.response.data)
}
})
}
if (result.length > 0) {
emit('uploadDone', result)
}
}
defineExpose({
getUploadData
})
</script>
<style scoped></style>

2
snowy-admin-web/src/config/index.js

@ -36,7 +36,7 @@ const DEFAULT_CONFIG = {
// 菜单是否折叠
SNOWY_MENU_COLLAPSE: false,
// 目录
// 模块
SNOWY_MODULE_UNFOLD_OPEN: true,
// 是否开启多标签

2
snowy-admin-web/src/layout/components/setting.vue

@ -55,7 +55,7 @@
</div>
<a-divider />
<a-form ref="form" style="text-align: right">
<a-form-item label="目录坞">
<a-form-item label="模块坞">
<a-switch v-model:checked="moduleUnfoldOpen" />
</a-form-item>
<a-form-item label="面包屑">

8
snowy-admin-web/src/layout/index.vue

@ -484,9 +484,11 @@
: header.classList.remove('snowy-header-primary-color')
//
const headerLogin = document.getElementById('snowyHeaderLogo')
this.topHanderThemeColorSpread
? headerLogin.classList.add('snowy-header-logo-primary-color')
: headerLogin.classList.remove('snowy-header-logo-primary-color')
try{
this.topHanderThemeColorSpread
? headerLogin.classList.add('snowy-header-logo-primary-color')
: headerLogin.classList.remove('snowy-header-logo-primary-color')
}catch (e) { }
//
if (this.layout === 'doublerow') {
const snowyDoublerowSideTop = document.getElementById('snowyDoublerowSideTop')

2
snowy-admin-web/src/locales/index.js

@ -14,7 +14,7 @@ import enGB from 'ant-design-vue/es/locale/en_GB'
import zh_cn from './lang/zh-cn.js'
import en from './lang/en.js'
import tool from '@/utils/tool'
import sysConfig from '@/config/index.js'
import sysConfig from '@/config/index'
export const messages = {
'zh-cn': {

2
snowy-admin-web/src/store/modules/global.js

@ -44,7 +44,7 @@ export default {
// 顶栏主题色通栏
topHanderThemeColorSpread:
getCacheConfig('SNOWY_TOP_HANDER_THEME_COLOR_SPREAD'),
// 目录
// 模块
moduleUnfoldOpen: getCacheConfig('SNOWY_MODULE_UNFOLD_OPEN'),
// 主题
theme: getCacheConfig('SNOWY_THEME'),

156
snowy-admin-web/src/utils/print.js

@ -1,156 +0,0 @@
/**
* Copyright [2022] [https://www.xiaonuo.vip]
* Snowy采用APACHE LICENSE 2.0开源协议您在使用过程中需要注意以下几点
* 1.请不要删除和修改根目录下的LICENSE文件
* 2.请不要删除和修改Snowy源码头部的版权声明
* 3.本项目代码可免费商业使用商业使用请保留源码和相关描述文件的项目出处作者声明等
* 4.分发源码时候请注明软件出处 https://www.xiaonuo.vip
* 5.不可二次分发开源参与同类竞品如有想法可联系团队xiaonuobase@qq.com商议合作
* 6.若您的项目无法满足以上几点需要更多功能代码获取Snowy商业授权许可请在官网购买授权地址为 https://www.xiaonuo.vip
*/
/* eslint-disable */
// 打印类属性、方法定义
const Print = function(dom, options) {
if (!(this instanceof Print)) return new Print(dom, options)
this.options = this.extend({
noPrint: '.no-print',
}, options)
if ((typeof dom) === 'string') {
try {
this.dom = document.querySelector(dom)
}
catch {
const createDom = document.createElement('div')
createDom.innerHTML = dom
this.dom = createDom
}
}
else {
this.isDOM(dom)
this.dom = this.isDOM(dom) ? dom : dom.$el
}
this.init()
}
Print.prototype = {
init() {
const content = this.getStyle() + this.getHtml()
this.writeIframe(content)
},
extend(obj, obj2) {
for (const k in obj2) {
obj[k] = obj2[k]
}
return obj
},
getStyle() {
let str = ''
const styles = document.querySelectorAll('style,link')
for (let i = 0; i < styles.length; i++) {
str += styles[i].outerHTML
}
str += `<style>${ this.options.noPrint ? this.options.noPrint : '.no-print'
}{display:none;}</style>`
str += '<style>html,body{background-color:#fff;}</style>'
return str
},
getHtml() {
const inputs = document.querySelectorAll('input')
const textareas = document.querySelectorAll('textarea')
const selects = document.querySelectorAll('select')
for (let k = 0; k < inputs.length; k++) {
if (inputs[k].type == 'checkbox' || inputs[k].type == 'radio') {
if (inputs[k].checked == true) {
inputs[k].setAttribute('checked', 'checked')
}
else {
inputs[k].removeAttribute('checked')
}
}
else if (inputs[k].type == 'text') {
inputs[k].setAttribute('value', inputs[k].value)
}
else {
inputs[k].setAttribute('value', inputs[k].value)
}
}
for (let k2 = 0; k2 < textareas.length; k2++) {
if (textareas[k2].type == 'textarea') {
textareas[k2].innerHTML = textareas[k2].value
}
}
for (let k3 = 0; k3 < selects.length; k3++) {
if (selects[k3].type == 'select-one') {
const child = selects[k3].children
for (const i in child) {
if (child[i].tagName == 'OPTION') {
if (child[i].selected == true) {
child[i].setAttribute('selected', 'selected')
}
else {
child[i].removeAttribute('selected')
}
}
}
}
}
return this.dom.outerHTML
},
writeIframe(content) {
let w; let doc; const iframe = document.createElement('iframe')
const f = document.body.appendChild(iframe)
iframe.id = 'myIframe'
// iframe.style = "position:absolute;width:0;height:0;top:-10px;left:-10px;";
iframe.setAttribute('style', 'position:absolute;width:0;height:0;top:-10px;left:-10px;')
w = f.contentWindow || f.contentDocument
doc = f.contentDocument || f.contentWindow.document
doc.open()
doc.write(content)
doc.close()
const _this = this
iframe.onload = function() {
_this.toPrint(w)
setTimeout(() => {
document.body.removeChild(iframe)
}, 100)
}
},
toPrint(frameWindow) {
try {
setTimeout(() => {
frameWindow.focus()
try {
if (!frameWindow.document.execCommand('print', false, null)) {
frameWindow.print()
}
}
catch (e) {
frameWindow.print()
}
frameWindow.close()
}, 10)
}
catch (err) {
console.log('err', err)
}
},
isDOM: (typeof HTMLElement === 'object')
? function(obj) {
return obj instanceof HTMLElement
}
: function(obj) {
return obj && typeof obj === 'object' && obj.nodeType === 1 && typeof obj.nodeName === 'string'
},
}
export default Print

2
snowy-admin-web/src/utils/smCrypto.js

@ -49,7 +49,7 @@ export default {
doSm3Hash(msgString) {
return sm3(msgString)
},
// SM4 CBC加密
// SM4 加密
doSm4Encrypt(msgString) {
return sm4.encrypt(msgString, key)
},

52
snowy-admin-web/src/utils/tool.js

@ -14,15 +14,9 @@
* @LastEditors: yubaoshan
* @LastEditTime: 2022年4月19日10:58:41
*/
const tool = {}
/**
* localStorage
*
* @author yubaoshan
* @date 2022-05-18 22:59
*/
// localStorage
tool.data = {
set(table, settings) {
const _set = JSON.stringify(settings)
@ -46,12 +40,7 @@ tool.data = {
}
}
/**
* sessionStorage
*
* @author yubaoshan
* @date 2022-05-18 22:59
*/
// sessionStorage
tool.session = {
set(table, settings) {
const _set = JSON.stringify(settings)
@ -74,12 +63,7 @@ tool.session = {
}
}
/**
* 千分符
*
* @author yubaoshan
* @date 2022-05-18 22:59
*/
// 千分符
tool.groupSeparator = (num) => {
num = `${num}`
if (!num.includes('.')) num += '.'
@ -91,24 +75,12 @@ tool.groupSeparator = (num) => {
.replace(/\.$/, '')
}
/**
* 获取所有字典数组
*
* @author yubaoshan
* @date 2022-04-08 01:11
*/
// 获取所有字典数组
tool.dictDataAll = () => {
return tool.data.get('DICT_TYPE_TREE_DATA')
}
/**
* 字典翻译方法
* 界面插槽使用方法 {{ $TOOL.dictType('sex', record.sex) }}
*
* @author yubaoshan
* @date 2022-04-08 01:11
*/
// todo 每次都从localStorage获取并重新解析,会有性能问题,应该在内存中做一层缓存,后面需要优化掉
// 字典翻译方法,界面插槽使用方法 {{ $TOOL.dictType('sex', record.sex) }}
tool.dictTypeData = (dictValue, value) => {
const dictTypeTree = tool.dictDataAll()
if (!dictTypeTree) {
@ -123,12 +95,7 @@ tool.dictTypeData = (dictValue, value) => {
return dict?.name || '无此字典'
}
/**
* 获取某个code下字典的列表多用于字典下拉框
*
* @author yubaoshan
* @date 2022-04-08 01:11
*/
// 获取某个code下字典的列表,多用于字典下拉框
tool.dictTypeList = (dictValue) => {
const dictTypeTree = tool.dictDataAll()
if (!dictTypeTree) {
@ -141,12 +108,7 @@ tool.dictTypeList = (dictValue) => {
return []
}
/**
* 生成UUID
*
* @author yubaoshan
* @date 2022-05-18 22:59
*/
// 生成UUID
tool.snowyUuid = () => {
let uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
let r = (Math.random() * 16) | 0,

2
snowy-admin-web/src/views/dev/log/oplog/detail.vue

@ -9,6 +9,8 @@
>
<a-descriptions :column="1" size="middle" bordered class="mb-2">
<a-descriptions-item label="名称">{{ formData.name }}</a-descriptions-item>
<a-descriptions-item label="请求IP">{{ formData.opIp }}</a-descriptions-item>
<a-descriptions-item label="IP来源">{{ formData.opAddress }}</a-descriptions-item>
<a-descriptions-item label="请求地址">{{ formData.reqUrl }}</a-descriptions-item>
<a-descriptions-item label="操作类">{{ formData.className }}</a-descriptions-item>
<a-descriptions-item label="操作方法">{{ formData.methodName }}</a-descriptions-item>

8
snowy-admin-web/src/views/dev/log/oplog/index.vue

@ -87,6 +87,14 @@
title: '名称',
dataIndex: 'name'
},
{
title: 'IP地址',
dataIndex: 'opIp'
},
{
title: '地址',
dataIndex: 'opAddress'
},
{
title: '类名称',
dataIndex: 'className'

Loading…
Cancel
Save