Skip to content

Commit

Permalink
perf: fs-files-format 支持自定义getFileName
Browse files Browse the repository at this point in the history
  • Loading branch information
greper committed Sep 23, 2023
1 parent c17aac5 commit 994f3af
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions packages/fast-extends/src/uploader/components/fs-files-format.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</template>

<script lang="ts">
import { defineComponent, Ref, ref, watch } from "vue";
import { computed, defineComponent, Ref, ref, watch } from "vue";
import { useUi } from "@fast-crud/fast-crud";
// 文件格式化展示组件
export default defineComponent({
Expand Down Expand Up @@ -53,21 +53,28 @@ export default defineComponent({
return value;
}
},
buildUrls: {}
buildUrls: {},
// 根据value构建文件名
getFileName: {}
} as any,
setup(props: any, ctx) {
const { ui } = useUi();
function getFileName(url: string) {
if (url?.lastIndexOf("/") >= 0) {
return url.substring(url.lastIndexOf("/") + 1);
}
return url;
}
const getFileName = computed(() => {
return (
props.getFileName ||
function (value: any) {
if (url?.lastIndexOf("/") >= 0) {
return url.substring(url.lastIndexOf("/") + 1);
}
return url;
}
);
});
function getItem(value: any): any {
return {
url: undefined,
value: value,
name: getFileName(value),
name: getFileName.value(value),
color: props.color
};
}
Expand Down

0 comments on commit 994f3af

Please sign in to comment.