update 更新全局属性定义,使用provide / inject

This commit is contained in:
LiuHao 2024-05-16 12:00:59 +08:00
parent 3062c46b49
commit c34d2bb82e
2 changed files with 23 additions and 5 deletions

View File

@ -50,8 +50,9 @@ app.use(router);
app.use(store);
app.use(i18n);
app.use(VXETable);
// 全局方法 属性
app.use(plugins);
// 自定义指令
directive(app);
app.use(directive);
app.mount('#app');

View File

@ -1,12 +1,12 @@
import modal from './modal';
import tab from './tab';
import download from './download';
import ossDownload from './download';
import cache from './cache';
import auth from './auth';
// 预设动画
import animate from '@/animate';
import { download as dl } from '@/utils/request';
import { download } from '@/utils/request';
import { useDict } from '@/utils/dict';
import { getConfigKey, updateConfigByKey } from '@/api/system/config';
import { parseTime, addDateRange, handleTree, selectDictLabel, selectDictLabels } from '@/utils/ruoyi';
@ -24,20 +24,37 @@ export default function installPlugin(app: App) {
app.config.globalProperties.$cache = cache;
// 下载文件
app.config.globalProperties.$download = download;
app.config.globalProperties.$download = ossDownload;
// 认证对象
app.config.globalProperties.$auth = auth;
app.provide('$tab', tab);
app.provide('$modal', modal);
app.provide('$cache', cache);
app.provide('$ossDownload', ossDownload);
app.provide('$auth', auth);
// 全局方法挂载
app.config.globalProperties.useDict = useDict;
app.config.globalProperties.getConfigKey = getConfigKey;
app.config.globalProperties.updateConfigByKey = updateConfigByKey;
app.config.globalProperties.download = dl;
app.config.globalProperties.download = download;
app.config.globalProperties.parseTime = parseTime;
app.config.globalProperties.handleTree = handleTree;
app.config.globalProperties.addDateRange = addDateRange;
app.config.globalProperties.selectDictLabel = selectDictLabel;
app.config.globalProperties.selectDictLabels = selectDictLabels;
app.config.globalProperties.animate = animate;
app.provide('useDict', useDict);
app.provide('getConfigKey', getConfigKey);
app.provide('updateConfigByKey', updateConfigByKey);
app.provide('download', download);
app.provide('parseTime', parseTime);
app.provide('handleTree', handleTree);
app.provide('addDateRange', addDateRange);
app.provide('selectDictLabel', selectDictLabel);
app.provide('selectDictLabels', selectDictLabels);
app.provide('animate', animate);
}