优化代码

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"> <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"> <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> <span class="el-icon-document"> {{ getFileName(file.name) }} </span>
</el-link> </el-link>
<div class="ele-upload-list__item-content-action"> <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> </div>
</li> </li>
</transition-group> </transition-group>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -199,7 +199,7 @@
<el-checkbox v-model="upload.updateSupport" />是否更新已经存在的用户数据 <el-checkbox v-model="upload.updateSupport" />是否更新已经存在的用户数据
</div> </div>
<span>仅允许导入xlsxlsx格式文件</span> <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> </div>
</template> </template>
</el-upload> </el-upload>
@@ -415,7 +415,7 @@ function handleResetPwd(row) {
} }
}, },
}).then(({ value }) => { }).then(({ value }) => {
resetUserPwd(row.userId, value).then(response => { resetUserPwd(row.userId, value).then(() => {
proxy.$modal.msgSuccess("修改成功,新密码是:" + value) proxy.$modal.msgSuccess("修改成功,新密码是:" + value)
}) })
}).catch(() => {}) }).catch(() => {})
@@ -524,7 +524,7 @@ function handleUpdate(row) {
form.value.roleIds = response.roleIds form.value.roleIds = response.roleIds
open.value = true open.value = true
title.value = "修改用户" title.value = "修改用户"
form.password = "" form.value.password = ""
}) })
} }
@@ -533,13 +533,13 @@ function submitForm() {
proxy.$refs["userRef"].validate(valid => { proxy.$refs["userRef"].validate(valid => {
if (valid) { if (valid) {
if (form.value.userId != undefined) { if (form.value.userId != undefined) {
updateUser(form.value).then(response => { updateUser(form.value).then(() => {
proxy.$modal.msgSuccess("修改成功") proxy.$modal.msgSuccess("修改成功")
open.value = false open.value = false
getList() getList()
}) })
} else { } else {
addUser(form.value).then(response => { addUser(form.value).then(() => {
proxy.$modal.msgSuccess("新增成功") proxy.$modal.msgSuccess("新增成功")
open.value = false open.value = false
getList() getList()

View File

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

View File

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