forked from goplus/builder
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: Supports retrieving assets from scratch projects and importing …
…them into the assets list (goplus#126) * feat: Import the scratch file and get the assets * feat: ui design for upload scratch proj and render download list * fix: offline upload sprite * fix: the style of scratch list and import button position * feat: list multi check * fix: delete test infomations * feat: rename scratch assets * fix: code format * feat: Import the scratch file and get the assets * feat: ui design for upload scratch proj and render download list * fix: offline upload sprite * fix: the style of scratch list and import button position * feat: list multi check * fix: delete test infomations * feat: rename scratch assets * fix: code format * fix: change the getAssetList url and change multiselect style * feat: add comment to functions * fix: tsc about existsByName * fix: change LoadFromScratchDemo.vuename * fix: delete spxEditor LoadFromScratch demo component * fix: tsc about import route * fix: scratch.ts, file-saver * fix: remove duplicate existsByName * fix: abstract setTopFileIndex function * fix: reuse file.ts getMimeFromExt * fix: deleteLoadFromScratchDemo * fix: delete scratch.ts * fix: add parseScratchFile * delete: getMimeType --------- Co-authored-by: 姚昕玥 <[email protected]>
- Loading branch information
Showing
14 changed files
with
581 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
* @Author: Yao xinyue | ||
* @Date: 2024-01-22 11:17:08 | ||
* @LastEditors: xuning [email protected] | ||
* @LastEditTime: 2024-02-21 21:01:22 | ||
* @LastEditTime: 2024-02-29 15:14:19 | ||
* @FilePath: /builder/spx-gui/src/api/asset.ts | ||
* @Description: | ||
*/ | ||
|
@@ -36,9 +36,12 @@ export function getAssetList({ | |
isOrderByTime?: boolean | ||
isOrderByHot?: boolean | ||
}): Promise<PageAssetResponse> { | ||
let url = `/list/asset/${pageIndex}/${pageSize}/${assetType}` | ||
const params = new URLSearchParams() | ||
|
||
params.append('pageIndex', pageIndex.toString()) | ||
params.append('pageSize', pageSize.toString()) | ||
params.append('assetType', assetType.toString()) | ||
|
||
if (category) { | ||
params.append('category', category) | ||
} | ||
|
@@ -48,9 +51,8 @@ export function getAssetList({ | |
if (isOrderByHot) { | ||
params.append('isOrderByHot', '1') | ||
} | ||
if (Array.from(params).length > 0) { | ||
url += `?${params.toString()}` | ||
} | ||
|
||
const url = `/list/asset?${params.toString()}` | ||
|
||
return service({ | ||
url: url, | ||
|
@@ -158,13 +160,13 @@ export function addAssetClickCount( | |
* @param {number} assetType | ||
* @return { SearchAssetResponse } | ||
*/ | ||
export function generateGifByCostumes(name:string, files: File[]): Promise<string> { | ||
export function generateGifByCostumes(name: string, files: File[]): Promise<string> { | ||
const url = `/spirits/upload` | ||
const formData = new FormData() | ||
formData.append('name',name) | ||
formData.append('name', name) | ||
files.forEach((file) => { | ||
formData.append('files', file); | ||
}); | ||
formData.append('files', file) | ||
}) | ||
|
||
return service({ | ||
url: url, | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
/* | ||
* @Author: TuGitee [email protected] | ||
* @Date: 2024-01-19 21:53:50 | ||
* @LastEditors: Zhang Zhi Yang | ||
* @LastEditTime: 2024-02-19 09:10:03 | ||
* @LastEditors: xuning [email protected] | ||
* @LastEditTime: 2024-02-29 14:14:20 | ||
* @FilePath: /spx-gui/src/class/backdrop.ts | ||
* @Description: The class of a backdrop. | ||
*/ | ||
|
@@ -11,6 +11,7 @@ import { AssetBase } from "@/class/asset-base"; | |
import { isInstance, getAllFromLocal } from "@/util/class"; | ||
import type { RawDir } from "@/types/file"; | ||
import { useProjectStore } from "@/store/modules/project"; | ||
import FileWithUrl from "@/class/file-with-url"; | ||
|
||
/** | ||
* @class Backdrop | ||
|
@@ -84,6 +85,11 @@ export class Backdrop extends AssetBase { | |
return await getAllFromLocal(Backdrop); | ||
} | ||
|
||
setTopFileIndex (file: FileWithUrl, index: number){ | ||
this.files.splice(index, 1) | ||
this.files.unshift(file) | ||
} | ||
|
||
/** | ||
* @constructor create a new backdrop | ||
* @param {string} name the name of the backdrop | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,19 +2,19 @@ | |
* @Author: Xu Ning | ||
* @Date: 2024-01-18 17:11:19 | ||
* @LastEditors: xuning [email protected] | ||
* @LastEditTime: 2024-02-06 12:54:20 | ||
* @LastEditTime: 2024-02-29 14:15:39 | ||
* @FilePath: /builder/spx-gui/src/components/sprite-list/ImageCardCom.vue | ||
* @Description: | ||
--> | ||
<template> | ||
<div v-if="props.type === 'sprite'" :class="computedProperties.cardClassName" > | ||
<div v-if="props.type === 'sprite'" :class="computedProperties.cardClassName"> | ||
<div class="delete-button" @click="deleteSprite(props.asset.name)">×</div> | ||
<n-image | ||
preview-disabled | ||
:width="computedProperties.imageWidth" | ||
:height="computedProperties.imageHeight" | ||
:src="computedProperties.spriteUrl" | ||
fallback-src="https://07akioni.oss-cn-beijing.aliyuncs.com/07akioni.jpeg" | ||
:fallback-src="error" | ||
/> | ||
{{ props.asset.name }} | ||
</div> | ||
|
@@ -23,50 +23,54 @@ | |
v-else | ||
:key="index" | ||
:class="computedProperties.cardClassName" | ||
:style="index == 0 ? firstBackdropStyle : ''" | ||
@click="setTopFileIndex(file, index)" | ||
> | ||
<div class="delete-button" @click="deleteBackdrop(file)">×</div> | ||
<n-image | ||
preview-disabled | ||
:width="computedProperties.imageWidth" | ||
:height="computedProperties.imageHeight" | ||
:src="file.url" | ||
fallback-src="https://07akioni.oss-cn-beijing.aliyuncs.com/07akioni.jpeg" | ||
:fallback-src="error" | ||
/> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
// ----------Import required packages / components----------- | ||
import { defineProps, computed } from "vue"; | ||
import { NImage } from "naive-ui"; | ||
import { useSpriteStore } from '@/store/modules/sprite'; | ||
import { useBackdropStore } from '@/store/modules/backdrop'; | ||
import { AssetBase } from "@/class/asset-base"; | ||
import { Backdrop } from "@/class/backdrop"; | ||
import FileWithUrl from "@/class/file-with-url"; | ||
import { defineProps, computed } from 'vue' | ||
import { NImage } from 'naive-ui' | ||
import { useSpriteStore } from '@/store/modules/sprite' | ||
import { useBackdropStore } from '@/store/modules/backdrop' | ||
import { AssetBase } from '@/class/asset-base' | ||
import { Backdrop } from '@/class/backdrop' | ||
import FileWithUrl from '@/class/file-with-url' | ||
import error from '@/assets/image/library/error.svg' | ||
// ----------props & emit------------------------------------ | ||
interface PropType { | ||
type?: string; | ||
asset: AssetBase | Backdrop; | ||
type?: string | ||
asset: AssetBase | Backdrop | ||
} | ||
const props = defineProps<PropType>(); | ||
const spriteStore = useSpriteStore(); | ||
const backdropStore = useBackdropStore(); | ||
const props = defineProps<PropType>() | ||
const spriteStore = useSpriteStore() | ||
const backdropStore = useBackdropStore() | ||
const firstBackdropStyle = { 'box-shadow': '0px 0px 0px 4px #FF81A7' } | ||
// ----------computed properties----------------------------- | ||
// Computed card style/ image width/ image height/ spriteUrl/ backdropFiles by props.type. | ||
const computedProperties = computed(() => { | ||
const isBg = props.type === "bg"; | ||
const hasFiles = props.asset && props.asset.files && props.asset.files.length > 0; | ||
const isBg = props.type === 'bg' | ||
const hasFiles = props.asset && props.asset.files && props.asset.files.length > 0 | ||
return { | ||
cardClassName: isBg ? "bg-list-card" : "sprite-list-card", | ||
cardClassName: isBg ? 'bg-list-card' : 'sprite-list-card', | ||
imageWidth: isBg ? 40 : 75, | ||
imageHeight: isBg ? 40 : 75, | ||
spriteUrl: !isBg && hasFiles ? props.asset.files[0].url : "", | ||
spriteUrl: !isBg && hasFiles ? props.asset.files[0].url : '', | ||
backdropFiles: isBg && hasFiles ? props.asset.files : [] | ||
}; | ||
}); | ||
} | ||
}) | ||
// ----------methods----------------------------------------- | ||
/** | ||
|
@@ -77,7 +81,7 @@ const computedProperties = computed(() => { | |
*/ | ||
const deleteSprite = (name: string) => { | ||
spriteStore.removeItemByName(name) | ||
}; | ||
} | ||
/** | ||
* @description: A Function about deleting backdrop's file. | ||
|
@@ -87,14 +91,26 @@ const deleteSprite = (name: string) => { | |
*/ | ||
const deleteBackdrop = (file: FileWithUrl) => { | ||
backdropStore.backdrop.removeFile(file) | ||
}; | ||
} | ||
/** | ||
* @description: A Function about change backdrop' file index to top. | ||
* @param {*} file | ||
* @param {*} index | ||
* @return {*} | ||
*/ | ||
const setTopFileIndex = (file: FileWithUrl, index: number) => { | ||
if (index != 0) { | ||
backdropStore.backdrop.setTopFileIndex(file, index) | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped lang="scss"> | ||
@import "@/assets/theme.scss"; | ||
@import '@/assets/theme.scss'; | ||
@mixin listCardBase { | ||
font-family:'Heyhoo'; | ||
font-family: 'Heyhoo'; | ||
margin: 10px auto; | ||
border-radius: 20px; | ||
box-shadow: 0 0 5px $sprite-list-card-box-shadow; | ||
|
Oops, something went wrong.