feat: the production environment can be dynamically configured

This commit is contained in:
nebv
2020-10-13 01:40:21 +08:00
parent e83cb06bb9
commit bb3b8f817d
29 changed files with 563 additions and 118 deletions

View File

@@ -283,7 +283,19 @@
const element = values[key];
if (fields.includes(key) && element !== undefined && element !== null) {
// 时间
(formModel as any)[key] = itemIsDateType(key) ? moment(element) : element;
if (itemIsDateType(key)) {
if (Array.isArray(element)) {
const arr: any[] = [];
for (const ele of element) {
arr.push(moment(ele));
}
(formModel as any)[key] = arr;
} else {
(formModel as any)[key] = moment(element);
}
} else {
(formModel as any)[key] = element;
}
if (formEl) {
formEl.validateFields([key]);
}

View File

@@ -209,7 +209,7 @@ export default defineComponent({
: {};
return (
<Menu
forceSubMenuRender={props.isAppMenu}
// forceSubMenuRender={props.isAppMenu}
selectedKeys={selectedKeys}
defaultSelectedKeys={defaultSelectedKeys}
mode={mode}

View File

@@ -77,7 +77,7 @@ export function useTableScroll(refProps: ComputedRef<BasicTableProps>, tableElRe
if (el) {
headerHeight = (el as HTMLElement).offsetHeight;
}
tableHeightRef.value =
const tHeight =
bottomIncludeBody -
(resizeHeightOffset || 0) -
paddingHeight -
@@ -86,8 +86,7 @@ export function useTableScroll(refProps: ComputedRef<BasicTableProps>, tableElRe
footerHeight -
headerHeight;
useTimeout(() => {
tableHeightRef.value =
tableHeightRef.value! > maxHeight! ? (maxHeight as number) : tableHeightRef.value;
tableHeightRef.value = tHeight > maxHeight! ? (maxHeight as number) : tableHeightRef.value;
cb && cb();
}, 0);
}

View File

@@ -1,14 +1,20 @@
import type { ProjectConfig, GlobConfig, SettingWrap } from '/@/types/config';
import type { ProjectConfig, GlobConfig, SettingWrap, GlobEnvConfig } from '/@/types/config';
import getProjectSetting from '/@/settings/projectSetting';
import { getGlobEnvConfig } from '../../../getEnvConfig';
import { getGlobEnvConfig, isDevMode } from '/@/utils/env';
import { getShortName } from '../../../build/getShortName';
const ENV_NAME = getShortName(import.meta.env);
const ENV = ((isDevMode()
? getGlobEnvConfig()
: window[ENV_NAME as any]) as unknown) as GlobEnvConfig;
const {
VITE_GLOB_APP_TITLE,
VITE_GLOB_API_URL,
VITE_GLOB_APP_SHORT_NAME,
VITE_GLOB_APP_TITLE,
VITE_GLOB_API_URL_PREFIX,
} = getGlobEnvConfig();
} = ENV;
export const useSetting = (): SettingWrap => {
// Take global configuration
@@ -19,7 +25,9 @@ export const useSetting = (): SettingWrap => {
urlPrefix: VITE_GLOB_API_URL_PREFIX,
};
const projectSetting: Readonly<ProjectConfig> = getProjectSetting;
console.log('======================');
console.log(glob);
console.log('======================');
return {
globSetting: glob as Readonly<GlobConfig>,
projectSetting,

View File

@@ -59,19 +59,17 @@ export function useECharts(
function resize() {
const chartInstance = unref(chartInstanceRef);
if (!chartInstance) {
return;
}
if (!chartInstance) return;
chartInstance.resize();
}
tryOnUnmounted(() => {
const chartInstance = unref(chartInstanceRef);
if (!chartInstance) {
return;
}
if (!chartInstance) return;
chartInstance.dispose();
chartInstanceRef.value = null;
});
return {
setOptions,
echarts,

View File

@@ -1,3 +1,10 @@
import type { GlobEnvConfig } from '/@/types/config';
export const getGlobEnvConfig = (): GlobEnvConfig => {
const env = import.meta.env;
return (env as unknown) as GlobEnvConfig;
};
/**
* @description: 开发模式
*/

View File

@@ -1,12 +1,13 @@
import { isDevMode, getEnv } from '/@/utils/env';
import { useSetting } from '/@/hooks/core/useSetting';
import moment from 'moment';
import pkg from '../../../package.json';
const { globSetting } = useSetting();
// Generate cache key according to version
export const getStorageShortName = () => {
const shortTime = moment().format('MMDDHHmmss');
return `${globSetting.shortName}__${getEnv()}${
isDevMode() ? `__${(pkg as any).version}` : '__' + process.env.VITE_BUILD_SHORT_TIME
`__${pkg.version}` + (isDevMode() ? '' : `__${shortTime}`)
}__`.toUpperCase();
};