chore: rename Application to app

This commit is contained in:
vben 2020-11-18 22:52:13 +08:00
parent 46e0875374
commit 99303a9987
9 changed files with 15 additions and 93 deletions

View File

@ -13,7 +13,7 @@
import moment from 'moment';
import 'moment/dist/locale/zh-cn';
import { getConfigProvider, initAppConfigStore } from '/@/setup/Application';
import { getConfigProvider, initAppConfigStore } from '/@/setup/App';
import { useLockPage } from '/@/hooks/web/useLockPage';
moment.locale('zh-cn');

View File

@ -1,4 +1,6 @@
import { Component } from 'vue';
import type { ComponentType } from './types/index';
/**
* Component list, register here to use it in the form
*/
@ -17,8 +19,6 @@ import {
} from 'ant-design-vue';
import RadioButtonGroup from './components/RadioButtonGroup.vue';
import { ComponentType } from './types/index';
const componentMap = new Map<ComponentType, any>();
componentMap.set('Input', Input);

View File

@ -108,4 +108,5 @@ export type ComponentType =
| 'ImageUpload'
| 'Switch'
| 'StrengthMeter'
| 'Upload'
| 'Render';

View File

@ -1,2 +1,8 @@
export { default as BasicUpload } from './src/BasicUpload.vue';
// export * from './src/types';
import type { App } from 'vue';
import BasicUpload from './src/BasicUpload.vue';
export default (app: App): void => {
app.component(BasicUpload.name, BasicUpload);
};
export { BasicUpload };

View File

@ -41,6 +41,7 @@
import { omit } from 'lodash-es';
export default defineComponent({
name: 'BasicUpload',
components: { UploadModal, UploadPreviewModal, Icon, Tooltip },
props: uploadContainerProps,
setup(props, { emit, attrs }) {

View File

@ -33,7 +33,7 @@ import {
Result,
Empty,
} from 'ant-design-vue';
import { getApp } from '/@/setup/Application';
import { getApp } from '/@/setup/App';
const compList = [Icon, Button, AntButton.Group, AppFooter];

View File

@ -7,7 +7,7 @@ import { setupErrorHandle } from '/@/setup/error-handle';
import { setupGlobDirectives } from '/@/setup/directives';
import { setupProdMockServer } from '../mock/_createProductionServer';
import { setApp } from '/@/setup/Application';
import { setApp } from '/@/setup/App';
import App from './App.vue';

View File

@ -1,86 +0,0 @@
/**
* Application configuration
*/
import type { ProjectConfig } from '/@/types/config';
import type { App } from 'vue';
import { computed, ref } from 'vue';
import { ThemeModeEnum } from '/@/enums/appEnum';
import { PROJ_CFG_KEY } from '/@/enums/cacheEnum';
import projectSetting from '/@/settings/projectSetting';
import { getLocal } from '/@/utils/helper/persistent';
import { isUnDef, isNull } from '/@/utils/is';
import {
updateGrayMode,
updateColorWeak,
updateHeaderBgColor,
updateSidebarBgColor,
} from '/@/setup/theme';
import { appStore } from '/@/store/modules/app';
// Used to share global app instances
let app: App;
export function setApp(_app: App): void {
app = _app;
}
export function getApp(): App {
return app;
}
// TODO Theme switching
export function useThemeMode(mode: ThemeModeEnum) {
const modeRef = ref(mode);
const html = document.documentElement;
const clsList = html.classList;
const change = () => {
clsList.contains(mode) ? clsList.remove(mode) : clsList.add(mode);
};
return {
runChangeThemeMode: change,
mode: computed(() => modeRef.value),
};
}
// Initial project configuration
export function initAppConfigStore() {
let projCfg: ProjectConfig = getLocal(PROJ_CFG_KEY) as ProjectConfig;
if (!projCfg) {
projCfg = projectSetting;
}
const { colorWeak, grayMode, headerBgColor, menuBgColor } = projCfg;
try {
// if (
// themeColor !== primaryColor &&
// themeColor &&
// process.env.VUE_APP_USE_THEME_REPLACER !== 'TRUE'
// ) {
// updateTheme(themeColor);
// }
headerBgColor && updateHeaderBgColor(headerBgColor);
menuBgColor && updateSidebarBgColor(menuBgColor);
grayMode && updateGrayMode(grayMode);
colorWeak && updateColorWeak(colorWeak);
} catch (error) {
console.log(error);
}
appStore.commitProjectConfigState(projCfg);
}
// antdv Config Provider
export function getConfigProvider() {
function transformCellText({ text }: { text: string }) {
if (isNull(text) || isUnDef(text)) {
return ' - ';
}
return text;
}
return {
transformCellText,
};
}