Quellcode durchsuchen

🎨 修改细节问题

快乐的梦鱼 vor 2 Monaten
Ursprung
Commit
25343d348c

+ 19 - 0
src/common/components/upload/ImageUploadCo.ts

@@ -0,0 +1,19 @@
+import CommonContent from "@/api/CommonContent";
+import type { UploaderAction } from "@/components/form/Uploader";
+
+export function useImageSimpleUploadCo(additionData?: Record<string, any>) {
+  return (action: UploaderAction) => {
+    action.onStart('正在上传');
+    CommonContent.uploadFile(action.item.filePath, 'image', 'file', additionData)
+      .then((res) => {
+        action.onProgress(100);
+        action.onFinish({
+          uploadedUrl: res.fullurl,
+          previewUrl: res.fullurl,
+        }, '上传成功');
+      }).catch((err) => {
+        action.onError?.(err);
+      })
+  }
+}
+

+ 2 - 0
src/components/dynamic/wrappers/PickerIdField.vue

@@ -16,6 +16,8 @@ const props = defineProps<PickerIdFieldProps>();
 const emit = defineEmits(['update:modelValue']);
 const loader = useDataLoader<PickerIdFieldOption[]>(async () => {
   const res = await props.loadData();
+  if (res.length === 0)
+    return [];
   return ([{
     text: '请选择',
     value: '',

+ 1 - 0
src/components/nav/Tabs.vue

@@ -345,6 +345,7 @@ function onTabClick(index: number) {
   flex-shrink: 0;
   flex-grow: 0;
   height: auto;
+  overflow: hidden;
 
   .tab-item {
     position: relative;

+ 1 - 1
src/pages/article/common/CommonListPage.vue

@@ -21,7 +21,7 @@
         v-model="searchValue"
         :placeholder="`输入关键词搜索${title}`" 
         @search="doSearch"
-        @clear="doSearch"
+        @cancel="doSearch"
       />
     </view>
     <!-- 下拉框 -->

+ 3 - 3
src/pages/parts/LikeFooter.vue

@@ -5,15 +5,15 @@
       
       </FlexRow>
       <FlexRow align="center">
-        <Touchable direction="row" :gap="10" :padding="[0,10]" @click="doLike">
+        <Touchable direction="row" align="center" :gap="10" :padding="[0,10]" @click="doLike">
           <Icon icon="good" :color="content.isLike ? 'primary' : 'text.content'" />
           <Text :text="likes" :color="content.isLike ? 'primary' : 'text.content'" />
         </Touchable>
-        <Touchable direction="row" :gap="10" :padding="[0,10]" @click="doCollect">
+        <Touchable direction="row" align="center" :gap="10" :padding="[0,10]" @click="doCollect">
           <Icon icon="favorite" :color="content.isCollect ? 'warning' : 'text.content'" />
           <Text text="收藏" :color="content.isCollect ? 'warning' : 'text.content'" />
         </Touchable>
-        <button class="remove-button-style" direction="row" open-type="share">
+        <button class="remove-button-style" open-type="share">
           <FlexRow :gap="10" align="center" :padding="[0,10]" >
             <Icon icon="share" color="text.content" />
             <Text text="分享" />

+ 2 - 0
src/pages/user/collect/index.vue

@@ -30,6 +30,8 @@ async function loadData(
 ) {
   
   const res = await UserApi.getUserCollect(page, pageSize);
+  if (searchText)
+    res.list = res.list.filter((p) => (p.title as string).includes(searchText));
   res.list.forEach((p) => {
     switch(p.modelId) {
       default:

+ 119 - 7
src/pages/user/contribute/submit.vue

@@ -21,6 +21,9 @@ import XBarSpace from '@/components/layout/space/XBarSpace.vue';
 import DynamicForm from '@/components/dynamic/DynamicForm.vue';
 import type { IDynamicFormOptions, IDynamicFormRef } from '@/components/dynamic';
 import type { FormProps } from '@/components/form/Form.vue';
+import type { PickerIdFieldProps } from '@/components/dynamic/wrappers/PickerIdField';
+import type { UploaderFieldProps } from '@/components/form/UploaderField.vue';
+import { useImageSimpleUploadCo } from '@/common/components/upload/ImageUploadCo';
 
 const loading = ref(false);
 
@@ -76,13 +79,13 @@ const formDefine : IDynamicFormOptions = {
             disabled: true,
             loadData: async () => {
               return [
-                { id: 1, text: "文章" },
-                { id: 2, text: "音频" },
-                { id: 3, text: "视频" },
-                { id: 4, text: "相册" },
+                { value: 1, text: "文章" },
+                { value: 2, text: "音频" },
+                { value: 3, text: "视频" },
+                { value: 4, text: "相册" },
               ]
-            },
-          },
+            } ,
+          } as PickerIdFieldProps,
           defaultValue: 1,
           rules: [{
             required: true,
@@ -96,6 +99,21 @@ const formDefine : IDynamicFormOptions = {
       type: 'flat-group',
       children: [
         {
+          label: `缩略图`,
+          name: 'image',
+          type: 'uploader',
+          defaultValue: '',
+          additionalProps: {
+            upload: useImageSimpleUploadCo(),
+            maxFileSize: 1024 * 1024 * 20,
+            single: true,
+          } as UploaderFieldProps,
+          rules: [],
+          formProps: {
+            extraMessage: '建议分辨率:1920*1080以上',
+          },
+        },
+        {
           label: '内容',
           name: 'intro',
           type: 'richtext',
@@ -108,9 +126,103 @@ const formDefine : IDynamicFormOptions = {
             required: true,
             message: '请输入内容',
           }]
-        }
+        },
+        {
+          label: '来源(可选)',
+          name: 'source',
+          type: 'text',
+          defaultValue: '',
+          additionalProps: {
+            placeholder: '如果是转载文章可以输入来源',
+          },
+        },
+        {
+          label: `组图`,
+          name: 'images',
+          type: 'uploader',
+          defaultValue: '',
+          show: { callback: (_, formModel) => formModel.type == 4 },
+          additionalProps: {
+            upload: useImageSimpleUploadCo(),
+            maxFileSize: 1024 * 1024 * 100,
+            maxUploadCount: 20,
+          } as UploaderFieldProps,
+          formProps: {
+            extraMessage: '建议分辨率:1920*1080以上',
+          },
+          rules: []
+        },
+        {
+          label: `音频`,
+          name: 'audio',
+          type: 'uploader',
+          defaultValue: '',
+          show: { callback: (_, formModel) => formModel.type == 2 },
+          additionalProps: {
+            upload: useImageSimpleUploadCo(),
+            maxFileSize: 1024 * 1024 * 100,
+            single: true,
+            chooseType: 'video',
+          } as UploaderFieldProps,
+          rules: []
+        },
+        {
+          label: `视频`,
+          name: 'video',
+          type: 'uploader',
+          defaultValue: '',
+          show: { callback: (_, formModel) => formModel.type == 3 },
+          additionalProps: {
+            upload: useImageSimpleUploadCo(),
+            maxFileSize: 1024 * 1024 * 100,
+            single: true,
+            chooseType: 'video',
+          } as UploaderFieldProps,
+          formProps: {
+            extraMessage: '建议使用MP4格式1080P分辨率',
+          },
+          rules: []
+        },
       ]
     },
+    {
+      name: 'c',
+      type: 'flat-group',
+      label: '额外信息(可选)',
+      formProps: {
+        showLabel: false,
+      },
+      additionalProps: {
+        collapsible: true,
+        collapsed: true,
+      },
+      childrenColProps: { span: 24 },
+      children: [
+        {
+          label: '',
+          name: 'extra',
+          type: 'static-text',
+          defaultValue: '',
+          additionalProps: {
+            text: '额外信息用于采集系统内部处理,可以不填写',
+          },
+        },
+        {
+          label: `关键字`,
+          name: 'keywords',
+          type: 'text-tag',
+          defaultValue: '',
+          rules: [],
+          additionalProps: {
+            placeholder: '可以输入关键字',
+            tagJoinType: ';',
+          },
+          formProps: {
+            extraMessage: '用于系统优化关键字搜索',
+          },
+        },
+      ],
+    }
   ]
 }
 

+ 9 - 1
src/pages/user/index.vue

@@ -56,7 +56,14 @@
       </Touchable>
 
       <CellGroup round>
-        <Cell icon="https://mncdn.wenlvti.net/uploads/20250313/07f750b4cf4959654c40171fdae91c3a.png" title="去投稿" showArrow touchable @click="goContribute" />
+        <Cell icon="https://mncdn.wenlvti.net/uploads/20250313/07f750b4cf4959654c40171fdae91c3a.png" title="投稿" showArrow touchable @click="goContribute">
+          <template #value>
+            <FlexRow>
+              <Button shape="round" type="success" size="small" :radius="40" @click="goContribute">去投稿</Button>
+              <Width :width="20" />
+            </FlexRow>
+          </template>
+        </Cell>
         <Cell icon="https://mncdn.wenlvti.net/uploads/20250313/66d4665b1da5075e60148312469b2630.png" title="我的投稿" showArrow touchable @click="goContributeList" />
         <Cell icon="https://mncdn.wenlvti.net/uploads/20250313/042236758da5aaed21c1010e5b9440ce.png" title="我的收藏" showArrow touchable @click="navTo('collect/index')" />
         <Cell icon="https://mncdn.wenlvti.net/uploads/20250313/d2e9010323d098aa51e268fc32f14d3d.png" title="在线客服" showArrow touchable @click="showService" />
@@ -98,6 +105,7 @@ import H4 from '@/components/typography/H4.vue';
 import Image from '@/components/basic/Image.vue';
 import Width from '@/components/layout/space/Width.vue';
 import Text from '@/components/basic/Text.vue';
+import Button from '@/components/basic/Button.vue';
 
 const UserHead = 'https://mncdn.wenlvti.net/app_static/minnan/images/home/UserHead.png';