@vyr/vue-browser 0.0.1
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/package.json +25 -0
- package/src/common/index.ts +1 -0
- package/src/common/provider.ts +14 -0
- package/src/index.ts +3 -0
- package/src/locale/Language.ts +10 -0
- package/src/locale/LanguageProvider.ts +25 -0
- package/src/locale/index.ts +2 -0
- package/src/service/index.ts +20 -0
- package/src/service/inspector/TemplateViewer.vue +34 -0
- package/src/service/inspector/index.ts +5 -0
- package/src/service/sidebar/action/AddComponentAction.ts +63 -0
- package/src/service/sidebar/action/index.ts +5 -0
- package/src/shims-vue.d.ts +10 -0
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vyr/vue-browser",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "./src/index.ts",
|
|
6
|
+
"author": "",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"@vyr/locale": "0.0.1",
|
|
10
|
+
"@vyr/runtime": "0.0.1",
|
|
11
|
+
"@vyr/engine": "0.0.1",
|
|
12
|
+
"@vyr/design": "0.0.1",
|
|
13
|
+
"@vyr/builtin": "0.0.1",
|
|
14
|
+
"@vyr/vue": "0.0.1",
|
|
15
|
+
"vue": "3.5.22"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"package.json",
|
|
19
|
+
"src/"
|
|
20
|
+
],
|
|
21
|
+
"vyr": {
|
|
22
|
+
"type": "browser",
|
|
23
|
+
"order": 1000
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './provider'
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { provide, inject, Ref } from "vue";
|
|
2
|
+
import { Descriptor } from "@vyr/engine";
|
|
3
|
+
|
|
4
|
+
const providerKey = Symbol()
|
|
5
|
+
|
|
6
|
+
const providerDescriptor = (descriptor: Ref<Descriptor | null>) => {
|
|
7
|
+
provide(providerKey, descriptor)
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const useDescriptor = <T extends Descriptor = Descriptor>() => {
|
|
11
|
+
return inject(providerKey) as Ref<T>
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { providerDescriptor, useDescriptor }
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Locale } from "@vyr/locale";
|
|
2
|
+
import { zhCnLanguageProvider, ZhCNLanguageProvider } from "./LanguageProvider";
|
|
3
|
+
|
|
4
|
+
Locale.register(zhCnLanguageProvider)
|
|
5
|
+
|
|
6
|
+
const language = Locale.getLanguage<ZhCNLanguageProvider>(zhCnLanguageProvider.name)
|
|
7
|
+
|
|
8
|
+
export {
|
|
9
|
+
language
|
|
10
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { LanguageProvider } from '@vyr/locale'
|
|
2
|
+
|
|
3
|
+
interface ZhCNLanguageProvider extends LanguageProvider {
|
|
4
|
+
'descriptor.type.Template': string
|
|
5
|
+
|
|
6
|
+
'sidebar.action.addComponent.label': string
|
|
7
|
+
|
|
8
|
+
'inspector.Template.slotName':string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const zhCnLanguageProvider: ZhCNLanguageProvider = {
|
|
12
|
+
id: 'zh_CN',
|
|
13
|
+
name: '@vyr/vue-browser',
|
|
14
|
+
|
|
15
|
+
'descriptor.type.Template': '插槽',
|
|
16
|
+
|
|
17
|
+
'sidebar.action.addComponent.label': '新增组件',
|
|
18
|
+
|
|
19
|
+
'inspector.Template.slotName':'插槽名称',
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export {
|
|
23
|
+
ZhCNLanguageProvider,
|
|
24
|
+
zhCnLanguageProvider,
|
|
25
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { InspectorService, runtime, ShortcutkeyService, } from "@vyr/runtime";
|
|
2
|
+
import sidebarAction from './sidebar/action'
|
|
3
|
+
import inspectorViewer from './inspector'
|
|
4
|
+
|
|
5
|
+
const setup = async () => {
|
|
6
|
+
const shortcutkeyService = runtime.get<ShortcutkeyService>('shortcutkey')
|
|
7
|
+
const inspectorService = runtime.get<InspectorService>('inspector')
|
|
8
|
+
|
|
9
|
+
const sidebar = shortcutkeyService.get('sidebar')
|
|
10
|
+
for (const Action of sidebarAction) {
|
|
11
|
+
const action = new Action()
|
|
12
|
+
sidebar.add(action)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
for (const viewer of inspectorViewer) {
|
|
16
|
+
inspectorService.set(viewer.type, viewer.import)
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { setup }
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<vyr-card v-if="descriptor" :title="language.get(`descriptor.type.${descriptor.type}` as any)" :scroll="true">
|
|
3
|
+
<BaseFragment :raw="raw" />
|
|
4
|
+
<vyr-row>
|
|
5
|
+
<vyr-label :label="language.get('inspector.Template.slotName')">
|
|
6
|
+
<vyr-col>
|
|
7
|
+
<vyr-input v-model="descriptor.slotName" trigger="blur"></vyr-input>
|
|
8
|
+
</vyr-col>
|
|
9
|
+
</vyr-label>
|
|
10
|
+
</vyr-row>
|
|
11
|
+
</vyr-card>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
<script lang="ts" setup>
|
|
16
|
+
import { ref, Ref, watch } from 'vue';
|
|
17
|
+
import { VyrCard, VyrRow, VyrLabel, VyrCol, VyrInput } from '@vyr/design';
|
|
18
|
+
import { BaseFragment, providerDescriptor as builtinProviderDescriptor } from '@vyr/builtin'
|
|
19
|
+
import { TemplateDescriptor } from '@vyr/vue'
|
|
20
|
+
import { language } from '../../locale'
|
|
21
|
+
|
|
22
|
+
const props = defineProps<{ raw: string, uuid: string }>()
|
|
23
|
+
|
|
24
|
+
const descriptor = ref(null) as Ref<TemplateDescriptor | null>
|
|
25
|
+
const watchEditItem = (cur: string) => {
|
|
26
|
+
if (!cur) return descriptor.value = null
|
|
27
|
+
descriptor.value = TemplateDescriptor.get<TemplateDescriptor>(cur)
|
|
28
|
+
}
|
|
29
|
+
watch(() => props.uuid, watchEditItem, { immediate: true })
|
|
30
|
+
|
|
31
|
+
builtinProviderDescriptor(descriptor)
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
<style lang="less" scoped></style>
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Descriptor } from "@vyr/engine"
|
|
2
|
+
import { TemplateDescriptor } from '@vyr/vue'
|
|
3
|
+
import { Action, DataService, runtime } from "@vyr/runtime"
|
|
4
|
+
import { language as builtinLanguage } from '@vyr/builtin'
|
|
5
|
+
import { language } from '../../../locale'
|
|
6
|
+
|
|
7
|
+
class AddComponentAction extends Action {
|
|
8
|
+
static id = 'sidebar.addComponent'
|
|
9
|
+
static generate = (label: string, Class: typeof Descriptor) => {
|
|
10
|
+
class ClassAction extends Action {
|
|
11
|
+
static id = Class.type
|
|
12
|
+
label = label
|
|
13
|
+
update() {
|
|
14
|
+
this.show = true
|
|
15
|
+
this.disabled = false
|
|
16
|
+
}
|
|
17
|
+
validator() {
|
|
18
|
+
return false
|
|
19
|
+
}
|
|
20
|
+
execute() {
|
|
21
|
+
|
|
22
|
+
const dataService = runtime.get<DataService>('data')
|
|
23
|
+
const navigator = dataService.sidebar.get(dataService.sidebar.active)
|
|
24
|
+
if (navigator === null) return console.log(builtinLanguage.get('sidebar.action.active.notFound', { key: dataService.sidebar.active }))
|
|
25
|
+
|
|
26
|
+
navigator.status.modifyMode = 'add'
|
|
27
|
+
navigator.status.modifyContent = new Class()
|
|
28
|
+
navigator.status.modifyValue = navigator.status.mouseItem
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return new ClassAction()
|
|
32
|
+
}
|
|
33
|
+
generate = AddComponentAction.generate
|
|
34
|
+
label = language.get('sidebar.action.addComponent.label')
|
|
35
|
+
order = 1
|
|
36
|
+
|
|
37
|
+
constructor() {
|
|
38
|
+
super()
|
|
39
|
+
this.children.push(
|
|
40
|
+
AddComponentAction.generate(language.get('descriptor.type.Template'), TemplateDescriptor)
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
update() {
|
|
45
|
+
const dataService = runtime.get<DataService>('data')
|
|
46
|
+
this.show = false
|
|
47
|
+
this.disabled = true
|
|
48
|
+
|
|
49
|
+
const navigator = dataService.sidebar.get(dataService.sidebar.active)
|
|
50
|
+
if (navigator === null) return console.log(builtinLanguage.get('sidebar.action.active.notFound', { key: dataService.sidebar.active }))
|
|
51
|
+
if (navigator.status.mouseItem === null) return
|
|
52
|
+
|
|
53
|
+
this.show = true
|
|
54
|
+
|
|
55
|
+
this.disabled = false
|
|
56
|
+
}
|
|
57
|
+
validator() {
|
|
58
|
+
return false
|
|
59
|
+
}
|
|
60
|
+
execute() { }
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export { AddComponentAction }
|