|
1 | 1 | <template> |
2 | 2 | <div> |
3 | | - <template v-if="projectType === 'scratch'"> |
| 3 | + <template v-if="isScratchLikeProjectType(projectType)"> |
4 | 4 | <v-card v-if="showplayer" border hover style="aspect-ratio: 4 / 3"> |
5 | 5 | <iframe |
6 | 6 | :src="embedurl" |
|
55 | 55 | import {initProject, getProjectContent} from "@/services/projectService"; |
56 | 56 | import CodeRunner from './CodeRunner.vue'; |
57 | 57 | import ExtensionDisplayContent from "../extensions/ExtensionDisplayContent.vue"; |
| 58 | +
|
| 59 | +const PLAYER_BASE_PATHS = { |
| 60 | + scratch: '/scratch', |
| 61 | + scratch3: '/scratch', |
| 62 | + 'scratch-clipcc': '/clipcc' |
| 63 | +}; |
| 64 | +
|
58 | 65 | export default { |
59 | 66 | name: 'ProjectPlayer', |
60 | 67 | components: { |
@@ -93,22 +100,34 @@ export default { |
93 | 100 | } |
94 | 101 | }, |
95 | 102 | computed: { |
| 103 | + playerBasePath() { |
| 104 | + return PLAYER_BASE_PATHS[this.projectType] || '/scratch'; |
| 105 | + }, |
96 | 106 | embedurl() { |
| 107 | + const playerFile = this.projectType === 'scratch-clipcc' ? 'player.html' : 'embed.html'; |
| 108 | + let baseUrl = `${this.playerBasePath}/${playerFile}?id=${this.projectId}&embed=true`; |
97 | 109 |
|
98 | | - let baseUrl = import.meta.env.DEV ?`http://localhost:8601/embed.html?id=${this.projectId}&embed=true` : `/scratch/embed.html?id=${this.projectId}&embed=true`; |
99 | | -
|
100 | | - if(localStorage.getItem('embedurl')){ |
101 | | - baseUrl = `${localStorage.getItem('embedurl')}/embed.html?id=${this.projectId}&embed=true`; |
| 110 | + if (this.projectType === 'scratch' || this.projectType === 'scratch3') { |
| 111 | + if (import.meta.env.DEV) { |
| 112 | + baseUrl = `http://localhost:8601/embed.html?id=${this.projectId}&embed=true`; |
| 113 | + } |
| 114 | + if (localStorage.getItem('embedurl')) { |
| 115 | + baseUrl = `${localStorage.getItem('embedurl')}/embed.html?id=${this.projectId}&embed=true`; |
| 116 | + } |
102 | 117 | } |
| 118 | +
|
103 | 119 | if (this.commitId !== 'latest') { |
104 | 120 | return `${baseUrl}&ref=${this.commitId}`; |
105 | 121 | } |
106 | 122 | return `${baseUrl}&branch=${this.branch}&ref=${this.commitId}`; |
107 | 123 | } |
108 | 124 | }, |
109 | 125 | methods: { |
| 126 | + isScratchLikeProjectType(type) { |
| 127 | + return ['scratch', 'scratch3', 'scratch-clipcc'].includes(type); |
| 128 | + }, |
110 | 129 | async loadProjectContent() { |
111 | | - if (!this.showplayer || this.projectType === 'scratch') { |
| 130 | + if (!this.showplayer || this.isScratchLikeProjectType(this.projectType)) { |
112 | 131 | return; |
113 | 132 | } |
114 | 133 |
|
|
0 commit comments