Skip to content

Commit

Permalink
feat: 优化预览界面加载
Browse files Browse the repository at this point in the history
  • Loading branch information
xream committed Feb 12, 2025
1 parent 7dff523 commit 95e357e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sub-store-front-end",
"version": "2.14.335",
"version": "2.14.336",
"private": true,
"scripts": {
"dev": "vite --host",
Expand Down
11 changes: 7 additions & 4 deletions src/views/FilePreview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,18 @@ const processedData = ref('')
watchEffect(async () => {
if (url) {
try {
cmStore.setEditCode('filePreview', 'Loading...')
const response = await axios.get(url as string, {
responseType: 'text',
transformResponse: [(data) => data],
})
console.log(typeof response.data)
processedData.value = response.data
cmStore.setEditCode('filePreview', processedData.value)
cmStore.setEditCode('filePreview', processedData.value || '')
} catch (error) {
console.error('Error fetching URL:', error)
cmStore.setEditCode('filePreview', `Error: ${error.message}`)
showNotify({ title: `加载失败: ${error.message}` })
}
}
if (route.query.name) {
Expand All @@ -114,9 +117,9 @@ const displayName = computed(() => {
});
const originalData = previewData?.original;
if(!url) processedData.value = previewData?.processed;
// cmStore.setCmCode(processedData)
cmStore.setEditCode('filePreview',processedData.value )
if(!url) {
cmStore.setEditCode('filePreview', previewData?.processed)
}
const clickClose = () => {
Expand Down

0 comments on commit 95e357e

Please sign in to comment.