@2kog/kacha 0.0.0-stage → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +57 -2
- package/bin/init-project.js +63 -0
- package/bin/kacha.js +51 -0
- package/index.html +5 -0
- package/package.json +45 -4
- package/server/asset-directories.js +65 -0
- package/server/asset-watch.js +35 -0
- package/server/character-assets.js +399 -0
- package/server/image-assets.js +652 -0
- package/server/index.js +15 -0
- package/server/project-brand.js +56 -0
- package/server/project-paths.js +4 -0
- package/server/project-settings.js +55 -0
- package/src/App.vue +34 -0
- package/src/assets/css/workbench.css +272 -0
- package/src/assets/img/rabbit-mark.svg +1 -0
- package/src/components/AssetDeleteButton.vue +53 -0
- package/src/components/AssetHistory.vue +40 -0
- package/src/components/AssetStoryEditor.vue +32 -0
- package/src/components/AssetTagInput.vue +26 -0
- package/src/components/ProjectMarkdown.vue +33 -0
- package/src/i18n/en.json +163 -0
- package/src/i18n/index.js +40 -0
- package/src/layouts/WorkbenchLayout.vue +61 -0
- package/src/main.js +7 -0
- package/src/router/index.js +38 -0
- package/src/service/assets.js +13 -0
- package/src/service/project-markdown.js +26 -0
- package/src/views/assets/AudioAssets.vue +325 -0
- package/src/views/assets/CharacterAssets.vue +412 -0
- package/src/views/assets/ImageAssets.vue +456 -0
- package/src/views/settings/ProjectSettings.vue +80 -0
- package/templates/project/AGENTS.md +14 -0
- package/templates/project/README.md +7 -0
- package/templates/project/assets/audio/README.md +5 -0
- package/templates/project/assets/characters/README.md +5 -0
- package/templates/project/assets/other/README.md +3 -0
- package/templates/project/assets/props/README.md +3 -0
- package/templates/project/assets/scenes/README.md +3 -0
- package/vite.config.js +10 -0
package/src/i18n/en.json
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
{
|
|
2
|
+
"语言": "Language",
|
|
3
|
+
"制作工作台": "Production Workbench",
|
|
4
|
+
"制作项目": "Production Project",
|
|
5
|
+
"工作台": "Workbench",
|
|
6
|
+
"设定": "Settings",
|
|
7
|
+
"资产": "Assets",
|
|
8
|
+
"项目设定": "Project Settings",
|
|
9
|
+
"navigation.项目设定": "Project",
|
|
10
|
+
"角色": "Characters",
|
|
11
|
+
"场景": "Scenes",
|
|
12
|
+
"道具": "Props",
|
|
13
|
+
"其他": "Other",
|
|
14
|
+
"音频": "Audio",
|
|
15
|
+
"项目设定目录": "Project Settings Index",
|
|
16
|
+
"故事设定": "Story Settings",
|
|
17
|
+
"世界观与角色": "Worldbuilding and Characters",
|
|
18
|
+
"美术设定": "Art Direction",
|
|
19
|
+
"角色美术": "Character Art",
|
|
20
|
+
"场景与空间": "Scenes and Spaces",
|
|
21
|
+
"道具美术": "Prop Art",
|
|
22
|
+
"生成与制作": "Generation and Production",
|
|
23
|
+
"3D 电影 CG 风格": "Cinematic 3D CG Style",
|
|
24
|
+
"分镜与视频生成": "Storyboards and Video Generation",
|
|
25
|
+
"角色原画与三视图": "Character Art and Turnarounds",
|
|
26
|
+
"无法读取项目设定目录": "Unable to load the project settings index",
|
|
27
|
+
"无法读取 {file}": "Unable to read {file}",
|
|
28
|
+
"取消": "Cancel",
|
|
29
|
+
"保存": "Save",
|
|
30
|
+
"编辑": "Edit",
|
|
31
|
+
"删除": "Delete",
|
|
32
|
+
"将永久删除「{name}」的整个文件夹,包括历史版本。": "Permanently delete the entire folder for “{name}”, including its version history?",
|
|
33
|
+
"确认删除": "Confirm Deletion",
|
|
34
|
+
"2D 图": "2D Image",
|
|
35
|
+
"3D 图": "3D Image",
|
|
36
|
+
"音色": "Voice",
|
|
37
|
+
"概览": "Overview",
|
|
38
|
+
"特写": "Close-ups",
|
|
39
|
+
"皮肤": "Skins",
|
|
40
|
+
"历史版本": "Version History",
|
|
41
|
+
"素材超过 60 MB": "The asset exceeds 60 MB",
|
|
42
|
+
"读取素材失败": "Unable to read the asset",
|
|
43
|
+
"角色资产": "Character Assets",
|
|
44
|
+
"{count} 个角色": "Characters: {count}",
|
|
45
|
+
"新建角色": "New Character",
|
|
46
|
+
"搜索名称或标签": "Search by name or tag",
|
|
47
|
+
"音色缺失": "Missing voice",
|
|
48
|
+
"切换全部角色封面图": "Switch all character covers",
|
|
49
|
+
"封面图": "Cover",
|
|
50
|
+
"按标签筛选": "Filter by tag",
|
|
51
|
+
"全部": "All",
|
|
52
|
+
"没有匹配的角色": "No matching characters",
|
|
53
|
+
"查看 {name}": "View {name}",
|
|
54
|
+
"{name} 图片预览": "Image preview for {name}",
|
|
55
|
+
"已配置": "Available",
|
|
56
|
+
"待补充": "Missing",
|
|
57
|
+
"关闭": "Close",
|
|
58
|
+
"角色名": "Character Name",
|
|
59
|
+
"创建角色": "Create Character",
|
|
60
|
+
"名称": "Name",
|
|
61
|
+
"标签": "Tags",
|
|
62
|
+
"备注": "Notes",
|
|
63
|
+
"写点笔记…": "Add a note…",
|
|
64
|
+
"皮肤图片": "Skin Images",
|
|
65
|
+
"角色特写图片": "Character Close-ups",
|
|
66
|
+
"生成词": "Generation Prompt",
|
|
67
|
+
"暂无特写": "No close-ups yet",
|
|
68
|
+
"暂无皮肤": "No skins yet",
|
|
69
|
+
"还没有角色设定。": "No character profile yet.",
|
|
70
|
+
"{label}生成词": "{label} Prompt",
|
|
71
|
+
"下载 GLB 模型": "Download GLB Model",
|
|
72
|
+
"待补{label}": "Missing {label}",
|
|
73
|
+
"主图": "Main Image",
|
|
74
|
+
"替换{label}": "Replace {label}",
|
|
75
|
+
"上传{label}": "Upload {label}",
|
|
76
|
+
"当前主图": "Current Main Image",
|
|
77
|
+
"设为主图": "Set as Main Image",
|
|
78
|
+
"编辑生成词": "Edit Prompt",
|
|
79
|
+
"添加生成词": "Add Prompt",
|
|
80
|
+
"保存生成词": "Save Prompt",
|
|
81
|
+
"输入后按空格或回车": "Type a tag, then press Space or Enter",
|
|
82
|
+
"还没有归档版本。": "No archived versions yet.",
|
|
83
|
+
"目录创建时间": "Folder Creation Time",
|
|
84
|
+
"归档时间": "Archive Time",
|
|
85
|
+
"扩展": "Additional Images",
|
|
86
|
+
"说明": "Description",
|
|
87
|
+
"道具说明": "Prop Description",
|
|
88
|
+
"场景说明": "Scene Description",
|
|
89
|
+
"请选择 30 MB 以内的图片": "Choose an image up to 30 MB",
|
|
90
|
+
"读取图片失败": "Unable to read the image",
|
|
91
|
+
"道具资产": "Prop Assets",
|
|
92
|
+
"场景资产": "Scene Assets",
|
|
93
|
+
"其他资产": "Other Assets",
|
|
94
|
+
"{count} 个道具": "Props: {count}",
|
|
95
|
+
"{count} 个场景": "Scenes: {count}",
|
|
96
|
+
"{count} 个其他": "Other assets: {count}",
|
|
97
|
+
"新建道具": "New Prop",
|
|
98
|
+
"新建场景": "New Scene",
|
|
99
|
+
"新建其他": "New Asset",
|
|
100
|
+
"没有匹配的道具": "No matching props",
|
|
101
|
+
"没有匹配的场景": "No matching scenes",
|
|
102
|
+
"没有匹配的其他": "No matching assets",
|
|
103
|
+
"待补主图": "Missing Main Image",
|
|
104
|
+
"{count} 张图": "Images: {count}",
|
|
105
|
+
"候选封面": "Candidate Cover",
|
|
106
|
+
"道具名": "Prop Name",
|
|
107
|
+
"场景名": "Scene Name",
|
|
108
|
+
"其他名": "Asset Name",
|
|
109
|
+
"创建道具": "Create Prop",
|
|
110
|
+
"创建场景": "Create Scene",
|
|
111
|
+
"创建其他": "Create Asset",
|
|
112
|
+
"扩展图片": "Additional Images",
|
|
113
|
+
"{category}图片": "{category} Images",
|
|
114
|
+
"图片名称": "Image Name",
|
|
115
|
+
"分类": "Category",
|
|
116
|
+
"采用状态": "Status",
|
|
117
|
+
"选择图片": "Choose Image",
|
|
118
|
+
"{category}(选填)": "{category} (optional)",
|
|
119
|
+
"保存图片": "Save Image",
|
|
120
|
+
"保存资料": "Save Details",
|
|
121
|
+
"找不到图片文件 {file}": "Image file not found: {file}",
|
|
122
|
+
"替换主图": "Replace Main Image",
|
|
123
|
+
"上传主图": "Upload Main Image",
|
|
124
|
+
"图片生成词": "Image Prompt",
|
|
125
|
+
"暂无图片": "No images yet",
|
|
126
|
+
"还没有说明。": "No description yet.",
|
|
127
|
+
"还没有道具说明。": "No prop description yet.",
|
|
128
|
+
"还没有场景说明。": "No scene description yet.",
|
|
129
|
+
"音乐": "Music",
|
|
130
|
+
"音效": "Sound Effects",
|
|
131
|
+
"台词": "Dialogue",
|
|
132
|
+
"请选择 30 MB 以内的音频": "Choose an audio file up to 30 MB",
|
|
133
|
+
"读取音频失败": "Unable to read the audio file",
|
|
134
|
+
"音频资产": "Audio Assets",
|
|
135
|
+
"{count} 个音频资产": "Audio assets: {count}",
|
|
136
|
+
"新建音频": "New Audio Asset",
|
|
137
|
+
"音频类型": "Audio Type",
|
|
138
|
+
"类型": "Type",
|
|
139
|
+
"音频标签": "Audio Tags",
|
|
140
|
+
"没有符合筛选条件的音频。": "No audio matches the filters.",
|
|
141
|
+
"暂无音频素材。": "No audio assets yet.",
|
|
142
|
+
"创建音频": "Create Audio Asset",
|
|
143
|
+
"未设置": "Unset",
|
|
144
|
+
"音频文件": "Audio Files",
|
|
145
|
+
"替换音频": "Replace Audio",
|
|
146
|
+
"上传音频": "Upload Audio",
|
|
147
|
+
"可循环": "Loopable",
|
|
148
|
+
"找不到音频文件 {file}": "Audio file not found: {file}",
|
|
149
|
+
"来源与授权": "Source and License",
|
|
150
|
+
"图形与字标": "Graphics and Wordmarks",
|
|
151
|
+
"特效": "Visual Effects",
|
|
152
|
+
"交付版": "Deliverables",
|
|
153
|
+
"机位": "Camera Angles",
|
|
154
|
+
"季节": "Season",
|
|
155
|
+
"时间": "Time",
|
|
156
|
+
"天气": "Weather",
|
|
157
|
+
"空间定位": "Spatial Layout",
|
|
158
|
+
"局部与陈设": "Details and Set Dressing",
|
|
159
|
+
"角度": "Angles",
|
|
160
|
+
"已采用": "Adopted",
|
|
161
|
+
"候选": "Candidate",
|
|
162
|
+
"参考": "Reference"
|
|
163
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { reactive, watch } from 'vue'
|
|
2
|
+
import en from './en.json'
|
|
3
|
+
|
|
4
|
+
const storageKey = 'workbench.locale'
|
|
5
|
+
const defaultLocale = 'zh-CN'
|
|
6
|
+
export const languages = Object.freeze({ 'zh-CN': '简体中文', en: 'English' })
|
|
7
|
+
|
|
8
|
+
function readLocale() {
|
|
9
|
+
try {
|
|
10
|
+
const saved = localStorage.getItem(storageKey)
|
|
11
|
+
if (Object.hasOwn(languages, saved)) return saved
|
|
12
|
+
} catch {
|
|
13
|
+
// The workbench can still switch languages when storage is unavailable.
|
|
14
|
+
}
|
|
15
|
+
return defaultLocale
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const language = reactive({ locale: readLocale() })
|
|
19
|
+
|
|
20
|
+
export function translate(message = '', params = {}, context) {
|
|
21
|
+
const key = context ? context + '.' + message : message
|
|
22
|
+
const template = language.locale === 'en' && Object.hasOwn(en, key)
|
|
23
|
+
? en[key]
|
|
24
|
+
: language.locale === 'en' && Object.hasOwn(en, message) ? en[message] : message
|
|
25
|
+
return template.replace(/\{(\w+)\}/g, (match, key) => params[key] ?? match)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const i18n = {
|
|
29
|
+
install(app) {
|
|
30
|
+
app.config.globalProperties.$t = translate
|
|
31
|
+
watch(() => language.locale, locale => {
|
|
32
|
+
document.documentElement.lang = locale
|
|
33
|
+
try {
|
|
34
|
+
localStorage.setItem(storageKey, locale)
|
|
35
|
+
} catch {
|
|
36
|
+
// Keep the current selection in memory.
|
|
37
|
+
}
|
|
38
|
+
}, { immediate: true, flush: 'sync' })
|
|
39
|
+
},
|
|
40
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { ElOption, ElSelect } from 'element-plus'
|
|
3
|
+
import 'element-plus/es/components/select/style/css'
|
|
4
|
+
import { AudioLines, BookOpen, Box, ChevronRight, Globe, Layers3, Mountain, Users } from 'lucide-vue-next'
|
|
5
|
+
import projectBrand from 'virtual:project-brand'
|
|
6
|
+
import { language, languages } from '@/i18n/index.js'
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
components: { AudioLines, BookOpen, Box, ChevronRight, ElOption, ElSelect, Globe, Layers3, Mountain, Users },
|
|
10
|
+
props: { sections: { type: Array, required: true } },
|
|
11
|
+
data() {
|
|
12
|
+
return {
|
|
13
|
+
language,
|
|
14
|
+
languages,
|
|
15
|
+
projectLogo: projectBrand.logo,
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
computed: {
|
|
19
|
+
projectName() {
|
|
20
|
+
return projectBrand.name || this.$t('制作项目')
|
|
21
|
+
},
|
|
22
|
+
projectDescription() {
|
|
23
|
+
return projectBrand.description || this.$t('制作工作台')
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
}
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<template>
|
|
30
|
+
<div class="shell">
|
|
31
|
+
<aside class="sidebar">
|
|
32
|
+
<div class="brand"><span class="brand-icon"><img v-if="projectLogo" :src="projectLogo" alt="" @error="projectLogo = ''" /><span v-else class="brand-rabbit" aria-hidden="true"></span></span><div><strong>{{ projectName }}</strong><small>{{ projectDescription }}</small></div></div>
|
|
33
|
+
<nav :aria-label="$t('工作台')">
|
|
34
|
+
<template v-for="(item, index) in sections" :key="item.name">
|
|
35
|
+
<div v-if="item.group !== sections[index - 1]?.group" class="nav-title">{{ $t(item.group) }}</div>
|
|
36
|
+
<RouterLink class="nav-link" :class="{ 'settings-nav': item.name === 'settings' }"
|
|
37
|
+
:to="{ name: item.name }" exact-active-class="selected">
|
|
38
|
+
<component :is="item.icon" :size="17" />{{ $t(item.label, {}, 'navigation') }}<ChevronRight class="nav-arrow" :size="14" />
|
|
39
|
+
</RouterLink>
|
|
40
|
+
</template>
|
|
41
|
+
</nav>
|
|
42
|
+
</aside>
|
|
43
|
+
|
|
44
|
+
<main>
|
|
45
|
+
<header class="topbar">
|
|
46
|
+
<span>{{ $t($route.meta.group) }}</span>
|
|
47
|
+
<ChevronRight :size="14" aria-hidden="true" />
|
|
48
|
+
<strong>{{ $t($route.meta.label) }}</strong>
|
|
49
|
+
<ElSelect v-model="language.locale" class="language-control" popper-class="language-options" :aria-label="$t('语言')">
|
|
50
|
+
<template #prefix><Globe :size="15" aria-hidden="true" /></template>
|
|
51
|
+
<ElOption v-for="(label, locale) in languages" :key="locale" :value="locale" :label="label" :lang="locale" />
|
|
52
|
+
</ElSelect>
|
|
53
|
+
</header>
|
|
54
|
+
<RouterView v-slot="{ Component, route }">
|
|
55
|
+
<KeepAlive include="CharacterAssets">
|
|
56
|
+
<component :is="Component" :key="route.name" />
|
|
57
|
+
</KeepAlive>
|
|
58
|
+
</RouterView>
|
|
59
|
+
</main>
|
|
60
|
+
</div>
|
|
61
|
+
</template>
|
package/src/main.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { createApp } from 'vue'
|
|
2
|
+
import { i18n } from './i18n/index.js'
|
|
3
|
+
import App from './App.vue'
|
|
4
|
+
import { createWorkbenchRouter } from './router/index.js'
|
|
5
|
+
import '@/assets/css/workbench.css'
|
|
6
|
+
|
|
7
|
+
createApp(App).use(i18n).use(createWorkbenchRouter()).mount('#app')
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { createRouter, createWebHistory } from 'vue-router'
|
|
2
|
+
import WorkbenchLayout from '@/layouts/WorkbenchLayout.vue'
|
|
3
|
+
import CharacterAssets from '@/views/assets/CharacterAssets.vue'
|
|
4
|
+
import ImageAssets from '@/views/assets/ImageAssets.vue'
|
|
5
|
+
import AudioAssets from '@/views/assets/AudioAssets.vue'
|
|
6
|
+
import ProjectSettings from '@/views/settings/ProjectSettings.vue'
|
|
7
|
+
|
|
8
|
+
const pages = [
|
|
9
|
+
{ name: 'settings', group: '设定', label: '项目设定', icon: 'BookOpen', component: ProjectSettings },
|
|
10
|
+
{ name: 'characters', group: '资产', label: '角色', icon: 'Users', component: CharacterAssets },
|
|
11
|
+
{ name: 'scenes', group: '资产', label: '场景', icon: 'Mountain', component: ImageAssets, props: { kind: 'scenes' } },
|
|
12
|
+
{ name: 'props', group: '资产', label: '道具', icon: 'Box', component: ImageAssets, props: { kind: 'props' } },
|
|
13
|
+
{ name: 'other', group: '资产', label: '其他', icon: 'Layers3', component: ImageAssets, props: { kind: 'other' } },
|
|
14
|
+
{ name: 'audio', group: '资产', label: '音频', icon: 'AudioLines', component: AudioAssets },
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
const routes = [
|
|
18
|
+
{
|
|
19
|
+
path: '/',
|
|
20
|
+
component: WorkbenchLayout,
|
|
21
|
+
props: { sections: pages.map(({ name, group, label, icon }) => ({ name, group, label, icon })) },
|
|
22
|
+
children: [
|
|
23
|
+
{ path: '', redirect: { name: 'settings' } },
|
|
24
|
+
...pages.map(({ name, group, label, component, props }) => ({
|
|
25
|
+
path: name,
|
|
26
|
+
name,
|
|
27
|
+
component,
|
|
28
|
+
props,
|
|
29
|
+
meta: { group, label },
|
|
30
|
+
})),
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
{ path: '/:pathMatch(.*)*', redirect: { name: 'settings' } },
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
export function createWorkbenchRouter(history = createWebHistory(import.meta.env.BASE_URL)) {
|
|
37
|
+
return createRouter({ history, routes })
|
|
38
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export async function requestAsset(kind, id, method = 'GET', data) {
|
|
2
|
+
const query = id ? '?id=' + encodeURIComponent(id) : ''
|
|
3
|
+
const response = await fetch('/api/' + kind + query, {
|
|
4
|
+
method,
|
|
5
|
+
...(data ? {
|
|
6
|
+
headers: { 'Content-Type': 'application/json', 'X-Workbench': 'local' },
|
|
7
|
+
body: JSON.stringify(data),
|
|
8
|
+
} : {}),
|
|
9
|
+
})
|
|
10
|
+
const result = await response.json()
|
|
11
|
+
if (!response.ok) throw new Error(result.error)
|
|
12
|
+
return result
|
|
13
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Marked, Renderer } from 'marked'
|
|
2
|
+
import DOMPurify from 'dompurify'
|
|
3
|
+
|
|
4
|
+
export const projectFileUrl = file => '/api/settings?file=' + encodeURIComponent(file)
|
|
5
|
+
|
|
6
|
+
export function renderProjectMarkdown(markdown, file, sanitizeOptions) {
|
|
7
|
+
const local = file ? new URL(file, 'https://project.invalid/') : null
|
|
8
|
+
const parser = new Marked({
|
|
9
|
+
renderer: {
|
|
10
|
+
table(token) {
|
|
11
|
+
return '<div class="markdown-table">' + Renderer.prototype.table.call(this, token) + '</div>\n'
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
walkTokens(token) {
|
|
15
|
+
if (!local || !['image', 'link'].includes(token.type) || token.href.startsWith('#')) return
|
|
16
|
+
if (/^(?:[a-z][a-z\d+.-]*:|\/\/)/i.test(token.href)) return
|
|
17
|
+
try {
|
|
18
|
+
const resource = new URL(token.href, local)
|
|
19
|
+
token.href = projectFileUrl(decodeURIComponent(resource.pathname.slice(1))) + resource.hash
|
|
20
|
+
} catch {
|
|
21
|
+
token.href = '#'
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
})
|
|
25
|
+
return DOMPurify.sanitize(parser.parse(markdown), sanitizeOptions)
|
|
26
|
+
}
|