Skip to content

Commit

Permalink
v1.1.0
Browse files Browse the repository at this point in the history
1. 修复删除图片时,缓存导致的图片显示问题;
2. 修复图库无法使用图床附件的问题;
3. 更新依赖库版本;
4. Imgtp图床支持;
  • Loading branch information
liuyiwuqing committed Jul 3, 2024
1 parent 2946f45 commit 9e6d550
Show file tree
Hide file tree
Showing 11 changed files with 102 additions and 62 deletions.
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id 'java'
id "com.github.node-gradle.node" version "5.0.0"
id "com.github.node-gradle.node" version "7.0.2"
id "io.freefair.lombok" version "8.0.1"
id "run.halo.plugin.devtools" version "0.0.9"
}
Expand All @@ -16,11 +16,11 @@ repositories {
}

dependencies {
implementation platform('run.halo.tools.platform:plugin:2.16.0-SNAPSHOT')
implementation platform('run.halo.tools.platform:plugin:2.17.0-SNAPSHOT')
compileOnly 'run.halo.app:api'

testImplementation 'run.halo.app:api'
implementation 'cn.hutool:hutool-all:5.8.16'
implementation 'cn.hutool:hutool-all:5.8.25'

}

Expand Down Expand Up @@ -53,6 +53,6 @@ build {
}

halo {
version = '2.16.2'
version = '2.17.0'
debug = true
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=1.0.3
version=1.1.0
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,15 @@ private Mono<LskyProResponseRecord> req(String path, Map<String, Object> paramMa

WebClient WEB_CLIENT =
WebClient.builder()
.defaultHeader(HttpHeaders.CACHE_CONTROL, "no-cache")
.defaultHeader(HttpHeaders.PRAGMA, "no-cache")
.defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
.defaultHeader("Authorization", "Bearer " + authorization).build();

switch (path) {
case "albums":
case "images":
paramMap.put("timestamp", System.currentTimeMillis());
return WEB_CLIENT.get()
.uri(url + path + "?" + HttpUtil.toParams(paramMap))
.retrieve()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,15 @@ private Mono<SmmsResponseRecord> req(String path, Map<String, Object> paramMap)

WebClient WEB_CLIENT =
WebClient.builder()
.defaultHeader(HttpHeaders.CACHE_CONTROL, "no-cache")
.defaultHeader(HttpHeaders.PRAGMA, "no-cache")
.defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA_VALUE)
.defaultHeader("Authorization", "Basic " + authorization).build();

if (StrUtil.startWithAny(path, "upload_history", "delete/")) {
if (StrUtil.startWithAny(path, "upload_history")) {
path = path + "&timestamp=" + System.currentTimeMillis();
}
return WEB_CLIENT.get()
.uri(url + path)
.retrieve()
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
name: PictureBed
spec:
enabled: true
requires: ">=2.16.0"
requires: ">=2.17.0"
author:
name: lywq
website: https://blog.muyin.site
Expand Down
16 changes: 8 additions & 8 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore"
},
"dependencies": {
"@halo-dev/api-client": "^2.17.0",
"@halo-dev/components": "^2.17.0",
"@halo-dev/console-shared": "^2.17.0",
"@material-tailwind/html": "^2.2.2",
"@tanstack/vue-query": "^5.29.0",
"@uppy/core": "^3.11.3",
"@vueuse/core": "^10.3.0",
"pretty-bytes": "^6.0.0",
"axios": "^1.6.8",
"path-browserify": "^1.0.1",
"@material-tailwind/html": "^2.2.2",
"@halo-dev/api-client": "^2.16.0",
"@halo-dev/components": "^2.16.0",
"@halo-dev/console-shared": "^2.16.0",
"@tanstack/vue-query": "^5.29.0",
"axios": "^1.5.0",
"pretty-bytes": "^6.0.0",
"vue": "^3.3.12"
},
"devDependencies": {
"@halo-dev/ui-plugin-bundler-kit": "^1.0.0",
"@halo-dev/ui-plugin-bundler-kit": "^2.17.0",
"@iconify/json": "^2.2.159",
"@rushstack/eslint-patch": "^1.6.1",
"@types/canvas-confetti": "^1.6.4",
Expand Down
31 changes: 22 additions & 9 deletions ui/src/components/ImgtpSelectorProvider.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {matchMediaTypes} from "@/utils/media-type";
import LazyImage from "@/components/image/LazyImage.vue";
import type {Album, Image, PageResult} from "@/types";
import {useQuery} from "@tanstack/vue-query";
import apiClient from "@/utils/api-client";
import {axiosInstance} from "@halo-dev/api-client";
import ImageDetailModal from "@/components/image/ImageDetailModal.vue";
import ImageUploadModal from "@/components/image/ImageUploadModal.vue";
Expand All @@ -45,6 +45,7 @@ const emit = defineEmits<{
}>();
const selectedImages = ref<Set<Image>>(new Set());
const deletedImageIds = ref<Set<string>>(new Set());
const selectedAlbum = ref<Album>();
const selectedImage = ref<Image | undefined>();
const checkedAll = ref(false);
Expand All @@ -65,11 +66,10 @@ const {
data: imageList,
refetch,
} = useQuery({
// queryKey: [`imageList_${picturebedType}`, selectedAlbum, page, size, keyword],
queryKey: [selectedAlbum, page, size, keyword],
queryKey: [`imageList_${picturebedType}`, selectedAlbum, page, size, keyword],
queryFn: async () => {
isLoading.value = true;
const {data} = await apiClient.get<PageResult<Image>>(
const {data} = await axiosInstance.get<PageResult<Image>>(
"/apis/picturebed.muyin.site/v1alpha1/images",
{
params: {
Expand All @@ -85,7 +85,13 @@ const {
page.value = data.page;
size.value = data.size;
isLoading.value = false;
return data.list;
// 过滤已删除的图片
const images = data.list.filter((image) => {
return !deletedImageIds.value.has(image.id);
});
return images;
},
// keepPreviousData: true,
enabled: true,
Expand Down Expand Up @@ -118,7 +124,7 @@ const isDisabled = (image: Image) => {
const deleteSelected = async () => {
const selected = Array.from(selectedImages.value);
selected.forEach((image) => {
apiClient.get(
axiosInstance.get(
"/apis/picturebed.muyin.site/v1alpha1/deleteImage",
{
params: {
Expand All @@ -127,6 +133,7 @@ const deleteSelected = async () => {
},
}
);
deletedImageIds.value.add(image.id);
});
selectedImages.value.clear();
await refetch();
Expand All @@ -150,9 +157,15 @@ const handleOpenDetail = (image: Image) => {
watchEffect(() => {
const images = Array.from(selectedImages.value).map((image) => {
return {
url: image.url,
type: image.mediaType as string,
};
spec: {
displayName: image.name,
mediaType: image.mediaType,
size: image.size,
},
status: {
permalink: image.url,
}
}
});
emit("update:selected", images);
});
Expand Down
44 changes: 29 additions & 15 deletions ui/src/components/LskySelectorProvider.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {matchMediaTypes} from "@/utils/media-type";
import LazyImage from "@/components/image/LazyImage.vue";
import type {Album, Image, PageResult} from "@/types";
import {useQuery} from "@tanstack/vue-query";
import apiClient from "@/utils/api-client";
import {axiosInstance} from "@halo-dev/api-client";
import ImageDetailModal from "@/components/image/ImageDetailModal.vue";
import ImageUploadModal from "@/components/image/ImageUploadModal.vue";
Expand All @@ -45,6 +45,7 @@ const emit = defineEmits<{
}>();
const selectedImages = ref<Set<Image>>(new Set());
const deletedImageIds = ref<Set<string>>(new Set());
const selectedAlbum = ref<Album>();
const selectedImage = ref<Image | undefined>();
const checkedAll = ref(false);
Expand All @@ -56,19 +57,19 @@ const page = ref(1);
const size = ref(40);
const keyword = ref("");
const totalLabel = ref("");
const albumListIsLoading = ref(false);
const isLoading = ref(false);
const picturebedType = "lsky";
// 相册列表
const {
let {
data: albumList,
isLoading: albumListIsLoading,
} = useQuery({
// queryKey: [`albumList_${picturebedType}`, page, size, keyword],
queryKey: [page, size, keyword],
queryKey: [`albumList_${picturebedType}`, page, size, keyword],
queryFn: async () => {
const {data} = await apiClient.get<Album[]>(
albumListIsLoading.value = true;
const {data} = await axiosInstance.get<Album[]>(
"/apis/picturebed.muyin.site/v1alpha1/albums",
{
params: {
Expand All @@ -86,20 +87,20 @@ const {
}];
albums.push(...data);
selectedAlbum.value = albums[0];
albumListIsLoading.value = false;
return albums;
},
});
// 图片列表
const {
let {
data: imageList,
refetch,
} = useQuery({
// queryKey: [`imageList_${picturebedType}`, selectedAlbum, page, size, keyword],
queryKey: [selectedAlbum, page, size, keyword],
queryKey: [`imageList_${picturebedType}`, selectedAlbum, page, size, keyword],
queryFn: async () => {
isLoading.value = true;
const {data} = await apiClient.get<PageResult<Image>>(
const {data} = await axiosInstance.get<PageResult<Image>>(
"/apis/picturebed.muyin.site/v1alpha1/images",
{
params: {
Expand All @@ -117,7 +118,13 @@ const {
page.value = data.page;
size.value = data.size;
isLoading.value = false;
return data.list;
// 过滤已删除的图片
const images = data.list.filter((image) => {
return !deletedImageIds.value.has(image.id);
});
return images;
},
// keepPreviousData: true,
enabled: computed(() => selectedAlbum.value !== undefined),
Expand Down Expand Up @@ -158,7 +165,7 @@ const isDisabled = (image: Image) => {
const deleteSelected = async () => {
const selected = Array.from(selectedImages.value);
selected.forEach((image) => {
apiClient.get(
axiosInstance.get(
"/apis/picturebed.muyin.site/v1alpha1/deleteImage",
{
params: {
Expand All @@ -167,6 +174,7 @@ const deleteSelected = async () => {
},
}
);
deletedImageIds.value.add(image.id);
});
selectedImages.value.clear();
await refetch();
Expand All @@ -190,9 +198,15 @@ const handleOpenDetail = (image: Image) => {
watchEffect(() => {
const images = Array.from(selectedImages.value).map((image) => {
return {
url: image.url,
type: image.mediaType as string,
};
spec: {
displayName: image.name,
mediaType: image.mediaType,
size: image.size,
},
status: {
permalink: image.url,
}
}
});
emit("update:selected", images);
});
Expand Down
31 changes: 22 additions & 9 deletions ui/src/components/SmmsSelectorProvider.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {matchMediaTypes} from "@/utils/media-type";
import LazyImage from "@/components/image/LazyImage.vue";
import type {Album, Image, PageResult} from "@/types";
import {useQuery} from "@tanstack/vue-query";
import apiClient from "@/utils/api-client";
import {axiosInstance} from "@halo-dev/api-client";
import ImageDetailModal from "@/components/image/ImageDetailModal.vue";
import ImageUploadModal from "@/components/image/ImageUploadModal.vue";
Expand All @@ -45,6 +45,7 @@ const emit = defineEmits<{
}>();
const selectedImages = ref<Set<Image>>(new Set());
const deletedImageIds = ref<Set<string>>(new Set());
const selectedAlbum = ref<Album>();
const selectedImage = ref<Image | undefined>();
const checkedAll = ref(false);
Expand All @@ -65,11 +66,10 @@ const {
data: imageList,
refetch,
} = useQuery({
// queryKey: [`imageList_${picturebedType}`, selectedAlbum, page, size, keyword],
queryKey: [selectedAlbum, page, size, keyword],
queryKey: [`imageList_${picturebedType}`, selectedAlbum, page, size, keyword],
queryFn: async () => {
isLoading.value = true;
const {data} = await apiClient.get<PageResult<Image>>(
const {data} = await axiosInstance.get<PageResult<Image>>(
"/apis/picturebed.muyin.site/v1alpha1/images",
{
params: {
Expand All @@ -85,7 +85,13 @@ const {
page.value = data.page;
size.value = data.size;
isLoading.value = false;
return data.list;
// 过滤已删除的图片
const images = data.list.filter((image) => {
return !deletedImageIds.value.has(image.id);
});
return images;
},
// keepPreviousData: true,
enabled: true,
Expand Down Expand Up @@ -118,7 +124,7 @@ const isDisabled = (image: Image) => {
const deleteSelected = async () => {
const selected = Array.from(selectedImages.value);
selected.forEach((image) => {
apiClient.get(
axiosInstance.get(
"/apis/picturebed.muyin.site/v1alpha1/deleteImage",
{
params: {
Expand All @@ -127,6 +133,7 @@ const deleteSelected = async () => {
},
}
);
deletedImageIds.value.add(image.id);
});
selectedImages.value.clear();
await refetch();
Expand All @@ -150,9 +157,15 @@ const handleOpenDetail = (image: Image) => {
watchEffect(() => {
const images = Array.from(selectedImages.value).map((image) => {
return {
url: image.url,
type: image.mediaType as string,
};
spec: {
displayName: image.name,
mediaType: image.mediaType,
size: image.size,
},
status: {
permalink: image.url,
}
}
});
emit("update:selected", images);
});
Expand Down
8 changes: 0 additions & 8 deletions ui/src/utils/api-client.ts

This file was deleted.

Loading

0 comments on commit 9e6d550

Please sign in to comment.