Skip to content

Commit edd1cb0

Browse files
committed
Update permissions and image upload API usage
1 parent 198cab2 commit edd1cb0

3 files changed

Lines changed: 9 additions & 17 deletions

File tree

ui/src/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,14 @@ export default definePlugin({
6363
{
6464
priority: 21,
6565
component: markRaw(VDropdownDivider),
66+
permissions: ['*'],
6667
},
6768
{
6869
priority: 22,
6970
component: markRaw(VDropdownItem),
7071
label: '转换',
7172
visible: true,
73+
permissions: ['*'],
7274
children: [
7375
{
7476
priority: 0,
@@ -110,6 +112,7 @@ export default definePlugin({
110112
loader: () => import('./components/PostExportDropdownItem.vue'),
111113
loadingComponent: h(VDropdownItem, { disabled: true }, '加载中'),
112114
}),
115+
permissions: ['*'],
113116
props: {
114117
post: post,
115118
},
@@ -119,7 +122,7 @@ export default definePlugin({
119122
component: markRaw(VDropdownItem),
120123
label: '复制文章内容',
121124
visible: true,
122-
permissions: ['system:posts:view'],
125+
permissions: ['*'],
123126
children: [
124127
{
125128
priority: 0,
@@ -149,6 +152,7 @@ export default definePlugin({
149152
},
150153
{
151154
priority: 25,
155+
permissions: ['*'],
152156
component: defineAsyncComponent({
153157
loader: () => import('./components/PostCloneDropdownItem.vue'),
154158
loadingComponent: h(VDropdownItem, { disabled: true }, '加载中'),

ui/src/views/tabs/MarkdownImport.vue

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,7 @@ import { extractImageReferences, isImageFile } from '@/utils/image';
44
import { convertPostContentToHTML } from '@/utils/markdown';
55
import { readMatter } from '@/utils/matter';
66
import { getTagNamesByDisplayNames } from '@/utils/tag';
7-
import {
8-
consoleApiClient,
9-
ucApiClient,
10-
type Attachment,
11-
type PostRequest,
12-
} from '@halo-dev/api-client';
7+
import { consoleApiClient, type Attachment, type PostRequest } from '@halo-dev/api-client';
138
import {
149
VAlert,
1510
VButton,
@@ -158,9 +153,8 @@ function findMatchingImageFile(imagePath: string): File | undefined {
158153
async function uploadImageFile(imageFile: File): Promise<Attachment> {
159154
try {
160155
const imageBlob = await imageFile.arrayBuffer();
161-
const { data } = await ucApiClient.storage.attachment.createAttachmentForPost({
156+
const { data } = await consoleApiClient.storage.attachment.uploadAttachmentForConsole({
162157
file: new File([imageBlob], imageFile.name, { type: imageFile.type }),
163-
waitForPermalink: true,
164158
});
165159
166160
return data;

ui/src/views/tabs/WordImport.vue

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
<script lang="ts" setup>
22
import turndownService from '@/utils/turndown';
3-
import {
4-
consoleApiClient,
5-
ucApiClient,
6-
type Attachment,
7-
type PostRequest,
8-
} from '@halo-dev/api-client';
3+
import { consoleApiClient, type Attachment, type PostRequest } from '@halo-dev/api-client';
94
import {
105
VAlert,
116
VButton,
@@ -127,9 +122,8 @@ async function uploadImageBuffer(imageBuffer: ArrayBuffer, filename: string): Pr
127122
const blob = new Blob([imageBuffer]);
128123
const file = new File([blob], filename, { type: 'image/png' });
129124
130-
const { data } = await ucApiClient.storage.attachment.createAttachmentForPost({
125+
const { data } = await consoleApiClient.storage.attachment.uploadAttachmentForConsole({
131126
file: file,
132-
waitForPermalink: true,
133127
});
134128
135129
return data;

0 commit comments

Comments
 (0)