优化代码

This commit is contained in:
RuoYi
2026-01-28 13:08:39 +08:00
parent 5cb67df134
commit 837ecf26bf
23 changed files with 127 additions and 130 deletions

View File

@@ -29,11 +29,11 @@
<!-- 文件列表 -->
<transition-group ref="uploadFileList" class="upload-file-list el-upload-list el-upload-list--text" name="el-fade-in-linear" tag="ul">
<li :key="file.uid" class="el-upload-list__item ele-upload-list__item-content" v-for="(file, index) in fileList">
<el-link :href="`${baseUrl}${file.url}`" :underline="false" target="_blank">
<el-link :href="`${baseUrl}${file.url}`" underline="never" target="_blank">
<span class="el-icon-document"> {{ getFileName(file.name) }} </span>
</el-link>
<div class="ele-upload-list__item-content-action">
<el-link :underline="false" @click="handleDelete(index)" type="danger" v-if="!disabled">&nbsp;删除</el-link>
<el-link underline="never" @click="handleDelete(index)" type="danger" v-if="!disabled">&nbsp;删除</el-link>
</div>
</li>
</transition-group>

View File

@@ -7,7 +7,7 @@
<script setup>
import { useFullscreen } from '@vueuse/core'
const { isFullscreen, enter, exit, toggle } = useFullscreen()
const { isFullscreen, toggle } = useFullscreen()
</script>
<style lang='scss' scoped>

View File

@@ -20,8 +20,6 @@ import useAppStore from "@/store/modules/app"
const appStore = useAppStore()
const size = computed(() => appStore.size)
const route = useRoute()
const router = useRouter()
const { proxy } = getCurrentInstance()
const sizeOptions = ref([
{ label: "较大", value: "large" },

View File

@@ -22,7 +22,6 @@ import useSettingsStore from '@/store/modules/settings'
const settingsStore = useSettingsStore()
const theme = computed(() => settingsStore.theme)
const sideTheme = computed(() => settingsStore.sideTheme)
const sidebar = computed(() => useAppStore().sidebar)
const device = computed(() => useAppStore().device)
const needTagsView = computed(() => settingsStore.tagsView)

View File

@@ -5,13 +5,13 @@ import { parseTime } from './ruoyi'
*/
export function formatDate(cellValue) {
if (cellValue == null || cellValue == "") return ""
var date = new Date(cellValue)
var year = date.getFullYear()
var month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1
var day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
var hours = date.getHours() < 10 ? '0' + date.getHours() : date.getHours()
var minutes = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()
var seconds = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()
const date = new Date(cellValue)
const year = date.getFullYear()
const month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1
const day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
const hours = date.getHours() < 10 ? '0' + date.getHours() : date.getHours()
const minutes = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()
const seconds = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()
return year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds
}
@@ -84,7 +84,7 @@ export function getQueryObject(url) {
export function byteLength(str) {
// returns the byte length of an utf8 string
let s = str.length
for (var i = str.length - 1; i >= 0; i--) {
for (let i = str.length - 1; i >= 0; i--) {
const code = str.charCodeAt(i)
if (code > 0x7f && code <= 0x7ff) s++
else if (code > 0x7ff && code <= 0xffff) s += 2

View File

@@ -71,7 +71,7 @@ export function selectDictLabel(datas, value) {
if (value === undefined) {
return ""
}
var actions = []
const actions = []
Object.keys(datas).some((key) => {
if (datas[key].value == ('' + value)) {
actions.push(datas[key].label)
@@ -92,11 +92,11 @@ export function selectDictLabels(datas, value, separator) {
if (Array.isArray(value)) {
value = value.join(",")
}
var actions = []
var currentSeparator = undefined === separator ? "," : separator
var temp = value.split(currentSeparator)
const actions = []
const currentSeparator = undefined === separator ? "," : separator
const temp = value.split(currentSeparator)
Object.keys(value.split(currentSeparator)).some((val) => {
var match = false
let match = false
Object.keys(datas).some((key) => {
if (datas[key].value == ('' + temp[val])) {
actions.push(datas[key].label + currentSeparator)
@@ -112,9 +112,9 @@ export function selectDictLabels(datas, value, separator) {
// 字符串格式化(%s )
export function sprintf(str) {
var args = arguments, flag = true, i = 1
let flag = true, i = 1
str = str.replace(/%s/g, function () {
var arg = args[i++]
const arg = args[i++]
if (typeof arg === 'undefined') {
flag = false
return ''
@@ -134,7 +134,7 @@ export function parseStrEmpty(str) {
// 数据合并
export function mergeRecursive(source, target) {
for (var p in target) {
for (const p in target) {
try {
if (target[p].constructor == Object) {
source[p] = mergeRecursive(source[p], target[p])
@@ -156,25 +156,25 @@ export function mergeRecursive(source, target) {
* @param {*} children 孩子节点字段 默认 'children'
*/
export function handleTree(data, id, parentId, children) {
let config = {
const config = {
id: id || 'id',
parentId: parentId || 'parentId',
childrenList: children || 'children'
}
var childrenListMap = {}
var tree = []
for (let d of data) {
let id = d[config.id]
const childrenListMap = {}
const tree = []
for (const d of data) {
const id = d[config.id]
childrenListMap[id] = d
if (!d[config.childrenList]) {
d[config.childrenList] = []
}
}
for (let d of data) {
let parentId = d[config.parentId]
let parentObj = childrenListMap[parentId]
for (const d of data) {
const parentId = d[config.parentId]
const parentObj = childrenListMap[parentId]
if (!parentObj) {
tree.push(d)
} else {
@@ -192,13 +192,13 @@ export function tansParams(params) {
let result = ''
for (const propName of Object.keys(params)) {
const value = params[propName]
var part = encodeURIComponent(propName) + "="
const part = encodeURIComponent(propName) + "="
if (value !== null && value !== "" && typeof (value) !== "undefined") {
if (typeof value === 'object') {
for (const key of Object.keys(value)) {
if (value[key] !== null && value[key] !== "" && typeof (value[key]) !== 'undefined') {
let params = propName + '[' + key + ']'
var subPart = encodeURIComponent(params) + "="
const params = propName + '[' + key + ']'
const subPart = encodeURIComponent(params) + "="
result += subPart + encodeURIComponent(value[key]) + "&"
}
}

View File

@@ -8,7 +8,7 @@ Math.easeInOutQuad = function(t, b, c, d) {
}
// requestAnimationFrame for Smart Animating http://goo.gl/sx5sts
var requestAnimFrame = (function() {
const requestAnimFrame = (function() {
return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || function(callback) { window.setTimeout(callback, 1000 / 60) }
})()
@@ -37,11 +37,11 @@ export function scrollTo(to, duration, callback) {
const increment = 20
let currentTime = 0
duration = (typeof (duration) === 'undefined') ? 500 : duration
var animateScroll = function() {
const animateScroll = function() {
// increment the time
currentTime += increment
// find the value with the quadratic in-out easing function
var val = Math.easeInOutQuad(currentTime, start, change, duration)
const val = Math.easeInOutQuad(currentTime, start, change, duration)
// move the document.body
move(val)
// do the animation unless its over

View File

@@ -352,8 +352,8 @@ function reset() {
jobGroup: undefined,
invokeTarget: undefined,
cronExpression: undefined,
misfirePolicy: 1,
concurrent: 1,
misfirePolicy: '1',
concurrent: '1',
status: "0"
}
proxy.resetForm("jobRef")
@@ -412,8 +412,8 @@ function handleRun(row) {
proxy.$modal.confirm('确认要立即执行一次"' + row.jobName + '"任务吗?').then(function () {
return runJob(row.jobId, row.jobGroup)
}).then(() => {
proxy.$modal.msgSuccess("执行成功")})
.catch(() => {})
proxy.$modal.msgSuccess("执行成功")
}).catch(() => {})
}
/** 任务详细信息 */

View File

@@ -249,13 +249,13 @@ function submitForm() {
proxy.$refs["postRef"].validate(valid => {
if (valid) {
if (form.value.postId != undefined) {
updatePost(form.value).then(response => {
updatePost(form.value).then(() => {
proxy.$modal.msgSuccess("修改成功")
open.value = false
getList()
})
} else {
addPost(form.value).then(response => {
addPost(form.value).then(() => {
proxy.$modal.msgSuccess("新增成功")
open.value = false
getList()

View File

@@ -164,7 +164,7 @@ function cancelAuthUser(row) {
}
/** 批量取消授权按钮操作 */
function cancelAuthUserAll(row) {
function cancelAuthUserAll() {
const roleId = queryParams.roleId
const uIds = userIds.value.join(",")
proxy.$modal.confirm("是否取消选中用户授权数据项?").then(function () {

View File

@@ -512,14 +512,14 @@ function submitForm() {
if (valid) {
if (form.value.roleId != undefined) {
form.value.menuIds = getMenuAllCheckedKeys()
updateRole(form.value).then(response => {
updateRole(form.value).then(() => {
proxy.$modal.msgSuccess("修改成功")
open.value = false
getList()
})
} else {
form.value.menuIds = getMenuAllCheckedKeys()
addRole(form.value).then(response => {
addRole(form.value).then(() => {
proxy.$modal.msgSuccess("新增成功")
open.value = false
getList()
@@ -566,7 +566,7 @@ function handleDataScope(row) {
function submitDataScope() {
if (form.value.roleId != undefined) {
form.value.deptIds = getDeptAllCheckedKeys()
dataScope(form.value).then(response => {
dataScope(form.value).then(() => {
proxy.$modal.msgSuccess("修改成功")
openDataScope.value = false
getList()

View File

@@ -95,7 +95,7 @@ function close() {
function submitForm() {
const userId = form.value.userId
const rIds = roleIds.value.join(",")
updateAuthRole({ userId: userId, roleIds: rIds }).then(response => {
updateAuthRole({ userId: userId, roleIds: rIds }).then(() => {
proxy.$modal.msgSuccess("授权成功")
close()
})

View File

@@ -199,7 +199,7 @@
<el-checkbox v-model="upload.updateSupport" />是否更新已经存在的用户数据
</div>
<span>仅允许导入xlsxlsx格式文件</span>
<el-link type="primary" :underline="false" style="font-size: 12px; vertical-align: baseline" @click="importTemplate">下载模板</el-link>
<el-link type="primary" underline="never" style="font-size: 12px; vertical-align: baseline" @click="importTemplate">下载模板</el-link>
</div>
</template>
</el-upload>
@@ -415,7 +415,7 @@ function handleResetPwd(row) {
}
},
}).then(({ value }) => {
resetUserPwd(row.userId, value).then(response => {
resetUserPwd(row.userId, value).then(() => {
proxy.$modal.msgSuccess("修改成功,新密码是:" + value)
})
}).catch(() => {})
@@ -524,7 +524,7 @@ function handleUpdate(row) {
form.value.roleIds = response.roleIds
open.value = true
title.value = "修改用户"
form.password = ""
form.value.password = ""
})
}
@@ -533,13 +533,13 @@ function submitForm() {
proxy.$refs["userRef"].validate(valid => {
if (valid) {
if (form.value.userId != undefined) {
updateUser(form.value).then(response => {
updateUser(form.value).then(() => {
proxy.$modal.msgSuccess("修改成功")
open.value = false
getList()
})
} else {
addUser(form.value).then(response => {
addUser(form.value).then(() => {
proxy.$modal.msgSuccess("新增成功")
open.value = false
getList()

View File

@@ -45,7 +45,7 @@ const rules = ref({
function submit() {
proxy.$refs.pwdRef.validate(valid => {
if (valid) {
updateUserPwd(user.oldPassword, user.newPassword).then(response => {
updateUserPwd(user.oldPassword, user.newPassword).then(() => {
proxy.$modal.msgSuccess("修改成功")
})
}

View File

@@ -44,7 +44,7 @@ const rules = ref({
function submit() {
proxy.$refs.userRef.validate(valid => {
if (valid) {
updateUserProfile(form.value).then(response => {
updateUserProfile(form.value).then(() => {
proxy.$modal.msgSuccess("修改成功")
props.user.phonenumber = form.value.phonenumber
props.user.email = form.value.email