|
|
@@ -0,0 +1,46 @@
|
|
|
+import { MengyuServerRequestModule } from '@/api/RequestModules';
|
|
|
+import { LogUtils } from '@imengyu/imengyu-utils';
|
|
|
+import { DataModel } from '@imengyu/js-request-transform';
|
|
|
+import DefaultConfiguration from './DefaultConfiguration.json';
|
|
|
+
|
|
|
+export const CommonConfigurationConfig = {
|
|
|
+ /**
|
|
|
+ * 应用id
|
|
|
+ */
|
|
|
+ appId: 2,
|
|
|
+ appConfigId: 6,
|
|
|
+}
|
|
|
+
|
|
|
+export interface IConfigurationItem {
|
|
|
+ baseServerUrl: string,
|
|
|
+ articleMark: string,
|
|
|
+ collectSignYear: number,
|
|
|
+ collectFormYear: number,
|
|
|
+ routeListImage: string,
|
|
|
+ routeListImageStyle: Record<string, any>,
|
|
|
+ routeListMarginTop: number,
|
|
|
+}
|
|
|
+
|
|
|
+export class ConfigurationApi extends MengyuServerRequestModule<DataModel> {
|
|
|
+
|
|
|
+ constructor() {
|
|
|
+ super();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取当前配置,有缓存,会根据激活的历史版本获取对应配置
|
|
|
+ * @returns
|
|
|
+ */
|
|
|
+ async getConfig() {try {
|
|
|
+ return (((await this.get('/app-configuration-get', '获取配置', {
|
|
|
+ name: CommonConfigurationConfig.appConfigId,
|
|
|
+ appId: CommonConfigurationConfig.appId,
|
|
|
+ })).data as any)?.data as IConfigurationItem);
|
|
|
+ } catch (error) {
|
|
|
+ LogUtils.printLog("ConfigurationApi", 'error', '获取配置失败,使用默认配置', error);
|
|
|
+ return DefaultConfiguration as IConfigurationItem;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+export default new ConfigurationApi();
|