Skip to content
This repository was archived by the owner on Apr 11, 2026. It is now read-only.

Commit e144e7f

Browse files
committed
feat: 添加对 Scratch (ClipCC) 项目的支持,更新相关组件和逻辑
1 parent 1d60af2 commit e144e7f

8 files changed

Lines changed: 46 additions & 17 deletions

File tree

src/components/posts/PostEmbed.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,14 +368,15 @@ const isSelf = computed(() => {
368368
// Computed properties
369369
const isScratchProject = computed(() => {
370370
const type = projectData.value?.type || "scratch";
371-
return type === "scratch" || type === "scratch3";
371+
return ["scratch", "scratch3", "scratch-clipcc"].includes(type);
372372
});
373373
374374
const projectTypeLabel = computed(() => {
375375
const type = projectData.value?.type || "scratch";
376376
const labels = {
377377
scratch: "Scratch 作品",
378378
scratch3: "Scratch 作品",
379+
"scratch-clipcc": "Scratch (ClipCC) 作品",
379380
"scratch-extension": "扩展",
380381
python: "Python",
381382
javascript: "JavaScript",

src/components/project/NewProjectDialog.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<v-col cols="12" sm="6">
1616
<v-select
1717
v-model="projectinfo.type"
18-
:items="['scratch', 'python', 'text']"
18+
:items="['scratch', 'scratch-clipcc', 'python', 'text']"
1919
hint="选择一个"
2020
label="类型"
2121
required

src/components/project/ProjectInfoCard.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,14 @@
104104
<!-- Editor buttons (full only) -->
105105
<div v-if="variant === 'full'" class="project-info__actions">
106106
<v-btn
107-
v-if="project.type === 'scratch'"
107+
v-if="['scratch', 'scratch3', 'scratch-clipcc'].includes(project.type)"
108108
variant="tonal"
109109
rounded="lg"
110110
class="text-none"
111111
append-icon="mdi-open-in-new"
112112
@click="openEditor(project.id, project.type)"
113113
>
114-
Scratch 编辑器
114+
{{ project.type === 'scratch-clipcc' ? 'ClipCC 编辑器' : 'Scratch 编辑器' }}
115115
</v-btn>
116116
<v-btn
117117
:to="`/${username}/${projectname}/edit`"

src/components/project/ProjectPlayer.vue

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div>
3-
<template v-if="projectType === 'scratch'">
3+
<template v-if="isScratchLikeProjectType(projectType)">
44
<v-card v-if="showplayer" border hover style="aspect-ratio: 4 / 3">
55
<iframe
66
:src="embedurl"
@@ -55,6 +55,13 @@
5555
import {initProject, getProjectContent} from "@/services/projectService";
5656
import CodeRunner from './CodeRunner.vue';
5757
import ExtensionDisplayContent from "../extensions/ExtensionDisplayContent.vue";
58+
59+
const PLAYER_BASE_PATHS = {
60+
scratch: '/scratch',
61+
scratch3: '/scratch',
62+
'scratch-clipcc': '/clipcc'
63+
};
64+
5865
export default {
5966
name: 'ProjectPlayer',
6067
components: {
@@ -93,22 +100,34 @@ export default {
93100
}
94101
},
95102
computed: {
103+
playerBasePath() {
104+
return PLAYER_BASE_PATHS[this.projectType] || '/scratch';
105+
},
96106
embedurl() {
107+
const playerFile = this.projectType === 'scratch-clipcc' ? 'player.html' : 'embed.html';
108+
let baseUrl = `${this.playerBasePath}/${playerFile}?id=${this.projectId}&embed=true`;
97109
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+
}
102117
}
118+
103119
if (this.commitId !== 'latest') {
104120
return `${baseUrl}&ref=${this.commitId}`;
105121
}
106122
return `${baseUrl}&branch=${this.branch}&ref=${this.commitId}`;
107123
}
108124
},
109125
methods: {
126+
isScratchLikeProjectType(type) {
127+
return ['scratch', 'scratch3', 'scratch-clipcc'].includes(type);
128+
},
110129
async loadProjectContent() {
111-
if (!this.showplayer || this.projectType === 'scratch') {
130+
if (!this.showplayer || this.isScratchLikeProjectType(this.projectType)) {
112131
return;
113132
}
114133

src/constants/special_languages.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ scratch: {
55
description: "图形化编程语言",
66
icon: "mdi-puzzle",
77
},
8+
"scratch-clipcc": {
9+
name: "Scratch (ClipCC)",
10+
extension: "sb3",
11+
description: "使用 ClipCC 编辑器与播放器",
12+
icon: "mdi-puzzle-check",
13+
},
814
"scratch-extension": {
915
name: "Scratch扩展",
1016
extension: "js",

src/pages/app/explore/index.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ const DEFAULT_SEARCH = Object.freeze({
195195
196196
const TYPE_PRESET_KEYS = [
197197
"scratch",
198+
"scratch-clipcc",
198199
"scratch-extension",
199200
"python",
200201
"javascript",

src/pages/app/project.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@
144144
<v-col cols="12" sm="6">
145145
<v-select
146146
v-model="currentProject.type"
147-
:items="['scratch', 'python', 'text']"
147+
:items="['scratch', 'scratch-clipcc', 'python', 'text']"
148148
hint="不建议你改"
149149
label="类型"
150150
required
@@ -266,6 +266,7 @@ export default {
266266
typeitems: [
267267
{name: "所有", type: ""},
268268
{name: "Scratch", type: "scratch"},
269+
{name: "Scratch (ClipCC)", type: "scratch-clipcc"},
269270
{name: "Python", type: "python"},
270271
],
271272
orderitems: [

src/stores/openEdit.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
export default function open(id, type, username, projectname) {
2-
if (type == "scratch") {
2+
if (type == "scratch" || type == "scratch3") {
3+
let editorUrl = "/scratch/editor.html?id=" + id;
34
if (localStorage.getItem("embedurl")) {
4-
window.open(
5-
localStorage.getItem("embedurl") + "/editor.html?id=" + id
6-
);
7-
} else {
8-
window.open("/scratch/editor.html?id=" + id);
5+
editorUrl = localStorage.getItem("embedurl") + "/editor.html?id=" + id;
96
}
7+
window.open(editorUrl);
8+
}
9+
if (type == "scratch-clipcc") {
10+
window.open("/clipcc/editor.html?id=" + id);
1011
}
1112
if (type == "python") {
1213
window.open("/python/edit.html?id=" + id);

0 commit comments

Comments
 (0)