This commit is contained in:
zk
2023-12-18 18:34:19 +08:00
parent 2cc8886c2d
commit 580a4fc5c6
50 changed files with 2343 additions and 223 deletions
+33
View File
@@ -0,0 +1,33 @@
import { onMounted, onUnmounted, ref } from 'vue';
export function useRefresh(time = 3000, callback) {
const refreshState = ref(false);
const timer = ref(null);
function setRefreshState() {
timer.value = setInterval(() => {
refreshState.value = !refreshState.value;
callback();
}, time);
}
function stopRefresh() {
clearInterval(timer.value);
timer.value = null;
}
onMounted(() => {
if (timer.value != null) {
timer.value = null;
}
setRefreshState();
});
onUnmounted(() => {
stopRefresh();
});
return {
refreshState,
stopRefresh,
};
}
+3
View File
@@ -0,0 +1,3 @@
export default {
//预警
};
+148
View File
@@ -0,0 +1,148 @@
let types = {
api: {
operationFailed: '操作失败',
errorTip: '错误提示',
errorMessage: '操作失败,系统异常!',
timeoutMessage: '登录超时,请重新登录!',
apiTimeoutMessage: '接口请求超时,请刷新页面重试!',
apiRequestFailed: '请求出错,请稍候重试',
networkException: '网络异常',
networkExceptionMsg: '网络异常,请检查您的网络连接是否正常!',
errMsg401: '用户没有权限(令牌、用户名、密码错误)!',
errMsg403: '用户得到授权,但是访问是被禁止的。!',
errMsg404: '网络请求错误,未找到该资源!',
errMsg405: '网络请求错误,请求方法未允许!',
errMsg408: '网络请求超时!',
errMsg500: '服务器错误,请联系管理员!',
errMsg501: '网络未实现!',
errMsg502: '网络错误!',
errMsg503: '服务不可用,服务器暂时过载或维护!',
errMsg504: '网络超时!',
errMsg505: 'http版本不支持该请求!',
registerMsg: '注册成功',
},
app: { logoutTip: '温馨提醒', logoutMessage: '是否确认退出系统?', menuLoading: '菜单加载中...' },
errorLog: {
tableTitle: '错误日志列表',
tableColumnType: '类型',
tableColumnDate: '时间',
tableColumnFile: '文件',
tableColumnMsg: '错误信息',
tableColumnStackMsg: 'stack信息',
tableActionDesc: '详情',
modalTitle: '错误详情',
fireVueError: '点击触发vue错误',
fireResourceError: '点击触发资源加载错误',
fireAjaxError: '点击触发ajax错误',
enableMessage: '只在`/src/settings/projectSetting.ts` 内的useErrorHandle=true时生效.',
},
exception: {
backLogin: '返回登录',
backHome: '返回首页',
subTitle403: '抱歉,您无权访问此页面。',
subTitle404: '抱歉,您访问的页面不存在。',
subTitle500: '抱歉,服务器报告错误。',
noDataTitle: '当前页无数据',
networkErrorTitle: '网络错误',
networkErrorSubTitle: '抱歉,您的网络连接已断开,请检查您的网络!',
},
lock: {
unlock: '点击解锁',
alert: '锁屏密码错误',
backToLogin: '返回登录',
entry: '进入系统',
placeholder: '请输入锁屏密码或者用户密码',
},
login: {
backSignIn: '返回',
signInFormTitle: '登录',
mobileSignInFormTitle: '手机登录',
qrSignInFormTitle: '二维码登录',
signUpFormTitle: '注册',
forgetFormTitle: '重置密码',
signInTitle: 'Jeecg Boot',
signInDesc: '是中国最具影响力的 企业级低代码平台!在线开发,可视化拖拽设计,零代码实现80%的基础功能~',
policy: '我同意敲敲云隐私政策',
scanSign: `扫码后,即可完成登录`,
scanSuccess: `扫码成功,登录中`,
loginButton: '登录',
registerButton: '注册',
rememberMe: '记住我',
forgetPassword: '忘记密码?',
otherSignIn: '其他登录方式',
// notify
loginSuccessTitle: '登录成功',
loginSuccessDesc: '欢迎回来',
// placeholder
accountPlaceholder: '请输入账号',
passwordPlaceholder: '请输入密码',
inputCodePlaceholder: '请输入验证码',
smsPlaceholder: '请输入验证码',
mobilePlaceholder: '请输入手机号码',
policyPlaceholder: '勾选后才能注册',
diffPwd: '两次输入密码不一致',
loginTitle: '健康服务业务平台',
formTitle: '欢迎登录',
userName: '账号',
password: '密码',
inputCode: '验证码',
confirmPassword: '确认密码',
email: '邮箱',
smsCode: '短信验证码',
mobile: '手机号码',
subTitleText: '{0}秒后返回登录页面',
//重置密码页面中文
authentication: '验证身份',
resetLoginPassword: '重置登录密码',
resetSuccess: '重置成功',
nextStep: '下一步',
goToLogin: '去登录',
},
common: {
okText: '确认',
closeText: '关闭',
cancelText: '取消',
loadingText: '加载中...',
saveText: '保存',
delText: '删除',
resetText: '重置',
searchText: '搜索',
queryText: '查询',
inputText: '请输入',
chooseText: '请选择',
redo: '刷新',
back: '返回',
light: '亮色主题',
dark: '黑暗主题',
},
};
export function t(key) {
if (!key) return '';
if (key.includes('.')) {
let value = types;
let keys = key.split('.');
let obj = {};
for (let i = 0; i < keys.length; i++) {
// debugger;
value = value[keys[i]];
}
return value;
}
}
+149
View File
@@ -0,0 +1,149 @@
import type { ModalFunc, ModalFuncProps } from 'ant-design-vue/lib/modal/Modal';
import { Modal, message as Message, notification } from 'ant-design-vue';
import { InfoCircleFilled, CheckCircleFilled, CloseCircleFilled } from '@ant-design/icons-vue';
import { NotificationArgsProps, ConfigProps } from 'ant-design-vue/lib/notification';
import { isString } from '/@/utils/is';
import { h } from 'vue';
import { t } from '/@/hooks/locales/useLocales.ts';
export interface NotifyApi {
info(config: NotificationArgsProps): void;
success(config: NotificationArgsProps): void;
error(config: NotificationArgsProps): void;
warn(config: NotificationArgsProps): void;
warning(config: NotificationArgsProps): void;
open(args: NotificationArgsProps): void;
close(key: String): void;
config(options: ConfigProps): void;
destroy(): void;
}
export declare type NotificationPlacement = 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight';
export declare type IconType = 'success' | 'info' | 'error' | 'warning';
export interface ModalOptionsEx extends Omit<ModalFuncProps, 'iconType'> {
iconType: 'warning' | 'success' | 'error' | 'info';
}
export type ModalOptionsPartial = Partial<ModalOptionsEx> & Pick<ModalOptionsEx, 'content'>;
interface ConfirmOptions {
info: ModalFunc;
success: ModalFunc;
error: ModalFunc;
warn: ModalFunc;
warning: ModalFunc;
}
function getIcon(iconType: string) {
try {
if (iconType === 'warning') {
return h(InfoCircleFilled, { class: 'modal-icon-warning' });
} else if (iconType === 'success') {
return h(CheckCircleFilled, { class: 'modal-icon-success' });
} else if (iconType === 'info') {
return h(InfoCircleFilled, { class: 'modal-icon-info' });
} else {
return h(CloseCircleFilled, { class: 'modal-icon-error' });
}
} catch (e) {
console.log(e);
}
}
function renderContent({ content }: Pick<ModalOptionsEx, 'content'>) {
try {
if (isString(content)) {
return h('div', h('div', { innerHTML: content as string }));
} else {
return content;
}
} catch (e) {
console.log(e);
return content;
}
}
/**
* @description: Create confirmation box
*/
function createConfirm(options: ModalOptionsEx): ReturnType<ModalFunc> {
const iconType = options.iconType || 'warning';
Reflect.deleteProperty(options, 'iconType');
const opt: ModalFuncProps = {
centered: true,
icon: getIcon(iconType),
...options,
content: renderContent(options),
};
return Modal.confirm(opt);
}
const getBaseOptions = () => {
// const { t } = useI18n();
return {
okText: t('common.okText'),
centered: true,
};
};
function createModalOptions(options: ModalOptionsPartial, icon: string): ModalOptionsPartial {
//update-begin-author:taoyan date:2023-1-10 for: 可以自定义图标
let titleIcon: any = '';
if (options.icon) {
titleIcon = options.icon;
} else {
titleIcon = getIcon(icon);
}
//update-end-author:taoyan date:2023-1-10 for: 可以自定义图标
return {
...getBaseOptions(),
...options,
content: renderContent(options),
icon: titleIcon,
};
}
function createSuccessModal(options: ModalOptionsPartial) {
return Modal.success(createModalOptions(options, 'success'));
}
function createErrorModal(options: ModalOptionsPartial) {
return Modal.error(createModalOptions(options, 'close'));
}
function createInfoModal(options: ModalOptionsPartial) {
return Modal.info(createModalOptions(options, 'info'));
}
function createWarningModal(options: ModalOptionsPartial) {
return Modal.warning(createModalOptions(options, 'warning'));
}
notification.config({
placement: 'topRight',
duration: 3,
});
/**
* @description: message
*/
export function useMessage() {
return {
createMessage: Message,
notification: notification as NotifyApi,
createConfirm: createConfirm,
createSuccessModal,
createErrorModal,
createInfoModal,
createWarningModal,
};
}