开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
文件
master
分支 (13)
标签 (4)
master
develop
cherry-pick-1684465687
dev_hyc_v1.2
feat-admin
feat-split_deploy
feat-channel
cherry-pick-1675816700
dev_storage_morpheus
dev_hyc_dict
dev_cyx
dev_hyc1103
dev_hyc
1.2.0
1.1.0
1.0.1
1.0.0
master
分支 (13)
标签 (4)
master
develop
cherry-pick-1684465687
dev_hyc_v1.2
feat-admin
feat-split_deploy
feat-channel
cherry-pick-1675816700
dev_storage_morpheus
dev_hyc_dict
dev_cyx
dev_hyc1103
dev_hyc
1.2.0
1.1.0
1.0.1
1.0.0
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
master
分支 (13)
标签 (4)
master
develop
cherry-pick-1684465687
dev_hyc_v1.2
feat-admin
feat-split_deploy
feat-channel
cherry-pick-1675816700
dev_storage_morpheus
dev_hyc_dict
dev_cyx
dev_hyc1103
dev_hyc
1.2.0
1.1.0
1.0.1
1.0.0
util.ts 4.84 KB
一键复制 编辑 原始数据 按行查看 历史
Yuuu_x 提交于 2022年11月21日 10:49 +08:00 . 1.0
import { isObject } from '@vue/shared'
import { cloneDeep } from 'lodash'
/**
* @description 添加单位
* @param {String | Number} value 值 100
* @param {String} unit 单位 px em rem
*/
export const addUnit = (value: string | number, unit = 'px') => {
return !Object.is(Number(value), NaN) ? `${value}${unit}` : value
}
/**
* @description 添加单位
* @param {unknown} value
* @return {Boolean}
*/
export const isEmpty = (value: unknown) => {
return value == null && typeof value == 'undefined'
}
/**
* @description 树转数组,队列实现广度优先遍历
* @param {Array} data 数据
* @param {Object} props `{ children: 'children' }`
*/
export const treeToArray = (data: any[], props = { children: 'children' }) => {
data = cloneDeep(data)
const { children } = props
const newData = []
const queue: any[] = []
data.forEach((child: any) => queue.push(child))
while (queue.length) {
const item: any = queue.shift()
if (item[children]) {
item[children].forEach((child: any) => queue.push(child))
delete item[children]
}
newData.push(item)
}
return newData
}
/**
* @description 数组转
* @param {Array} data 数据
* @param {Object} props `{ parent: 'pid', children: 'children' }`
*/
export const arrayToTree = (
data: any[],
props = { id: 'id', parentId: 'pid', children: 'children' }
) => {
data = cloneDeep(data)
const { id, parentId, children } = props
const result: any[] = []
const map = new Map()
data.forEach((item) => {
map.set(item[id], item)
const parent = map.get(item[parentId])
if (parent) {
parent[children] = parent[children] ?? []
parent[children].push(item)
} else {
result.push(item)
}
})
return result
}
/**
* @description 获取正确的路经
* @param {String} path 数据
*/
export function getNormalPath(path: string) {
if (path.length === 0 || !path || path == 'undefined') {
return path
}
const newPath = path.replace('//', '/')
const length = newPath.length
if (newPath[length - 1] === '/') {
return newPath.slice(0, length - 1)
}
return newPath
}
/**
* @description对象格式化为Query语法
* @param { Object } params
* @return {string} Query语法
*/
export function objectToQuery(params: Record<string, any>): string {
let query = ''
for (const props of Object.keys(params)) {
const value = params[props]
const part = encodeURIComponent(props) + '='
if (!isEmpty(value)) {
if (isObject(value)) {
for (const key of Object.keys(value)) {
if (!isEmpty(value[key])) {
const params = props + '[' + key + ']'
const subPart = encodeURIComponent(params) + '='
query += subPart + encodeURIComponent(value[key]) + '&'
}
}
} else {
query += part + encodeURIComponent(value) + '&'
}
}
}
return query.slice(0, -1)
}
/**
* @description 时间格式化
* @param dateTime { number } 时间戳
* @param fmt { string } 时间格式
* @return { string }
*/
// yyyy:mm:dd|yyyy:mm|yyyy年mm月dd日|yyyy年mm月dd日 hh时MM分等,可自定义组合
export const timeFormat = (dateTime: number, fmt = 'yyyy-mm-dd') => {
// 如果为null,则格式化当前时间
if (!dateTime) {
dateTime = Number(new Date())
}
// 如果dateTime长度为10或者13,则为秒和毫秒的时间戳,如果超过13位,则为其他的时间格式
if (dateTime.toString().length == 10) {
dateTime *= 1000
}
const date = new Date(dateTime)
let ret
const opt: any = {
'y+': date.getFullYear().toString(), // 年
'm+': (date.getMonth() + 1).toString(), // 月
'd+': date.getDate().toString(), // 日
'h+': date.getHours().toString(), // 时
'M+': date.getMinutes().toString(), // 分
's+': date.getSeconds().toString() // 秒
}
for (const k in opt) {
ret = new RegExp('(' + k + ')').exec(fmt)
if (ret) {
fmt = fmt.replace(
ret[1],
ret[1].length == 1 ? opt[k] : opt[k].padStart(ret[1].length, '0')
)
}
}
return fmt
}
/**
* @description 获取不重复的id
* @param length { Number } id的长度
* @return { String } id
*/
export const getNonDuplicateID = (length = 8) => {
let idStr = Date.now().toString(36)
idStr += Math.random().toString(36).substring(3, length)
return idStr
}
/**
* @description 单词首字母大写
* @param { String } str
* @return { String } id
*/
export const firstToUpperCase = (str = '') => {
return str.toLowerCase().replace(/( |^)[a-z]/g, (1ドル) => 1ドル.toUpperCase())
}
Loading...
举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

简介

🚀🚀🚀li‌keadmin这套框架专为快速开发业务项目而生,含管理后台、微信小程序、手机 H5、PC 端等,集成常见业务场景,助你高效打造项目产品。Python3、FastAPI、TypeScript、Vue3、vite2、Element Plus1.2(ElementUI)。 后台管理系统、Python管理后台、前后端分离管理后台、Vue.js管理后台、Element UI管理后台。
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
编辑仓库简介
简介内容
主页
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/redoing/likeadmin_python.git
git@gitee.com:redoing/likeadmin_python.git
redoing
likeadmin_python
likeadmin(Python版)- MIT协议-免费任意商用- 管理后台_小程序_手机H5_PC端_uni-app
master
点此查找更多帮助

搜索帮助

评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册

AltStyle によって変換されたページ (->オリジナル) /