mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-23 23:53:55 +08:00
Manager web (#227)
* update:增加前端设计图 * 前端代码优化 * update:底部信息纠正 * 增加:flyio * update:去除org.quartz * update:登陆功能 --------- Co-authored-by: hrz <1710360675@qq.com> Co-authored-by: CGD <3030332422@qq.com>
This commit is contained in:
Executable
+19
@@ -0,0 +1,19 @@
|
||||
const HAVE_NO_RESULT = '暂无'
|
||||
export default {
|
||||
HAVE_NO_RESULT, // 项目的配置信息
|
||||
STORAGE_KEY: {
|
||||
TOKEN: 'TOKEN',
|
||||
PUBLIC_KEY: 'PUBLIC_KEY',
|
||||
USER_TYPE: 'USER_TYPE'
|
||||
},
|
||||
Lang: {
|
||||
'zh_cn': 'zh_cn', 'zh_tw': 'zh_tw', 'en': 'en'
|
||||
},
|
||||
FONT_SIZE: {
|
||||
'big': 'big',
|
||||
'normal': 'normal',
|
||||
}, // 获取map中的某key
|
||||
get(map, key) {
|
||||
return map[key] || HAVE_NO_RESULT
|
||||
}
|
||||
}
|
||||
Executable
+60
@@ -0,0 +1,60 @@
|
||||
export const toDate = (date) => {
|
||||
return isDate(date) ? new Date(date) : null
|
||||
}
|
||||
|
||||
export const isDate = (date) => {
|
||||
if (date === null || date === undefined) return false
|
||||
if (isNaN(new Date(date).getTime())) return false
|
||||
return true
|
||||
}
|
||||
|
||||
export const isDateObject = (val) => {
|
||||
return val instanceof Date
|
||||
}
|
||||
|
||||
export const formatAddDate = (date, format, addDay) => {
|
||||
date = toDate(date)
|
||||
if (!date) {
|
||||
return ''
|
||||
}
|
||||
if (!addDay) {
|
||||
date.setDate(date.getDate() + addDay)
|
||||
}
|
||||
return formatDateTool(date, format || 'yyyy-MM-dd HH:mm:ss')
|
||||
}
|
||||
|
||||
export const formatDate = (date, format) => {
|
||||
date = toDate(date)
|
||||
if (!date) return ''
|
||||
return formatDateTool(date, format || 'yyyy-MM-dd HH:mm:ss')
|
||||
}
|
||||
|
||||
function formatDateTool(date, fmt) {
|
||||
if (/(y+)/.test(fmt)) {
|
||||
fmt = fmt.replace(
|
||||
RegExp.$1,
|
||||
(date.getFullYear() + '').substr(4 - RegExp.$1.length)
|
||||
)
|
||||
}
|
||||
const o = {
|
||||
'M+': date.getMonth() + 1,
|
||||
'd+': date.getDate(),
|
||||
'h+': date.getHours(),
|
||||
'm+': date.getMinutes(),
|
||||
's+': date.getSeconds()
|
||||
}
|
||||
for (const k in o) {
|
||||
if (new RegExp(`(${k})`).test(fmt)) {
|
||||
const str = o[k] + ''
|
||||
fmt = fmt.replace(
|
||||
RegExp.$1,
|
||||
RegExp.$1.length === 1 ? str : padLeftZero(str)
|
||||
)
|
||||
}
|
||||
}
|
||||
return fmt
|
||||
}
|
||||
|
||||
function padLeftZero(str) {
|
||||
return ('00' + str).substr(str.length)
|
||||
}
|
||||
Executable
+135
@@ -0,0 +1,135 @@
|
||||
import router from '../router'
|
||||
import Constant from '../utils/constant'
|
||||
import { Message } from 'element-ui'
|
||||
|
||||
/**
|
||||
* 判断用户是否登录
|
||||
*/
|
||||
export function checkUserLogin(fn) {
|
||||
let token = localStorage.getItem(Constant.STORAGE_KEY.TOKEN)
|
||||
let userType = localStorage.getItem(Constant.STORAGE_KEY.USER_TYPE)
|
||||
if (isNull(token) || isNull(userType)) {
|
||||
goToPage('console', true)
|
||||
return
|
||||
}
|
||||
if (fn) {
|
||||
fn()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否为空
|
||||
* @param data
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export function isNull(data) {
|
||||
if (data === undefined) {
|
||||
return true
|
||||
} else if (data === null) {
|
||||
return true
|
||||
} else if (typeof data === 'string' && (data.length === 0 || data === '' || data === 'undefined' || data === 'null')) {
|
||||
return true
|
||||
} else if ((data instanceof Array) && data.length === 0) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断不为空
|
||||
* @param data
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export function isNotNull(data) {
|
||||
return !isNull(data)
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示顶部红色通知
|
||||
* @param msg
|
||||
*/
|
||||
export function showDanger(msg) {
|
||||
if (isNull(msg)) {
|
||||
return
|
||||
}
|
||||
Message({
|
||||
message: msg,
|
||||
type: 'error'
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示顶部橙色通知
|
||||
* @param msg
|
||||
*/
|
||||
export function showWarning(msg) {
|
||||
if (isNull(msg)) {
|
||||
return
|
||||
}
|
||||
Message({
|
||||
message: msg,
|
||||
type: 'warning'
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 显示顶部绿色通知
|
||||
* @param msg
|
||||
*/
|
||||
export function showSuccess(msg) {
|
||||
Message({
|
||||
message: msg,
|
||||
type: 'success'
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 页面跳转
|
||||
* @param path
|
||||
* @param isRepalce
|
||||
*/
|
||||
export function goToPage(path, isRepalce) {
|
||||
if (isRepalce) {
|
||||
router.replace(path)
|
||||
} else {
|
||||
router.push(path)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前vue页面名称
|
||||
* @param path
|
||||
* @param isRepalce
|
||||
*/
|
||||
export function getCurrentPage() {
|
||||
let hash = location.hash.replace('#', '')
|
||||
if (hash.indexOf('?') > 0) {
|
||||
hash = hash.substring(0, hash.indexOf('?'))
|
||||
}
|
||||
return hash
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成从[min,max]的随机数
|
||||
* @param min
|
||||
* @param max
|
||||
* @returns {number}
|
||||
*/
|
||||
export function randomNum(min, max) {
|
||||
return Math.round(Math.random() * (max - min) + min)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取uuid
|
||||
*/
|
||||
export function getUUID() {
|
||||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
|
||||
return (c === 'x' ? (Math.random() * 16 | 0) : ('r&0x3' | '0x8')).toString(16)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user