Skip to content

Commit

Permalink
refactor: refactor user image view with custom component
Browse files Browse the repository at this point in the history
  • Loading branch information
ShiinaKin committed Dec 6, 2024
1 parent 5f2c232 commit a20859f
Show file tree
Hide file tree
Showing 3 changed files with 584 additions and 450 deletions.
74 changes: 74 additions & 0 deletions ui/src/components/form/userField/image/ImageEditForm.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<script setup lang="ts">
import { useForm } from "vee-validate";
import { useI18n } from "vue-i18n";
import * as yup from "yup";
import VeeIftaInputText from "@/components/vee-input/VeeIftaInputText.vue";
import Button from "primevue/button";
const { t } = useI18n();
const imageRenameFormSchema = yup.object({
displayName: yup
.string()
.trim()
.test("at-least-one-field", t("myImageView.edit.dialog.form.verify.atLeastOneField"), function () {
return !!(this.parent.displayName || this.parent.description);
}),
description: yup
.string()
.trim()
.test("at-least-one-field", t("myImageView.edit.dialog.form.verify.atLeastOneField"), function () {
return !!(this.parent.displayName || this.parent.description);
})
});
const { handleSubmit } = useForm({
validationSchema: imageRenameFormSchema
});
const { imagePageVO } = defineProps(["imagePageVO"]);
const emits = defineEmits(["submit", "cancel"]);
const onSubmit = handleSubmit((values, ctx) => {
emits("submit", values, ctx);
});
const onCancel = () => {
emits("cancel");
};
</script>

<template>
<form @submit="onSubmit" class="flex flex-col gap-4 m-4 w-96">
<div class="flex flex-col gap-2.5 w-full">
<div class="flex flex-col gap-1">
<VeeIftaInputText
id="editImageDisplayName"
name="displayName"
:placeholder="imagePageVO.displayName"
:label="t('myImageView.edit.dialog.form.displayName')"
/>
</div>
<div class="flex flex-col gap-1">
<VeeIftaInputText
id="editImageDescription"
name="description"
:placeholder="imagePageVO.description"
:label="t('myImageView.edit.dialog.form.description')"
/>
</div>
</div>
<div class="flex justify-end gap-2">
<Button
type="button"
:label="t('myImageView.edit.dialog.form.cancelButton')"
severity="secondary"
@click="onCancel"
/>
<Button type="submit" :label="t('myImageView.edit.dialog.form.submitButton')" />
</div>
</form>
</template>

<style scoped></style>
156 changes: 109 additions & 47 deletions ui/src/locales/zh_cn.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,53 +76,115 @@ imageUploadView:
title: "上传列表"
uploadAllButton: "上传全部"
myImageView:
myImageFilterUploadTimeASC: "上传时间升序"
myImageFilterUploadTimeDESC: "上传时间降序"
myImageFilterFileSizeASC: "文件大小升序"
myImageFilterFileSizeDESC: "文件大小降序"
myImageFilterPublicVisible: "公开"
myImageFilterPrivateVisible: "私密"
myImageFilterAllVisible: "全部"
myImageFilterAlbumButton: "相册"
myImageFilterAlbumTitle: "相册列表"
myImageDialogImageCopySuccessMessage: "复制成功"
myImageDialogImageCopyPrivateWarningMessage: "复制失败,图片为私密图片"
myImageDialogImageDetailTitle: "图片详情"
myImageDialogImageDetailImageName: "图片名称"
myImageDialogImageDetailImageRawName: "图片原始名称"
myImageDialogImageDetailImageType: "图片类型"
myImageDialogImageDetailImageAlbumName: "所属相册"
myImageDialogImageDetailImageOwnerName: "所属用户"
myImageDialogImageDetailImageSize: "图片尺寸"
myImageDialogImageDetailImageFileSize: "图片大小"
myImageDialogImageDetailImageUploadTime: "上传时间"
myImageDialogImageDetailImageIsPublic: "是否公开"
myImageDialogImageDetailImageDesc: "图片描述"
myImageDialogImageRenameCancelButton: "取消"
myImageDialogImageRenameSubmitButton: "保存"
myImageDialogImageRenameTitle: "修改图片名称"
myImageDialogImageRenameOldImageName: "旧图片名"
myImageDialogImageRenameNewImageName: "新图片名"
myImageDialogImageRenameSuccessMessage: "重命名成功"
myImageDialogImageRenameFailedTitle: "重命名失败"
myImageDialogImageDeleteConfirmTitle: "确认删除"
myImageDialogImageDeleteConfirmWarningMainContent: "你确定要删除图片吗?"
myImageDialogImageDeleteConfirmWarningSubContent: "真的会删除,而且无法找回"
myImageDialogImageDeleteConfirmCancelButton: "取消"
myImageDialogImageDeleteConfirmSubmitButton: "确认删除"
myImageDialogImageDeleteConfirmSuccessTitle: "删除成功"
myImageDialogImageDeleteConfirmFailedTitle: "删除失败"
myImageDialogImageChangeVisibleSuccessMessage: "修改访问权限成功"
myImageDialogImageChangeVisibleFailedTitle: "修改访问权限失败"
myImageDialogImageChangeAlbumTableAlbumId: "相册ID"
myImageDialogImageChangeAlbumTableAlbumName: "相册名"
myImageDialogImageChangeAlbumTableImageCount: "图片数量"
myImageDialogImageChangeAlbumTableIsUncategorized: "是否为未分类相册"
myImageDialogImageChangeAlbumCancelButton: "取消"
myImageDialogImageChangeAlbumSubmitButton: "移动"
myImageDialogImageChangeAlbumWarningMessage: "请选择相册"
myImageDialogImageChangeAlbumSuccessMessage: "修改相册成功"
myImageDialogImageChangeAlbumFailedTitle: "修改相册失败"
filter:
image:
uploadTimeASC: "上传时间升序"
uploadTimeDESC: "上传时间降序"
fileSizeASC: "文件大小升序"
fileSizeDESC: "文件大小降序"
visible:
public: "公开"
private: "私密"
all: "全部"
album:
button: "相册"
drawer:
title: "相册列表"
contextMenu:
single:
copyImage: "复制图片"
copyLink: "复制链接"
moveToAlbum: "移动到相册"
settingAsPrivate: "设为私密"
settingAsPublic: "设为公开"
detail: "详情信息"
edit: "修改"
delete: "删除"
multi:
moveToAlbum: "移动到相册"
settingAsPrivate: "设为私密"
settingAsPublic: "设为公开"
delete: "删除"
detail:
dialog:
title: "图片详情"
name: "图片名称"
rawName: "图片原始名称"
type: "图片类型"
albumName: "所属相册"
ownerName: "所属用户"
strategyName: "所属存储策略"
strategyType: "存储策略类型"
size: "图片尺寸"
fileSize: "图片大小"
fileSizeUnit: "MB"
uploadTime: "上传时间"
isPrivate:
title: "是否公开"
true: "私密"
false: "公开"
description: "图片描述"
toast:
failedTitle: "获取图片信息失败"
edit:
dialog:
title: "修改图片"
form:
displayName: "图片名"
description: "图片描述"
cancelButton: "取消"
submitButton: "保存"
verify:
atLeastOneField: "请至少修改一个字段"
toast:
successTitle: "重命名成功"
failedTitle: "重命名失败"
copyImage:
toast:
successTitle: "复制成功"
failedTitle: "复制失败"
copyLink:
toast:
successTitle: "复制成功"
failedTitle: "复制失败, 私密图片无法复制外链"
changeVisible:
toast:
successTitle: "修改访问权限成功"
failedTitle: "修改访问权限失败"
changeAlbum:
dialog:
title: "移动到相册"
form:
table:
albumId: "相册ID"
albumName: "相册名"
imageCount: "图片数量"
isUncategorized:
title: "是否为未分类"
true: ""
false: ""
isDefault:
title: "是否默认"
true: ""
false: ""
cancelButton: "取消"
submitButton: "移动"
verify:
album:
required: "请选择相册"
toast:
successTitle: "修改相册成功"
failedTitle: "修改相册失败"
delete:
dialog:
title: "确认删除"
mainContent: "你确定要删除图片吗?"
subContent: "真的会删除,而且无法找回"
cancelButton: "取消"
submitButton: "确认删除"
toast:
successTitle: "删除成功"
failedTitle: "删除失败"
myAlbumView:
toolbar:
createButton: "创建相册"
Expand Down
Loading

0 comments on commit a20859f

Please sign in to comment.