提交 5810078b 编写于 作者: V vben

wip: code adjustment and optimization

上级 07c18d60
......@@ -9,14 +9,13 @@
<script lang="ts">
import { defineComponent } from 'vue';
import { ConfigProvider } from 'ant-design-vue';
import { AppProvider } from '/@/components/Application';
import { initAppConfigStore } from '/@/logics/initAppConfig';
import { useLockPage } from '/@/hooks/web/useLockPage';
import { useLocale } from '/@/locales/useLocale';
import { AppProvider } from '/@/components/Application';
export default defineComponent({
name: 'App',
components: { ConfigProvider, AppProvider },
......
此差异已折叠。
<svg id="e4fde902-34f0-42ac-83bb-70aac2088463" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" width="855.41839" height="610.77534" viewBox="0 0 855.41839 610.77534"><circle cx="39.53587" cy="110.72662" r="13.63057" fill="#e6e6e6"/><circle cx="80.42757" cy="110.72662" r="13.63057" fill="#e6e6e6"/><circle cx="121.31927" cy="110.72662" r="13.63057" fill="#e6e6e6"/><circle cx="162.21097" cy="110.72662" r="13.63057" fill="#e6e6e6"/><circle cx="203.10267" cy="110.72662" r="13.63057" fill="#e6e6e6"/><circle cx="243.99437" cy="110.72662" r="13.63057" fill="#e6e6e6"/><circle cx="284.88607" cy="110.72662" r="13.63057" fill="#e6e6e6"/><path d="M488.67447,271.93783H180.32909a5.55346,5.55346,0,0,1-5.54693-5.54693V244.28714a5.55345,5.55345,0,0,1,5.54693-5.54693H488.67447a5.55346,5.55346,0,0,1,5.54693,5.54693V266.3909A5.55347,5.55347,0,0,1,488.67447,271.93783ZM180.32909,240.959a3.3318,3.3318,0,0,0-3.32816,3.32816V266.3909a3.3318,3.3318,0,0,0,3.32816,3.32815H488.67447a3.33179,3.33179,0,0,0,3.32815-3.32815V244.28714a3.33179,3.33179,0,0,0-3.32815-3.32816Z" transform="translate(-172.29081 -144.61233)" fill="#e6e6e6"/><path d="M246.31694,147.79938a3.19065,3.19065,0,0,1,3.187,3.187V220.049a3.19065,3.19065,0,0,1-3.187,3.187h-67.652a3.19065,3.19065,0,0,1-3.187-3.187V150.98643a3.19065,3.19065,0,0,1,3.187-3.187h67.652m0-3.18705h-67.652a6.3741,6.3741,0,0,0-6.3741,6.3741V220.049a6.3741,6.3741,0,0,0,6.3741,6.3741h67.652a6.37411,6.37411,0,0,0,6.3741-6.3741V150.98643a6.37411,6.37411,0,0,0-6.3741-6.3741Z" transform="translate(-172.29081 -144.61233)" fill="#e6e6e6"/><path d="M235.76469,165.95293H190.62778a1.59353,1.59353,0,1,1,0-3.187h45.13691a1.59353,1.59353,0,1,1,0,3.187Z" transform="translate(-172.29081 -144.61233)" fill="#0960bd"/><path d="M235.76469,177.23755H190.62778a1.59353,1.59353,0,1,1,0-3.187h45.13691a1.59353,1.59353,0,1,1,0,3.187Z" transform="translate(-172.29081 -144.61233)" fill="#0960bd"/><path d="M235.76469,188.52139H190.62778a1.59353,1.59353,0,1,1,0-3.187h45.13691a1.59353,1.59353,0,1,1,0,3.187Z" transform="translate(-172.29081 -144.61233)" fill="#0960bd"/><path d="M235.76469,199.806H190.62778a1.59353,1.59353,0,1,1,0-3.187h45.13691a1.59353,1.59353,0,1,1,0,3.187Z" transform="translate(-172.29081 -144.61233)" fill="#0960bd"/><path d="M235.76469,211.09063H190.62778a1.59353,1.59353,0,1,1,0-3.18706h45.13691a1.59353,1.59353,0,0,1,0,3.18706Z" transform="translate(-172.29081 -144.61233)" fill="#0960bd"/><path d="M477.37812,147.79938a3.19065,3.19065,0,0,1,3.187,3.187V220.049a3.19065,3.19065,0,0,1-3.187,3.187h-67.652a3.19065,3.19065,0,0,1-3.187-3.187V150.98643a3.19065,3.19065,0,0,1,3.187-3.187h67.652m0-3.18705h-67.652a6.3741,6.3741,0,0,0-6.3741,6.3741V220.049a6.3741,6.3741,0,0,0,6.3741,6.3741h67.652a6.3741,6.3741,0,0,0,6.3741-6.3741V150.98643a6.3741,6.3741,0,0,0-6.3741-6.3741Z" transform="translate(-172.29081 -144.61233)" fill="#e6e6e6"/><path d="M466.82588,165.95293H421.689a1.59353,1.59353,0,1,1,0-3.187h45.13692a1.59353,1.59353,0,0,1,0,3.187Z" transform="translate(-172.29081 -144.61233)" fill="#0960bd"/><path d="M466.82588,177.23755H421.689a1.59353,1.59353,0,1,1,0-3.187h45.13692a1.59353,1.59353,0,0,1,0,3.187Z" transform="translate(-172.29081 -144.61233)" fill="#0960bd"/><path d="M466.82588,188.52139H421.689a1.59353,1.59353,0,1,1,0-3.187h45.13692a1.59353,1.59353,0,0,1,0,3.187Z" transform="translate(-172.29081 -144.61233)" fill="#0960bd"/><path d="M466.82588,199.806H421.689a1.59353,1.59353,0,1,1,0-3.187h45.13692a1.59353,1.59353,0,0,1,0,3.187Z" transform="translate(-172.29081 -144.61233)" fill="#0960bd"/><path d="M466.82588,211.09063H421.689a1.59353,1.59353,0,1,1,0-3.18706h45.13692a1.59353,1.59353,0,0,1,0,3.18706Z" transform="translate(-172.29081 -144.61233)" fill="#0960bd"/><path d="M707.317,280.59077a3.19065,3.19065,0,0,1,3.187,3.187v69.06255a3.19066,3.19066,0,0,1-3.187,3.187H639.665a3.19066,3.19066,0,0,1-3.187-3.187V283.77782a3.19065,3.19065,0,0,1,3.187-3.187h67.652m0-3.187H639.665a6.3741,6.3741,0,0,0-6.3741,6.3741v69.06255a6.3741,6.3741,0,0,0,6.3741,6.3741h67.652a6.37411,6.37411,0,0,0,6.3741-6.3741V283.77782a6.3741,6.3741,0,0,0-6.3741-6.3741Z" transform="translate(-172.29081 -144.61233)" fill="#0960bd"/><path d="M696.76476,298.74432H651.62784a1.59353,1.59353,0,1,1,0-3.187h45.13692a1.59353,1.59353,0,0,1,0,3.187Z" transform="translate(-172.29081 -144.61233)" fill="#0960bd"/><path d="M696.76476,310.02894H651.62784a1.59353,1.59353,0,0,1,0-3.18706h45.13692a1.59353,1.59353,0,0,1,0,3.18706Z" transform="translate(-172.29081 -144.61233)" fill="#0960bd"/><path d="M696.76476,321.31278H651.62784a1.59352,1.59352,0,1,1,0-3.187h45.13692a1.59353,1.59353,0,0,1,0,3.187Z" transform="translate(-172.29081 -144.61233)" fill="#0960bd"/><path d="M696.76476,332.59739H651.62784a1.59353,1.59353,0,1,1,0-3.187h45.13692a1.59353,1.59353,0,0,1,0,3.187Z" transform="translate(-172.29081 -144.61233)" fill="#0960bd"/><path d="M696.76476,343.882H651.62784a1.59353,1.59353,0,1,1,0-3.187h45.13692a1.59353,1.59353,0,0,1,0,3.187Z" transform="translate(-172.29081 -144.61233)" fill="#0960bd"/><path d="M362.73282,226.42308H293.30943a7.08972,7.08972,0,0,1-7.08139-7.08138V169.66541a7.08988,7.08988,0,0,1,7.08139-7.08216h69.42339a7.09,7.09,0,0,1,7.08217,7.08216V219.3417A7.08988,7.08988,0,0,1,362.73282,226.42308ZM293.30943,165.7703a3.89917,3.89917,0,0,0-3.89434,3.89511V219.3417a3.89851,3.89851,0,0,0,3.89434,3.89433h69.42339a3.89917,3.89917,0,0,0,3.89511-3.89433V169.66541a3.89983,3.89983,0,0,0-3.89511-3.89511Z" transform="translate(-172.29081 -144.61233)" fill="#e6e6e6"/><path d="M350.59,184.81246H305.45305a1.59353,1.59353,0,0,1,0-3.187H350.59a1.59353,1.59353,0,1,1,0,3.187Z" transform="translate(-172.29081 -144.61233)" fill="#0960bd"/><path d="M350.59,196.09708H305.45305a1.59353,1.59353,0,0,1,0-3.187H350.59a1.59353,1.59353,0,1,1,0,3.187Z" transform="translate(-172.29081 -144.61233)" fill="#0960bd"/><path d="M350.59,207.38092H305.45305a1.59353,1.59353,0,0,1,0-3.187H350.59a1.59353,1.59353,0,1,1,0,3.187Z" transform="translate(-172.29081 -144.61233)" fill="#0960bd"/><path d="M593.09111,253.95025,526.41486,234.6141a7.08971,7.08971,0,0,1-4.82882-8.77351l13.83608-47.71054a7.08988,7.08988,0,0,1,8.77372-4.82958l66.67625,19.33615a7.09,7.09,0,0,1,4.82935,8.77447l-13.83608,47.71055A7.08988,7.08988,0,0,1,593.09111,253.95025Zm-49.78294-77.58884a3.89916,3.89916,0,0,0-4.82511,2.65631L524.647,226.72827a3.89851,3.89851,0,0,0,2.65557,4.8249l66.67624,19.33614a3.89918,3.89918,0,0,0,4.82565-2.65535l13.83608-47.71054a3.89985,3.89985,0,0,0-2.65609-4.82587Z" transform="translate(-172.29081 -144.61233)" fill="#e6e6e6"/><path d="M593.01835,210.60411l-43.3508-12.57175a1.59353,1.59353,0,0,1,.88767-3.06094L593.906,207.54318a1.59352,1.59352,0,1,1-.88768,3.06093Z" transform="translate(-172.29081 -144.61233)" fill="#0960bd"/><path d="M589.87531,221.44219,546.5245,208.87043a1.59352,1.59352,0,1,1,.88767-3.06093L590.763,218.38125a1.59353,1.59353,0,0,1-.88767,3.06094Z" transform="translate(-172.29081 -144.61233)" fill="#0960bd"/><path d="M586.73248,232.27951l-43.35081-12.57175a1.59353,1.59353,0,0,1,.88767-3.06094l43.35081,12.57176a1.59352,1.59352,0,0,1-.88767,3.06093Z" transform="translate(-172.29081 -144.61233)" fill="#0960bd"/><rect x="156.10589" y="607.77534" width="699.3125" height="3" fill="#e6e6e6"/><polygon points="562.14 603.085 448.421 603.085 452.276 552.973 558.285 552.973 562.14 603.085" fill="#e6e6e6"/><rect x="442.63878" y="597.3034" width="127.21043" height="11.5646" fill="#e6e6e6"/><path d="M895.37073,374.74021H460.73514a11.56458,11.56458,0,0,0-11.56458,11.56458h0V651.3265H906.93533V386.30479a11.56457,11.56457,0,0,0-11.56456-11.56458Z" transform="translate(-172.29081 -144.61233)" fill="#3f3d56"/><path d="M449.17056,651.3265v43.36719a11.56457,11.56457,0,0,0,11.56458,11.56457H895.37073a11.56459,11.56459,0,0,0,11.5646-11.56457h0V651.3265Z" transform="translate(-172.29081 -144.61233)" fill="#e6e6e6"/><rect x="300.00891" y="254.22076" width="412.47016" height="231.29169" fill="#e6e6e6"/><circle cx="506.244" cy="533.69821" r="11.56459" fill="#3f3d56"/><circle cx="312.86987" cy="261.79534" r="2.19466" fill="#fff"/><circle cx="321.20026" cy="261.79534" r="2.19466" fill="#fff"/><circle cx="329.53064" cy="261.79534" r="2.19466" fill="#fff"/><rect x="310.6752" y="269.25275" width="389.91608" height="194.24707" fill="#fff"/><path d="M508.885,443.41111a1.37973,1.37973,0,0,0-1.37842,1.37842v69.67578a1.37973,1.37973,0,0,0,1.37842,1.37841H589.3493a1.37973,1.37973,0,0,0,1.37842-1.37841V444.78953a1.37973,1.37973,0,0,0-1.37842-1.37842Z" transform="translate(-172.29081 -144.61233)" fill="#e6e6e6"/><path d="M638.08075,443.63523a1.37984,1.37984,0,0,0-1.37891,1.37842v69.45166a1.37984,1.37984,0,0,0,1.37891,1.37841h80.208a1.37963,1.37963,0,0,0,1.37793-1.37841V445.01365a1.37963,1.37963,0,0,0-1.37793-1.37842Z" transform="translate(-172.29081 -144.61233)" fill="#e6e6e6"/><path d="M765.92157,442.9072a1.37963,1.37963,0,0,0-1.37793,1.37842v70.17969a1.37962,1.37962,0,0,0,1.37793,1.37841h81.042a1.37962,1.37962,0,0,0,1.37793-1.37841V444.28562a1.37963,1.37963,0,0,0-1.37793-1.37842Z" transform="translate(-172.29081 -144.61233)" fill="#e6e6e6"/><path d="M510.35614,550.333a2.84986,2.84986,0,0,0,0,5.69971h75.65234a2.84986,2.84986,0,0,0,0-5.69971Z" transform="translate(-172.29081 -144.61233)" fill="#e6e6e6"/><path d="M510.35614,563.88865a2.8501,2.8501,0,0,0,0,5.70019h34.062a2.8501,2.8501,0,0,0,0-5.70019Z" transform="translate(-172.29081 -144.61233)" fill="#0960bd"/><path d="M640.94012,550.333a2.84986,2.84986,0,0,0,0,5.69971h75.65235a2.84986,2.84986,0,0,0,0-5.69971Z" transform="translate(-172.29081 -144.61233)" fill="#e6e6e6"/><path d="M640.94012,563.88865a2.8501,2.8501,0,0,0,0,5.70019h34.0625a2.8501,2.8501,0,0,0,0-5.70019Z" transform="translate(-172.29081 -144.61233)" fill="#0960bd"/><path d="M768.26044,550.333a2.84986,2.84986,0,0,0,0,5.69971h75.65234a2.84986,2.84986,0,0,0,0-5.69971Z" transform="translate(-172.29081 -144.61233)" fill="#e6e6e6"/><path d="M510.35614,536.333a2.84986,2.84986,0,0,0,0,5.69971h75.65234a2.84986,2.84986,0,0,0,0-5.69971Z" transform="translate(-172.29081 -144.61233)" fill="#e6e6e6"/><path d="M640.94012,536.333a2.84986,2.84986,0,0,0,0,5.69971h75.65235a2.84986,2.84986,0,0,0,0-5.69971Z" transform="translate(-172.29081 -144.61233)" fill="#e6e6e6"/><path d="M768.26044,536.333a2.84986,2.84986,0,0,0,0,5.69971h75.65234a2.84986,2.84986,0,0,0,0-5.69971Z" transform="translate(-172.29081 -144.61233)" fill="#e6e6e6"/><path d="M768.26044,563.88865a2.8501,2.8501,0,0,0,0,5.70019H802.322a2.8501,2.8501,0,0,0,0-5.70019Z" transform="translate(-172.29081 -144.61233)" fill="#0960bd"/></svg>
\ No newline at end of file
......@@ -7,7 +7,6 @@
import { defineComponent, reactive, computed, watch, onMounted, unref, toRef } from 'vue';
import { countToProps } from './props';
import { isNumber } from '/@/utils/is';
import { requestAnimationFrame, cancelAnimationFrame } from '/@/utils/animation';
export default defineComponent({
name: 'CountTo',
props: countToProps,
......
import { isFunction, isUnDef } from '/@/utils/is';
import { ref, unref } from 'vue';
import { requestAnimationFrame } from '/@/utils/animation';
export interface ScrollToParams {
el: HTMLElement;
......
import type { AppRouteRecordRaw } from '/@/router/types';
import ParentLayout from '/@/layouts/page/ParentView.vue';
const EXCEPTION_COMPONENT = () => import('../views/sys/exception/Exception');
const EXCEPTION_COMPONENT = () => import('../views/sys/exception/Exception.vue');
/**
* @description: default layout
......
......@@ -2,7 +2,7 @@ import type { Router } from 'vue-router';
import { useGlobSetting } from '/@/hooks/setting';
import { setTitle } from '/@/utils/browser';
import { setTitle } from '/@/utils';
import { useI18n } from '/@/hooks/web/useI18n';
import { REDIRECT_NAME } from '/@/router/constant';
......
......@@ -4,7 +4,7 @@ import { getParentLayout, LAYOUT } from '/@/router/constant';
import { ExceptionEnum } from '/@/enums/exceptionEnum';
import { t } from '/@/hooks/web/useI18n';
const ExceptionPage = () => import('/@/views/sys/exception/Exception');
const ExceptionPage = () => import('/@/views/sys/exception/Exception.vue');
const page: AppRouteModule = {
path: '/page-demo',
......
import { isServer } from '/@/utils/is';
let lastTime = 0;
const prefixes = 'webkit moz ms o'.split(' ');
let requestAnimationFrame: typeof window.requestAnimationFrame;
let cancelAnimationFrame: typeof window.cancelAnimationFrame;
(() => {
const NO_LOOP: any = () => {};
const getWindowFrame = (name: string) => {
return name as any;
};
if (isServer) {
requestAnimationFrame = cancelAnimationFrame = NO_LOOP;
} else {
requestAnimationFrame = window.requestAnimationFrame;
cancelAnimationFrame = window.cancelAnimationFrame;
let prefix;
for (let i = 0; i < prefixes.length; i++) {
if (requestAnimationFrame && cancelAnimationFrame) {
break;
}
prefix = prefixes[i];
requestAnimationFrame =
requestAnimationFrame || window[getWindowFrame(prefix + 'RequestAnimationFrame')];
cancelAnimationFrame =
cancelAnimationFrame ||
window[getWindowFrame(prefix + 'CancelAnimationFrame')] ||
window[getWindowFrame(prefix + 'CancelRequestAnimationFrame')];
}
// If the current browser does not support requestAnimationFrame and cancelAnimationFrame, it will fall back to setTimeout
if (!requestAnimationFrame || !cancelAnimationFrame) {
requestAnimationFrame = function (callback: Fn) {
const currTime = new Date().getTime();
const timeToCall = Math.max(0, 16 - (currTime - lastTime));
const id = window.setTimeout(() => {
/* eslint-disable-next-line */
callback(currTime + timeToCall);
}, timeToCall);
lastTime = currTime + timeToCall;
return id;
};
cancelAnimationFrame = function (id: number) {
window.clearTimeout(id);
};
}
}
})();
export { requestAnimationFrame, cancelAnimationFrame };
function getTypeVersion() {
const userAgent = navigator.userAgent.toLowerCase();
const browserTypes = {
IE: /(?:msie|trident.*rv).([\d.]+)/,
Edge: /edge.([\d.]+)/,
Chrome: /chrome.([\d.]+)/,
Firefox: /firefox.([\d.]+)/,
Opera: /opera.([\d.]+)/,
Safari: /(?:safari|version).([\d.]+)/,
};
type BrowserKeys = keyof typeof browserTypes;
/** browser type */
let type!: BrowserKeys | null;
/** browser version */
let version!: string | null;
for (type in browserTypes) {
if ((version = browserTypes[type as BrowserKeys].exec(userAgent) as any)) {
version = version[1];
break;
}
}
if (version) {
if (type === 'IE') {
try {
document.execCommand('BackgroundImageCache', false, true as any);
} catch (error) {
console.log(error);
}
}
} else {
type = version = null;
}
return { type, version };
}
const { type, version } = getTypeVersion();
export function getType() {
return type;
}
export function getVersion() {
return version;
}
export function isIeFn() {
return type === 'IE';
}
export function isChromeFn() {
return type === 'Chrome';
}
export function isEdgeFn() {
return type === 'Edge';
}
export function isSafariFn() {
return type === 'Safari';
}
export function isFirefoxFn() {
return type === 'Firefox';
}
export function isOperaFn() {
return type === 'Opera';
}
/**
* set page Title
* @param {*} title :page Title
*/
function setDocumentTitle(title: string) {
document.title = title;
const ua = navigator.userAgent;
const regex = /\bMicroMessenger\/([\d.]+)/;
// 兼容
if (regex.test(ua) && /ip(hone|od|ad)/i.test(ua)) {
const i = document.createElement('iframe');
i.src = '/favicon.ico';
i.style.display = 'none';
i.onload = function () {
setTimeout(function () {
i.remove();
}, 9);
};
document.body.appendChild(i);
}
}
export function setTitle(title: string, appTitle?: string) {
if (title) {
const _title = title ? ` ${title}-${appTitle} ` : `${appTitle}`;
setDocumentTitle(_title);
}
}
......@@ -6,7 +6,7 @@
* @return Boolean
*/
export function isHexColor(color: string) {
const reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/;
const reg = /^#([0-9a-fA-F]{3}|[0-9a-fA-f]{6})$/;
return reg.test(color);
}
......@@ -40,7 +40,7 @@ export function hexToRGB(hex: string) {
}
sHex = sColorNew;
}
const sColorChange = [];
const sColorChange: number[] = [];
for (let i = 1; i < 7; i += 2) {
sColorChange.push(parseInt('0x' + sHex.slice(i, i + 2)));
}
......
......@@ -14,27 +14,4 @@ export function formatToDate(date: moment.MomentInput = null, format = DATE_FORM
return moment(date).format(format);
}
export function formatAgo(str: string | number) {
if (!str) return '';
const date = new Date(Number(str));
const time = new Date().getTime() - date.getTime(); // 现在的时间-传入的时间 = 相差的时间(单位 = 毫秒)
if (time < 0) {
return '';
} else if (time / 1000 < 30) {
return '刚刚';
} else if (time / 1000 < 60) {
return parseInt(String(time / 1000)) + '秒前';
} else if (time / 60000 < 60) {
return parseInt(String(time / 60000)) + '分钟前';
} else if (time / 3600000 < 24) {
return parseInt(String(time / 3600000)) + '小时前';
} else if (time / 86400000 < 31) {
return parseInt(String(time / 86400000)) + '天前';
} else if (time / 2592000000 < 12) {
return parseInt(String(time / 2592000000)) + '月前';
} else {
return parseInt(String(time / 31536000000)) + '年前';
}
}
export const dateUtil = moment;
import { createStorage } from '/@/utils/cache';
import { isIeFn } from '/@/utils/browser';
import { BASE_LOCAL_CACHE_KEY, BASE_SESSION_CACHE_KEY } from '/@/enums/cacheEnum';
......@@ -127,9 +126,5 @@ export function persistentCache() {
}
}
if (isIeFn() && (document as any).attachEvent) {
(document as any).attachEvent('onstorage', storageChange);
} else {
window.addEventListener('storage', storageChange);
}
window.addEventListener('storage', storageChange);
})();
......@@ -81,7 +81,9 @@ export class VAxios {
// 请求拦截器配置处理
this.axiosInstance.interceptors.request.use((config: AxiosRequestConfig) => {
// If cancel repeat request is turned on, then cancel repeat request is prohibited
const { headers: { ignoreCancelToken } = { ignoreCancelToken: false } } = config;
const {
headers: { ignoreCancelToken = false },
} = config;
!ignoreCancelToken && axiosCanceler.addPending(config);
if (requestInterceptors && isFunction(requestInterceptors)) {
config = requestInterceptors(config);
......
......@@ -99,3 +99,32 @@ export function getLastItem<T extends any>(list: T) {
return Array.from(list.values()).slice(-1)[0];
}
}
/**
* set page Title
* @param {*} title :page Title
*/
function setDocumentTitle(title: string) {
document.title = title;
const ua = navigator.userAgent;
const regex = /\bMicroMessenger\/([\d.]+)/;
// 兼容
if (regex.test(ua) && /ip(hone|od|ad)/i.test(ua)) {
const i = document.createElement('iframe');
i.src = '/favicon.ico';
i.style.display = 'none';
i.onload = function () {
setTimeout(function () {
i.remove();
}, 9);
};
document.body.appendChild(i);
}
}
export function setTitle(title: string, appTitle?: string) {
if (title) {
const _title = title ? ` ${title}-${appTitle} ` : `${appTitle}`;
setDocumentTitle(_title);
}
}
......@@ -86,21 +86,7 @@ export function isElement(val: unknown): val is Element {
export const isServer = typeof window === 'undefined';
export const isClient = typeof window !== 'undefined';
export function isImageDom(o: Element) {
return o && ['IMAGE', 'IMG'].includes(o.tagName);
}
export function isTextarea(element: Element | null): element is HTMLTextAreaElement {
return element !== null && element.tagName.toLowerCase() === 'textarea';
}
export function isMobile(): boolean {
return !!navigator.userAgent.match(
/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i
);
}
export const isClient = !isServer;
export function isUrl(path: string): boolean {
const reg = /(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/;
......
......@@ -4,13 +4,16 @@
</BasicModal>
</template>
<script lang="ts">
import { defineComponent, PropType } from 'vue';
import type { PropType } from 'vue';
import { defineComponent } from 'vue';
import { BasicModal } from '/@/components/Modal/index';
import { ErrorInfo } from '/@/store/modules/error';
import { Description, useDescription } from '/@/components/Description/index';
import { useI18n } from '/@/hooks/web/useI18n';
import { ErrorInfo } from '/@/store/modules/error';
import { getDescSchema } from './data';
export default defineComponent({
......@@ -24,10 +27,12 @@
},
setup() {
const { t } = useI18n();
const [register] = useDescription({
column: 2,
schema: getDescSchema(),
});
return {
register,
useI18n,
......
......@@ -53,7 +53,6 @@ export function getColumns(): BasicColumn[] {
{
dataIndex: 'stack',
title: t('sys.errorLog.tableColumnStackMsg'),
width: 300,
},
];
}
......
<template>
<div class="p-4">
<template v-for="src in imgListRef" :key="src">
<template v-for="src in imgList" :key="src">
<img :src="src" v-show="false" />
</template>
<DetailModal :info="rowInfoRef" @register="registerModal" />
<DetailModal :info="rowInfo" @register="registerModal" />
<BasicTable @register="register" class="error-handle-table">
<template #toolbar>
<a-button @click="fireVueError" type="primary">
......@@ -50,8 +50,8 @@
name: 'ErrorHandler',
components: { DetailModal, BasicTable, TableAction },
setup() {
const rowInfoRef = ref<ErrorInfo>();
const imgListRef = ref<string[]>([]);
const rowInfo = ref<ErrorInfo>();
const imgList = ref<string[]>([]);
const { t } = useI18n();
......@@ -84,7 +84,7 @@
}
// 查看详情
function handleDetail(row: ErrorInfo) {
rowInfoRef.value = row;
rowInfo.value = row;
openModal(true);
}
......@@ -93,7 +93,7 @@
}
function fireResourceError() {
imgListRef.value.push(`${new Date().getTime()}.png`);
imgList.value.push(`${new Date().getTime()}.png`);
}
async function fireAjaxError() {
......@@ -107,8 +107,8 @@
fireVueError,
fireResourceError,
fireAjaxError,
imgListRef,
rowInfoRef,
imgList,
rowInfo,
t,
};
},
......
import './exception.less';
import type { PropType } from 'vue';
import { Result, Button } from 'ant-design-vue';
import { defineComponent, ref, computed, unref } from 'vue';
import { ExceptionEnum } from '/@/enums/exceptionEnum';
import netWorkImg from '/@/assets/images/exception/net-work.png';
import notDataImg from '/@/assets/images/no-data.png';
import { useRoute } from 'vue-router';
import { useGo, useRedo } from '/@/hooks/web/usePage';
import { PageEnum } from '/@/enums/pageEnum';
import { useI18n } from '/@/hooks/web/useI18n';
interface MapValue {
title: string;
subTitle: string;
btnText?: string;
icon?: string;
handler?: Fn;
status?: string;
}
export default defineComponent({
name: 'ErrorPage',
props: {
// 状态码
status: {
type: Number as PropType<number>,
default: ExceptionEnum.PAGE_NOT_FOUND,
},
title: {
type: String as PropType<string>,
default: '',
},
subTitle: {
type: String as PropType<string>,
default: '',
},
full: {
type: Boolean as PropType<boolean>,
default: false,
},
},
setup(props) {
const statusMapRef = ref(new Map<string | number, MapValue>());
const { query } = useRoute();
const go = useGo();
const redo = useRedo();
const { t } = useI18n();
const getStatus = computed(() => {
const { status: routeStatus } = query;
const { status } = props;
return Number(routeStatus) || status;
});
const getMapValue = computed(
(): MapValue => {
return unref(statusMapRef).get(unref(getStatus)) as MapValue;
}
);
const backLoginI18n = t('sys.exception.backLogin');
const backHomeI18n = t('sys.exception.backHome');
unref(statusMapRef).set(ExceptionEnum.PAGE_NOT_ACCESS, {
title: '403',
status: `${ExceptionEnum.PAGE_NOT_ACCESS}`,
subTitle: t('sys.exception.subTitle403'),
btnText: props.full ? backLoginI18n : backHomeI18n,
handler: () => (props.full ? go(PageEnum.BASE_LOGIN) : go()),
});
unref(statusMapRef).set(ExceptionEnum.PAGE_NOT_FOUND, {
title: '404',
status: `${ExceptionEnum.PAGE_NOT_FOUND}`,
subTitle: t('sys.exception.subTitle404'),
btnText: props.full ? backLoginI18n : backHomeI18n,
handler: () => (props.full ? go(PageEnum.BASE_LOGIN) : go()),
});
unref(statusMapRef).set(ExceptionEnum.ERROR, {
title: '500',
status: `${ExceptionEnum.ERROR}`,
subTitle: t('sys.exception.subTitle500'),
btnText: backHomeI18n,
handler: () => go(),
});
unref(statusMapRef).set(ExceptionEnum.PAGE_NOT_DATA, {
title: t('sys.exception.noDataTitle'),
subTitle: '',
btnText: t('common.redo'),
handler: () => redo(),
icon: notDataImg,
});
unref(statusMapRef).set(ExceptionEnum.NET_WORK_ERROR, {
title: t('sys.exception.networkErrorTitle'),
subTitle: t('sys.exception.networkErrorSubTitle'),
btnText: 'Refresh',
handler: () => redo(),
icon: netWorkImg,
});
return () => {
const { title, subTitle, btnText, icon, handler, status } = unref(getMapValue) || {};
return (
<Result
class="exception "
status={status as any}
title={props.title || title}
sub-title={props.subTitle || subTitle}
>
{{
extra: () =>
btnText && (
<Button type="primary" onClick={handler}>
{() => btnText}
</Button>
),
icon: () => (icon ? <img src={icon} /> : null),
}}
</Result>
);
};
},
});
<script lang="tsx">
import type { PropType } from 'vue';
import { Result, Button } from 'ant-design-vue';
import { defineComponent, ref, computed, unref } from 'vue';
import { ExceptionEnum } from '/@/enums/exceptionEnum';
import notDataSvg from '/@/assets/svg/no-data.svg';
import netWorkSvg from '/@/assets/svg/net-error.svg';
import { useRoute } from 'vue-router';
import { useDesign } from '/@/hooks/web/useDesign';
import { useI18n } from '/@/hooks/web/useI18n';
import { useGo, useRedo } from '/@/hooks/web/usePage';
import { PageEnum } from '/@/enums/pageEnum';
interface MapValue {
title: string;
subTitle: string;
btnText?: string;
icon?: string;
handler?: Fn;
status?: string;
}
export default defineComponent({
name: 'ErrorPage',
props: {
// 状态码
status: {
type: Number as PropType<number>,
default: ExceptionEnum.PAGE_NOT_FOUND,
},
title: {
type: String as PropType<string>,
default: '',
},
subTitle: {
type: String as PropType<string>,
default: '',
},
full: {
type: Boolean as PropType<boolean>,
default: false,
},
},
setup(props) {
const statusMapRef = ref(new Map<string | number, MapValue>());
const { query } = useRoute();
const go = useGo();
const redo = useRedo();
const { t } = useI18n();
const { prefixCls } = useDesign('app-exception-page');
const getStatus = computed(() => {
const { status: routeStatus } = query;
const { status } = props;
return Number(routeStatus) || status;
});
const getMapValue = computed(
(): MapValue => {
return unref(statusMapRef).get(unref(getStatus)) as MapValue;
}
);
const backLoginI18n = t('sys.exception.backLogin');
const backHomeI18n = t('sys.exception.backHome');
unref(statusMapRef).set(ExceptionEnum.PAGE_NOT_ACCESS, {
title: '403',
status: `${ExceptionEnum.PAGE_NOT_ACCESS}`,
subTitle: t('sys.exception.subTitle403'),
btnText: props.full ? backLoginI18n : backHomeI18n,
handler: () => (props.full ? go(PageEnum.BASE_LOGIN) : go()),
});
unref(statusMapRef).set(ExceptionEnum.PAGE_NOT_FOUND, {
title: '404',
status: `${ExceptionEnum.PAGE_NOT_FOUND}`,
subTitle: t('sys.exception.subTitle404'),
btnText: props.full ? backLoginI18n : backHomeI18n,
handler: () => (props.full ? go(PageEnum.BASE_LOGIN) : go()),
});
unref(statusMapRef).set(ExceptionEnum.ERROR, {
title: '500',
status: `${ExceptionEnum.ERROR}`,
subTitle: t('sys.exception.subTitle500'),
btnText: backHomeI18n,
handler: () => go(),
});
unref(statusMapRef).set(ExceptionEnum.PAGE_NOT_DATA, {
title: t('sys.exception.noDataTitle'),
subTitle: '',
btnText: t('common.redo'),
handler: () => redo(),
icon: notDataSvg,
});
unref(statusMapRef).set(ExceptionEnum.NET_WORK_ERROR, {
title: t('sys.exception.networkErrorTitle'),
subTitle: t('sys.exception.networkErrorSubTitle'),
btnText: t('common.redo'),
handler: () => redo(),
icon: netWorkSvg,
});
return () => {
const { title, subTitle, btnText, icon, handler, status } = unref(getMapValue) || {};
return (
<Result
class={prefixCls}
status={status as any}
title={props.title || title}
sub-title={props.subTitle || subTitle}
>
{{
extra: () =>
btnText && (
<Button type="primary" onClick={handler}>
{() => btnText}
</Button>
),
icon: () => (icon ? <img src={icon} /> : null),
}}
</Result>
);
};
},
});
</script>
<style lang="less">
@prefix-cls: ~'@{namespace}-app-exception-page';
.@{prefix-cls} {
display: flex;
align-items: center;
flex-direction: column;
.ant-result-icon {
img {
max-width: 400px;
max-height: 300px;
}
}
}
</style>
.exception {
display: flex;
align-items: center;
flex-direction: column;
}
export { default as Exception } from './Exception';
export { default as Exception } from './Exception.vue';
<template>
<div class="iframe-page" :style="getWrapStyle">
<div :class="prefixCls" :style="getWrapStyle">
<Spin :spinning="loading" size="large" :style="getWrapStyle">
<iframe :src="frameSrc" class="iframe-page__main" ref="frameRef"></iframe>
<iframe :src="frameSrc" :class="`${prefixCls}__main`" ref="frameRef"></iframe>
</Spin>
</div>
</template>
<script lang="ts">
import { defineComponent, PropType, ref, unref, onMounted, nextTick, computed } from 'vue';
import type { CSSProperties } from 'vue';
import { defineComponent, ref, unref, onMounted, nextTick, computed } from 'vue';
import { Spin } from 'ant-design-vue';
import { getViewportOffset } from '/@/utils/domUtils';
import { useWindowSizeFn } from '/@/hooks/event/useWindowSizeFn';
import { propTypes } from '/@/utils/propTypes';
import { useDesign } from '/@/hooks/web/useDesign';
export default defineComponent({
name: 'IFrame',
components: { Spin },
props: {
frameSrc: {
type: String as PropType<string>,
default: '',
},
frameSrc: propTypes.string.def(''),
},
setup() {
const loadingRef = ref(false);
const loading = ref(false);
const topRef = ref(50);
const heightRef = ref(window.innerHeight);
const frameRef = ref<HTMLElement | null>(null);
const frameRef = ref<HTMLFrameElement | null>(null);
const { prefixCls } = useDesign('iframe-page');
useWindowSizeFn(calcHeight, 150, { immediate: true });
const getWrapStyle = computed(
(): CSSProperties => {
return {
height: `${unref(heightRef)}px`,
};
}
);
function calcHeight() {
const iframe = unref(frameRef);
......@@ -40,21 +53,19 @@
iframe.style.height = `${clientHeight}px`;
}
useWindowSizeFn(calcHeight, 150, { immediate: true });
function hideLoading() {
loadingRef.value = false;
loading.value = false;
calcHeight();
}
function init() {
nextTick(() => {
const iframe = unref(frameRef);
if (!iframe) {
return;
}
if ((iframe as any).attachEvent) {
(iframe as any).attachEvent('onload', () => {
if (!iframe) return;
const _frame = iframe as any;
if (_frame.attachEvent) {
_frame.attachEvent('onload', () => {
hideLoading();
});
} else {
......@@ -65,23 +76,23 @@
});
}
onMounted(() => {
loadingRef.value = true;
loading.value = true;
init();
});
return {
getWrapStyle: computed(() => {
return {
height: `${unref(heightRef)}px`,
};
}),
loading: loadingRef,
getWrapStyle,
loading,
frameRef,
prefixCls,
};
},
});
</script>
<style lang="less" scoped>
.iframe-page {
@prefix-cls: ~'@{namespace}-iframe-page';
.@{prefix-cls} {
.ant-spin-nested-loading {
position: relative;
height: 100%;
......
......@@ -203,15 +203,12 @@
display: flex;
width: 40%;
height: 74%;
// font-size: 50em;
font-weight: 700;
color: #bababa;
background: #141313;
border-radius: 30px;
justify-content: center;
align-items: center;
// .respond-to(large-only, { font-size: 25em;});
// .respond-to(large-only, { font-size: 30em;});
@media (min-width: @screen-xxxl-min) {
font-size: 46em;
}
......
......@@ -12,7 +12,9 @@
const { params, query } = unref(currentRoute);
const { path } = params;
const _path = Array.isArray(path) ? path.join('/') : path;
replace({
path: '/' + _path,
query,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册