Procházet zdrojové kódy

🎨 修改细节问题

快乐的梦鱼 před 3 týdny
rodič
revize
14dc5fa7b6

+ 9 - 1
src/common/config/AppCofig.ts

@@ -11,8 +11,16 @@ export default {
   defaultImage: 'https://mncdn.wenlvti.net/app_static/minnan/EmptyImage.png',
   shareTitle: '',
 }
-
+//#ifdef MP-WEIXIN
 const accountInfo = uni.getAccountInfoSync();
+//#endif
+//#ifndef MP-WEIXIN
+const accountInfo = {
+  miniProgram: {
+    envVersion: '',
+  },
+};
+//#endif
 
 /**
  * 获取当前环境版本

+ 5 - 5
src/pages/article/data/CommonCategoryDetail.vue

@@ -259,15 +259,15 @@ const tabRenderDefinesArray = computed(() => {
 });
 
 async function loadPageConfig() {
-  if (getIsDevtoolsPlatform()) {
-    await waitTimeOut(1000);
-  }
   if (!props.pageConfigName) {
     errorMessage.value = '配置有误';
     return;
   }
-  currentCommonCategoryDefine.value = commonCategory.value.page
-    .find((item) => item.name === props.pageConfigName);
+  currentCommonCategoryDefine.value = commonCategory.value.page.find((item) => item.name === props.pageConfigName);
+  if (!currentCommonCategoryDefine.value) {
+    await waitTimeOut(1000);
+    currentCommonCategoryDefine.value = commonCategory.value.page.find((item) => item.name === props.pageConfigName);
+  }
   if (!currentCommonCategoryDefine.value) {
     errorMessage.value = '未找到指定的分类配置:' + props.pageConfigName;
     return;

+ 6 - 0
src/pages/article/data/CommonCategoryDynamicEvax.ts

@@ -326,6 +326,8 @@ export function doEvaluateDynamicCompareExpression(expression: string, context:
  * @param context 
  */
 export async function doCallDynamicFunction(functions: string, context: IDynamicCompareExpressionContext) {
+  if (functions.startsWith('dynamic:'))
+    functions = functions.substring(8);
   const functionArr = functions.replace(/\n/g, '/').split('/');
   let result = null;
   let currentPointer = 0;
@@ -463,6 +465,10 @@ export async function doCallDynamicFunction(functions: string, context: IDynamic
             },
             fail: (err: any) => {
               console.error('doCallDynamicFunction: openOfficialAccountArticle failed: ' + err);
+              uni.showToast({
+                title: '打开公众号文章失败',
+                icon: 'none',
+              });
               reject(err);
             },
           });

+ 5 - 5
src/pages/article/data/CommonCategoryList.vue

@@ -53,15 +53,15 @@ const props = defineProps({
 });
 
 async function loadPageConfig() {
-  if (getIsDevtoolsPlatform()) {
-    await waitTimeOut(1000);
-  }
   if (!props.pageConfigName) {
     errorMessage.value = '配置有误';
     return;
   }
-  currentCommonCategoryDefine.value = commonCategory.value.page
-    .find((item) => item.name === props.pageConfigName);
+  currentCommonCategoryDefine.value = commonCategory.value.page.find((item) => item.name === props.pageConfigName);
+  if (!currentCommonCategoryDefine.value) {
+    await waitTimeOut(1000);
+    currentCommonCategoryDefine.value = commonCategory.value.page.find((item) => item.name === props.pageConfigName);
+  }
   if (!currentCommonCategoryDefine.value) {
     errorMessage.value = '未找到指定的分类配置:' + props.pageConfigName;
     return;

+ 6 - 3
src/pages/article/data/DefaultCategory.json

@@ -1497,11 +1497,13 @@
                     }
                   ]
                 }
-              }
+              },
+              "width": 200
             },
             {
               "text": "地理位置",
-              "type": "map"
+              "type": "map",
+              "width": 200
             }
           ]
         }
@@ -2038,7 +2040,8 @@
             "url": "https://mn.wenlvti.net/xmlib/opac/m/search?q={0}&curlibcode=&searchWay=title&hasholding=1",
             "icon": "https://mn.wenlvti.net/app_static/minnan/images/inhert/IconBorrow.png",
             "text": "点击查询借阅"
-          }
+          },
+          "recommendDetailHandler": "dynamic:if:A,K#main.externalLink:jumpMp:default/#jumpMp#openOfficialAccountArticle:A,K#main.externalLink/break/#default#navigateToAutoContent:K#main"
         }
       }
     },

+ 3 - 1
src/pages/article/data/api/CommonCategoryApi.ts

@@ -72,12 +72,14 @@ export class CommonCategoryApi extends UpdateServerRequestModule<DataModel> {
     saveToHistoryId?: number,
     autoSelectNewToActive?: boolean,
   ) {
-    return (await this.post(`/app-configuration-edit/${CommonCategoryConfig.getAppConfigId(isDev)}?saveToHistoryId=${saveToHistoryId ?? ''}`, '编辑配置', {
+    return (await this.post(`/app-configuration-edit/${CommonCategoryConfig.getAppConfigId(isDev)}`, '编辑配置', {
       id: CommonCategoryConfig.getAppConfigId(isDev),
       name,
       data: json,
       accessKey: CommonCategoryConfig.getAccessKey(isDev),
       autoSelectNewToActive: autoSelectNewToActive ?? false,
+    }, {
+      saveToHistoryId: saveToHistoryId || undefined,
     })).data;
   }
   /**

+ 8 - 0
src/pages/article/data/editor/editors/CommonDetailPropsEditor.vue

@@ -79,6 +79,14 @@
             <a-button type="dashed" block size="small" @click="addTopShowInfo">+ 添加显示信息</a-button>
           </div>
         </a-collapse-panel>
+
+        <a-collapse-panel key="recommendDetailHandler" header="推荐详情处理函数 (recommendDetailHandler)">
+          <a-form :labelCol="{ span: 6 }" size="small">
+            <a-form-item label="函数表达式">
+              <a-input v-model:value="props.props.recommendDetailHandler" placeholder="表达式" />
+            </a-form-item>
+          </a-form>
+        </a-collapse-panel>
       </a-collapse>
     </a-form>
   </div>

+ 28 - 8
src/pages/article/details.vue

@@ -106,7 +106,7 @@
               :desc="item.desc"
               :wideImage="true"
               :tags="(item.bottomTags as string[])"
-              @click="goDetails(item.id)"
+              @click="goDetails(item)"
             />
           </view>
 
@@ -133,11 +133,11 @@ import { FormatUtils, StringUtils, waitTimeOut } from "@imengyu/imengyu-utils";
 import { injectAppConfiguration } from "@/api/system/useAppConfiguration";
 import { useSimpleDataLoader } from "@/common/composeabe/SimpleDataLoader";
 import { navTo, redirectTo } from "@/components/utils/PageAction";
-import { resolveCommonContentFormData } from "./common/CommonContent";
+import { navCommonDetail, resolveCommonContentFormData } from "./common/CommonContent";
 import { injectCommonCategory } from "./data/CommonCategoryGlobalLoader";
 import { getIsDevtoolsPlatform } from "@/common/utils/MpVersions";
 import { doCallDynamicFunction, doEvaluateDynamicCompareExpression } from "./data/CommonCategoryDynamicEvax";
-import type { GetContentDetailItem } from "@/api/CommonContent";
+import type { GetContentDetailItem, GetContentListItem } from "@/api/CommonContent";
 import type { IHomeCommonArticleDetailDefine } from "./data/CommonCategoryDefine";
 import CommonContent, { GetContentListParams } from "@/api/CommonContent";
 import Box2LineImageRightShadow from "../parts/Box2LineImageRightShadow.vue";
@@ -216,6 +216,10 @@ export interface CommonArticleDetailProps {
      */
     expression: string,
   }[],
+  /**
+   * 推荐详情处理函数
+   */
+  recommendDetailHandler: string,
 }
 
 const { querys } = useLoadQuerys({ 
@@ -261,6 +265,7 @@ const loader = useSimplePageContentLoader<
 >(async (params) => {
   if (!params)
     throw new Error("!params");
+  await waitTimeOut(200);
   const res = await NewsIndexContent.getContentDetail(params.id);
   uni.setNavigationBarTitle({ title: res.title });
   if (querys.value.navToExternalLink === 'auto' && (!res.content || res.content.trim() === '') && res.externalLink) {
@@ -390,10 +395,21 @@ function goArchive(id: number) {
       break;
   }
 }
-function goDetails(id: number) {
-  navTo('/pages/article/details', { 
-    ...querys.value,
-    id,
+function goDetails(item: GetContentListItem) {
+  const script = currentCommonCategoryContentDefine.value?.props.recommendDetailHandler;
+  if (script) {
+    doCallDynamicFunction(script, {
+      sourceData: {
+        main: item,
+        customData: {},
+      }
+    });
+    return;
+  }
+  navCommonDetail({
+    id: item.id,
+    mainBodyColumnId: item.mainBodyColumnId,
+    modelId: item.modelId,
   });
 }
 function goBorrow(title: string) {
@@ -416,9 +432,13 @@ async function loadPageConfig() {
     await waitTimeOut(500);
   }
   const pageConfigName = 'common-details';
-  const currentCommonCategoryDefine = commonCategory.value.page
+  let currentCommonCategoryDefine = commonCategory.value.page
     .find((item) => item.name === pageConfigName);
   if (!currentCommonCategoryDefine) {
+    await waitTimeOut(1000);
+    currentCommonCategoryDefine = commonCategory.value.page.find((item) => item.name === pageConfigName);
+  }
+  if (!currentCommonCategoryDefine) {
     errorMessage.value = '未找到指定的分类配置:' + pageConfigName;
     return;
   }