Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(file-upload): modify the error reported by the upload component on the mobile client and add the demo #2724

Merged
merged 3 commits into from
Jan 2, 2025

Conversation

James-9696
Copy link
Collaborator

@James-9696 James-9696 commented Jan 2, 2025

PR

PR Checklist

Please check if your PR fulfills the following requirements:

  • [\x] The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

Based on the comprehensive summary of changes, here are the release notes:

  • New Features

    • Enhanced file upload component with improved mobile demo configurations
    • Added more flexible file upload options and properties
  • Bug Fixes

    • Refined file upload interactions and validation mechanisms
    • Improved error handling for file uploads
  • Refactoring

    • Streamlined file upload component structure
    • Updated prop management for file upload components
    • Simplified references and component interactions
  • Removals

    • Deleted several demo components related to file uploads
    • Removed redundant code and unused components
  • Documentation

    • Updated demo configurations for file upload features
    • Enhanced localization support for file upload demos

Copy link

coderabbitai bot commented Jan 2, 2025

Walkthrough

This pull request introduces comprehensive modifications to the file upload component across multiple files in the mobile application. The changes primarily focus on refining the mobileDemo properties, updating component configurations, and streamlining the file upload functionality. Several demo components have been removed, and the core file upload implementation has been updated to improve prop handling, reference management, and overall component structure.

Changes

File Path Change Summary
examples/sites/demos/apis/file-upload.js Updated mobileDemo values for various file upload properties
examples/sites/demos/mobile/app/file-upload/ Removed multiple demo components like accept-file-image.vue, custom-prefix.vue, drag-select-file.vue
packages/mobile/components/file-upload/src/file-upload.ts Added import for $props and updated fileUploadProps
packages/mobile/components/file-upload/src/mobile.vue Simplified props declaration and removed Progress component
packages/mobile/components/file-upload/src/renderless/ Updated references and method calls in upload-related files

Sequence Diagram

sequenceDiagram
    participant User
    participant FileUploadComponent
    participant FileUploadService

    User->>FileUploadComponent: Select Files
    FileUploadComponent->>FileUploadComponent: Validate Files
    alt Files Valid
        FileUploadComponent->>FileUploadService: Upload Files
        FileUploadService-->>FileUploadComponent: Upload Response
        FileUploadComponent-->>User: Show Upload Status
    else Files Invalid
        FileUploadComponent-->>User: Show Error Message
    end
Loading

Possibly related PRs

Suggested Labels

bug, documentation

Suggested Reviewers

  • zzcr

Poem

🐰 Hop, hop, upload with glee!
Files dancing, wild and free
Props refined, demos take flight
Mobile uploads, shining bright
Code rabbit's file upload delight! 🚀


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the bug Something isn't working label Jan 2, 2025
Copy link

github-actions bot commented Jan 2, 2025

[e2e-test-warn]
The component to be tested is missing.

The title of the Pull request should look like "fix(vue-renderless): [action-menu, alert] fix xxx bug".

Please make sure you've read our contributing guide

Copy link

Walkthrough

This pull request addresses a bug fix in the file upload component for mobile clients. It modifies error reporting and adds a demo to illustrate the changes. The update involves changes in demo configurations and the removal of certain demo files.

Changes

File(s) Summary
examples/sites/demos/apis/file-upload.js Updated mobile demo configurations for file upload scenarios.
examples/sites/demos/mobile/app/file-upload/*.vue Removed several demo files related to file upload.
examples/sites/demos/mobile/app/file-upload/webdoc/file-upload.js Added new demo configurations for file upload features.
packages/mobile/components/file-upload/src/file-upload.ts Added shared props to file upload component.
packages/mobile/components/file-upload/src/mobile.vue Refactored to use shared props for file upload component.
packages/mobile/components/file-upload/src/renderless/index.ts Simplified upload handling by removing nested references.
packages/mobile/components/file-upload/src/renderless/vue.ts Updated to use optional chaining for EDM upload properties.
packages/mobile/components/upload-list/src/renderless/vue.ts Refactored to use injected uploader directly.
packages/mobile/components/upload-list/src/upload-list.ts Added reUploadable prop to upload list component.
packages/mobile/components/upload/src/renderless/vue.ts Simplified upload inner reference computation.

@@ -315,7 +315,7 @@ export const startUpload =
}: Pick<IFileUploadRenderlessParams, 'state' | 'constants' | 'vm' | 'api' | 't'> & IFileUploadModalVm) =>
(file: IFileUploadFile, isList: boolean) => {
if (state.isHwh5) {
vm.$refs[constants.UPLOAD_INNER].$refs[constants.UPLOAD_INNER_TEMPLATE].upload(file.raw)
vm.$refs[constants.UPLOAD_INNER].upload(file.raw)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored to remove unnecessary nested reference to UPLOAD_INNER_TEMPLATE, simplifying the upload call.

@@ -335,7 +335,7 @@ export const startUpload =
status: 'warning'
})
} else {
vm.$refs[constants.UPLOAD_INNER].$refs[constants.UPLOAD_INNER_TEMPLATE].upload(file.raw)
vm.$refs[constants.UPLOAD_INNER].upload(file.raw)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored to remove unnecessary nested reference to UPLOAD_INNER_TEMPLATE, simplifying the upload call.

@@ -629,16 +629,14 @@ export const handleStart =

if (!state.isEdm && props.autoUpload) {
if (props.multiple && props.mergeService) {
const handler = (file) =>
vm.$refs[constants.UPLOAD_INNER].$refs[constants.UPLOAD_INNER_TEMPLATE].upload(file.raw)
const handler = (file) => vm.$refs[constants.UPLOAD_INNER].upload(file.raw)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored to remove unnecessary nested reference to UPLOAD_INNER_TEMPLATE, simplifying the upload call.


rawFiles.length && api.beforeUpload({ raw: rawFiles }, true, handler)
} else {
rawFiles.forEach((rawFile) => {
const file = api.getFile(rawFile)
if (!file) return
const handler = (file) =>
vm.$refs[constants.UPLOAD_INNER].$refs[constants.UPLOAD_INNER_TEMPLATE].upload(file.raw)
const handler = (file) => vm.$refs[constants.UPLOAD_INNER].upload(file.raw)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored to remove unnecessary nested reference to UPLOAD_INNER_TEMPLATE, simplifying the upload call.

@@ -863,7 +861,7 @@ export const handleReUpload =
const { READY } = constants.FILE_STATUS
file.status = READY
file.percentage = 0
vm.$refs[constants.UPLOAD_INNER].$refs[constants.UPLOAD_INNER_TEMPLATE].upload(file.raw)
vm.$refs[constants.UPLOAD_INNER].upload(file.raw)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored to remove unnecessary nested reference to UPLOAD_INNER_TEMPLATE, simplifying the upload call.

@@ -918,7 +916,7 @@ export const abort =
})
}

vm.$refs[constants.UPLOAD_INNER].$refs[constants.UPLOAD_INNER_TEMPLATE].abort(file)
vm.$refs[constants.UPLOAD_INNER].abort(file)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored to remove unnecessary nested reference to UPLOAD_INNER_TEMPLATE, simplifying the abort call.

@@ -990,12 +988,12 @@ export const submit =
const rawFiles = files.map((file) => file.raw)
rawFiles.length &&
api.beforeUpload({ raw: rawFiles }, false, (file) => {
vm.$refs[constants.UPLOAD_INNER].$refs[constants.UPLOAD_INNER_TEMPLATE].upload(file.raw)
vm.$refs[constants.UPLOAD_INNER].upload(file.raw)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored to remove unnecessary nested reference to UPLOAD_INNER_TEMPLATE, simplifying the upload call.

})
} else {
files.forEach((file) => {
api.beforeUpload(file, false, (file) => {
vm.$refs[constants.UPLOAD_INNER].$refs[constants.UPLOAD_INNER_TEMPLATE].upload(file.raw)
vm.$refs[constants.UPLOAD_INNER].upload(file.raw)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored to remove unnecessary nested reference to UPLOAD_INNER_TEMPLATE, simplifying the upload call.

@@ -1005,7 +1003,7 @@ export const submit =
export const handleClick =
({ constants, vm }: Pick<IFileUploadRenderlessParams, 'constants' | 'vm'>) =>
() =>
vm.$refs[constants.UPLOAD_INNER].$refs[constants.UPLOAD_INNER_TEMPLATE].handleClick()
vm.$refs[constants.UPLOAD_INNER].handleClick()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored to remove unnecessary nested reference to UPLOAD_INNER_TEMPLATE, simplifying the handleClick call.

@@ -2121,7 +2119,7 @@ export const batchSegmentUpload =
} else {
typeof props.edm.upload.closeloading === 'function' && props.edm.upload.closeloading()

vm.$refs[constants.UPLOAD_INNER].$refs[constants.UPLOAD_INNER_TEMPLATE].upload(state.largeFileInfo[docId])
vm.$refs[constants.UPLOAD_INNER].upload(state.largeFileInfo[docId])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored to remove unnecessary nested reference to UPLOAD_INNER_TEMPLATE, simplifying the upload call.

@@ -2623,7 +2621,7 @@ export const getFileSourceType =
export const updateFile =
({ constants, vm }: Pick<IFileUploadRenderlessParams, 'constants' | 'vm'>) =>
(file: IFileUploadFile) => {
vm.$refs[constants.UPLOAD_INNER].$refs[constants.UPLOAD_INNER_TEMPLATE].handleUpdate(file)
vm.$refs[constants.UPLOAD_INNER].handleUpdate(file)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored to remove unnecessary nested reference to UPLOAD_INNER_TEMPLATE, simplifying the handleUpdate call.

@@ -2634,7 +2632,7 @@ export const handleChange =
if (!Array.isArray(file)) {
files = [file]
}
vm.$refs[constants.UPLOAD_INNER].$refs[constants.UPLOAD_INNER_TEMPLATE].handleChange({ target: { files } })
vm.$refs[constants.UPLOAD_INNER].handleChange({ target: { files } })

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored to remove unnecessary nested reference to UPLOAD_INNER_TEMPLATE, simplifying the handleChange call.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (5)
examples/sites/demos/mobile/app/file-upload/file-icon-list.vue (1)

2-8: Inline title might need localization support

Adding file-title="我是标题" helps illustrate usage but it’s hard-coded in Chinese. If your project supports multiple languages, consider extracting this string for localization or i18n, ensuring it’s easily translatable.

packages/mobile/components/file-upload/src/mobile.vue (1)

53-53: Returning pictureArr within the .map() callback.
Although you’re returning pictureArr, consider whether this return value is actually needed in the .map() chain or if a forEach might be cleaner.

- uploaArr &&
-   uploaArr.map((item) => {
-     // ...
-     return pictureArr
-   })
+ if (uploaArr) {
+   uploaArr.forEach((item) => {
+     // ...
+   })
+ }
packages/mobile/components/file-upload/src/renderless/index.ts (3)

639-639: beforeUpload invocation.
Be mindful if any UI blocking or concurrency issues might arise if large sets of files are processed.


919-919: Global abort call.
Calling abort() with no file argument correctly sets all files in FAIL state. Be mindful of partial states if new files are being added concurrently.


2635-2635: Trigger handleChange with a custom file array.
Good approach for programmatic file addition. Consider adding input validation if malicious file objects appear.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 23e3222 and 02bbb0d.

📒 Files selected for processing (22)
  • examples/sites/demos/apis/file-upload.js (10 hunks)
  • examples/sites/demos/mobile/app/file-upload/accept-file-image.vue (0 hunks)
  • examples/sites/demos/mobile/app/file-upload/custom-prefix.vue (0 hunks)
  • examples/sites/demos/mobile/app/file-upload/custom-upload-request.vue (0 hunks)
  • examples/sites/demos/mobile/app/file-upload/drag-select-file.vue (0 hunks)
  • examples/sites/demos/mobile/app/file-upload/drag-upload.vue (0 hunks)
  • examples/sites/demos/mobile/app/file-upload/file-icon-list.vue (1 hunks)
  • examples/sites/demos/mobile/app/file-upload/file-title.vue (0 hunks)
  • examples/sites/demos/mobile/app/file-upload/image-size.vue (0 hunks)
  • examples/sites/demos/mobile/app/file-upload/manual-upload.vue (1 hunks)
  • examples/sites/demos/mobile/app/file-upload/prevent-delete-file.vue (3 hunks)
  • examples/sites/demos/mobile/app/file-upload/prevent-upload-file.vue (0 hunks)
  • examples/sites/demos/mobile/app/file-upload/upload-limit.vue (0 hunks)
  • examples/sites/demos/mobile/app/file-upload/webdoc/file-upload.js (1 hunks)
  • packages/mobile/components/file-upload/src/file-upload.ts (2 hunks)
  • packages/mobile/components/file-upload/src/mobile.vue (2 hunks)
  • packages/mobile/components/file-upload/src/renderless/index.ts (10 hunks)
  • packages/mobile/components/file-upload/src/renderless/vue.ts (3 hunks)
  • packages/mobile/components/upload-list/src/renderless/vue.ts (1 hunks)
  • packages/mobile/components/upload-list/src/upload-list.ts (2 hunks)
  • packages/mobile/components/upload/src/renderless/index.ts (0 hunks)
  • packages/mobile/components/upload/src/renderless/vue.ts (1 hunks)
💤 Files with no reviewable changes (10)
  • examples/sites/demos/mobile/app/file-upload/drag-upload.vue
  • examples/sites/demos/mobile/app/file-upload/file-title.vue
  • examples/sites/demos/mobile/app/file-upload/custom-upload-request.vue
  • examples/sites/demos/mobile/app/file-upload/prevent-upload-file.vue
  • examples/sites/demos/mobile/app/file-upload/accept-file-image.vue
  • examples/sites/demos/mobile/app/file-upload/upload-limit.vue
  • examples/sites/demos/mobile/app/file-upload/drag-select-file.vue
  • examples/sites/demos/mobile/app/file-upload/image-size.vue
  • packages/mobile/components/upload/src/renderless/index.ts
  • examples/sites/demos/mobile/app/file-upload/custom-prefix.vue
🧰 Additional context used
🪛 Biome (1.9.4)
packages/mobile/components/file-upload/src/renderless/index.ts

[error] 2624-2624: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)

🔇 Additional comments (56)
examples/sites/demos/mobile/app/file-upload/manual-upload.vue (1)

2-2: Removed display attribute and used header-show prop – verify potential impact

You’ve removed the display attribute from <tiny-file-upload> and retained :header-show="false". Make sure this change doesn’t introduce regressions in any other demos or usage scenarios that relied on the old display prop.

examples/sites/demos/mobile/app/file-upload/prevent-delete-file.vue (3)

8-8: Validate newly added success-statistics prop

The success-statistics prop is informative but ensure that corresponding logic exists downstream to process or track these statistics. Without handling or documentation, it might be unclear to users how to leverage this feature.


17-17: Importing TinyModal for confirmations

Good move to centralize modal usage rather than calling window.confirm. This fosters a consistent UI/UX across the app.


37-41: Changes in removal flow – confirm dialog behavior

Switching from window.confirm to TinyModal.confirm is a solid improvement. However, ensure downstream consumers handle the rejected promise appropriately, especially if any logic expects an immediate boolean return.

packages/mobile/components/upload/src/renderless/vue.ts (1)

68-70: Expanded uploadInner to reference entire uploader instance

Pointing uploadInner directly to the entire uploader broadens its scope. Verify any existing code or computed properties relying on a more granular reference still function correctly, especially if they expect a template ref. Also confirm that code referencing uploadInner.state or uploadInner.edm remains stable.

packages/mobile/components/upload-list/src/upload-list.ts (2)

28-29: Exporting the ISharedRenderlessParamHooks type is consistent and clear.
No functionality issues appear here. Good job adding back the export for shared usage in other components.


119-120: Adding the reUploadable Boolean prop for toggling re-upload functionality.
Ensure that any dependent logic in the upload list or file upload flow checks this property before showing a re-upload button or trigger.

You could add a default value (e.g., false) for clarity:

-  reUploadable: Boolean
+  reUploadable: {
+    type: Boolean,
+    default: false
+  }
✅ Verification successful

Let me gather information about the usage and dependencies of this new reUploadable prop.


Based on the search results, I can now provide a final response about the reUploadable prop and its dependencies:

The reUploadable prop is properly integrated with re-upload functionality across the codebase

The codebase shows that:

  • The prop is used to control re-upload UI elements and functionality in both mobile and PC components
  • Re-upload buttons/triggers only appear when reUploadable is true and file status is 'fail'
  • The prop is checked before removing failed files from the upload list
  • Re-upload functionality is properly wired through events and handlers

Key integrations:

  • packages/mobile/components/file-upload/src/renderless/index.ts: Checks reUploadable before removing failed files
  • packages/mobile/components/upload-list/src/mobile.vue: Conditionally renders re-upload button based on reUploadable and file status
  • packages/vue/src/upload-list/src/pc.vue: Similar conditional rendering for PC version
🏁 Scripts executed

The following scripts were executed for the analysis:

Error: No shell scripts found


Script:

#!/bin/bash
# Search for any existing usage of reUploadable prop
rg "reUploadable" -l

# Look for re-upload related UI elements or logic
rg -i "reupload" -A 3

# Check the component implementation
cat "packages/mobile/components/upload-list/src/upload-list.ts"

Length of output: 63922

packages/mobile/components/upload-list/src/renderless/vue.ts (1)

67-68: Reassigning vm to the injected uploader.
Switching from the parent to the injected uploader is valid, but ensure that vm indeed carries everything you need (constants, etc.). Verify that other references to parent in the code remain consistent.

packages/mobile/components/file-upload/src/mobile.vue (3)

14-14: Replacing direct imports with the existing vue-common references.
No issues here—this maintains consistent import practices.


23-23: Importing fileUploadProps centralizes prop definitions.
This reduces duplication and keeps prop definitions in one place.


27-27: Using the consolidated fileUploadProps.
This simplifies prop management and helps ensure consistency across different file upload components.

examples/sites/demos/mobile/app/file-upload/webdoc/file-upload.js (23)

3-4: Column and owner changes.
No functional issues. Verify whether “owner” is populated later if needed.


5-16: Added multiple-file demo configuration.
Demonstrates multiple file selection. Looks correct and consistent with the docs.


17-29: Added manual-upload demo configuration.
Showcases manual uploading with explicit auto-upload off. This is aligned with best practices.


30-43: Added header-show demo configuration.
Toggles the header, with an optional file-title customization. Straightforward usage.


44-57: Added file-icon-list demo.
Your approach for specifying icon paths is clear. No obvious issues.


58-70: Added accept-file demo.
Highlights restricting file types. This properly showcases accept usage.


71-84: Added max-file-count demo.
Implements limit and optional hiding of the button. Looks good.


85-98: Added prevent-delete-file demo.
Demonstrates how to block file deletion. The logic seems sound.


99-112: Added upload-file-list demo.
Supports toggling the file list’s visibility and enabling file downloads. Well-structured example.


113-125: Added upload-http-request demo.
Showcasing custom HTTP requests is a valuable addition. No concerns.


126-139: Added picture-card demo.
Demonstrates photo wall mode and preview. Proper usage of the list-type="picture-card" property.


140-151: Added size demo.
Defines a smaller or larger upload button. Straightforward configuration.


152-164: Added data demo.
Showcases additional upload parameters and the upload-icon usage. Clear and correct.


165-176: Added mini-mode demo.
Enables a minimal interface with straightforward toggles.


177-188: Added dynamic-disable demo.
Disables upload according to user input or conditions. Basic but effective demonstration.


189-202: Added upload-request demo for custom request headers.
No issues. Looks consistent with the rest of the upload architecture.


203-214: Added with-credentials demo.
Demonstrates cookie credential usage. This is a nice complement to the standard scenarios.


215-228: Added clear-files demo.
Exemplifies manual clearing of the file list. Straightforward usage.


229-240: Added abort-quest demo.
Showcases how to cancel an upload in progress. Good demonstration.


241-253: Added custom-trigger demo.
Slots for customizing triggers are well explained, with no issues found.


254-267: Added custom-upload-tip demo.
Leveraging tip and reUploadable to customize the re-upload flow. Great improvement.
[approve]


268-281: Added upload-events demo.
Comprehensive overview of events like preview, remove, error etc. No concerns.


282-282: No further structural changes beyond the new demos array.
Everything is wrapped properly and consistent with the new items above.

packages/mobile/components/file-upload/src/renderless/vue.ts (3)

296-296: Use optional chaining carefully for EDMS.
The optional chaining on props.edm?.upload prevents runtime errors but ensure you handle null or undefined cases for deeper nested properties inside props.edm.upload if needed.


334-334: Good practice to replace parent with vm.
This makes the code more consistent with Vue’s recommended usage of the component instance.


357-357: Injected dependency clarity.
Providing 'uploader' with vm ensures consistent injection logic. No action needed, just acknowledging this design approach.

packages/mobile/components/file-upload/src/file-upload.ts (3)

88-89: Importing $props improves maintainability.
Integrating $props from a central file can help you avoid duplicating definitions across multiple files.


90-90: Duplicate type export confirmation.
Exporting ISharedRenderlessParamHooks again might be intentional to ensure availability. Confirm it doesn’t create conflicts in the consuming modules.


191-191: Merging $props is a sensible design choice.
Spreading $props into fileUploadProps centralizes prop definitions and simplifies updates.

examples/sites/demos/apis/file-upload.js (9)

18-18: Property accept mobile demo updated.
Renaming demo references helps maintain consistency with actual usage scenarios.


74-74: Property before-remove mobile demo updated.
Good to see self-descriptive naming (e.g., 'prevent-delete-file').


89-89: Property before-upload demo alignment.
Switching to 'upload-request' clarifies the custom request demonstration.


162-162: Property display mobile demo removed.
Ensure you intentionally removed the prior 'manual-upload' reference if it’s no longer valid.


267-267: Property file-title'header-show'.
This aligns better with the newly introduced logic for toggling header visibility.


378-378: Property limit'max-file-count'.
Updated name is more descriptive and user-friendly.


403-403: Property list-type'picture-card'.
Helps unify naming schemes across demos.


651-651: Property success-statistics'prevent-delete-file'.
Check if the property’s function is truly relevant to “prevent delete” or if the name needs further refinement.


900-900: Method abort'abort-quest'.
Descriptive naming clarifies the user-facing demo, good job.

packages/mobile/components/file-upload/src/renderless/index.ts (7)

318-318: Mobile HWH5 block clarity.
The if (state.isHwh5) condition is well-placed to separate mobile logic.


338-338: Large-file fallback.
After checking file size logic, gracefully falling back to normal upload is correct.


632-632: Conditional uploading with merge services.
Ensure that the rawFiles.length condition handles empty arrays to prevent corner-case errors.


864-864: Re-upload scenario check.
Make sure re-upload logic resets all relevant file properties, such as status, percentage, and response.


1006-1006: Direct click invocation.
vm.$refs[constants.UPLOAD_INNER].handleClick() bypasses any additional checks. Confirm no extra validations are needed.


2122-2122: Delegated large-file final upload.
Resuming the upload with the large-file info is clean. Keep an eye on concurrency or partial states.


2624-2624: False positive from static analysis on assignment.
The code here is a simple function call with no assignment. You can safely ignore the lint insinuation unless there’s truly an assignment hidden in an expression.

🧰 Tools
🪛 Biome (1.9.4)

[error] 2624-2624: The assignment should not be in an expression.

The use of assignments in expressions is confusing.
Expressions are often considered as side-effect free.

(lint/suspicious/noAssignInExpressions)

@zzcr zzcr merged commit 92d4485 into dev Jan 2, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants