@opentiny/vue-docs 3.24.6 → 3.26.0
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/.stylelintrc.js +2 -2
- package/demos/apis/button.js +15 -0
- package/demos/apis/calendar-view.js +3 -2
- package/demos/apis/chart-demo.js +1 -1
- package/demos/apis/chart-docs.js +1 -1
- package/demos/apis/chart-events.js +1 -1
- package/demos/apis/chart-question.js +1 -1
- package/demos/apis/chart.js +1 -1
- package/demos/apis/form.js +3 -0
- package/demos/apis/grid.js +76 -16
- package/demos/apis/modal.js +1 -1
- package/demos/apis/numeric.js +3 -3
- package/demos/apis/search.js +28 -0
- package/demos/apis/slider-button.js +22 -0
- package/demos/apis/split.js +11 -0
- package/demos/apis/steps.js +3 -3
- package/demos/apis/tabs.js +12 -0
- package/demos/apis/time-line.js +20 -0
- package/demos/mobile-first/app/button/type.vue +1 -1
- package/demos/mobile-first/app/button/webdoc/button.js +2 -2
- package/demos/mobile-first/app/slider-button/basic-usage.vue +5 -5
- package/demos/mobile-first/app/slider-button/webdoc/slider-button.js +1 -1
- package/demos/mobile-first/app/steps/advanced-steps.vue +8 -1
- package/demos/mobile-first/menus.js +16 -9
- package/demos/pc/app/action-menu/basic-usage-composition-api.vue +1 -1
- package/demos/pc/app/action-menu/basic-usage.vue +1 -1
- package/demos/pc/app/action-menu/card-mode-composition-api.vue +1 -1
- package/demos/pc/app/action-menu/card-mode.vue +1 -1
- package/demos/pc/app/action-menu/disabled-composition-api.vue +2 -2
- package/demos/pc/app/action-menu/disabled.vue +2 -2
- package/demos/pc/app/action-menu/events-composition-api.vue +1 -1
- package/demos/pc/app/action-menu/events.vue +1 -1
- package/demos/pc/app/action-menu/icon-composition-api.vue +2 -2
- package/demos/pc/app/action-menu/icon.vue +2 -2
- package/demos/pc/app/action-menu/max-show-num-composition-api.vue +1 -1
- package/demos/pc/app/action-menu/max-show-num.vue +1 -1
- package/demos/pc/app/action-menu/more-text-composition-api.vue +1 -1
- package/demos/pc/app/action-menu/more-text.vue +1 -1
- package/demos/pc/app/action-menu/popper-class-composition-api.vue +1 -1
- package/demos/pc/app/action-menu/popper-class.vue +1 -1
- package/demos/pc/app/action-menu/slot-item-composition-api.vue +1 -1
- package/demos/pc/app/action-menu/slot-item.vue +1 -1
- package/demos/pc/app/action-menu/spacing-composition-api.vue +1 -1
- package/demos/pc/app/action-menu/spacing.vue +1 -1
- package/demos/pc/app/action-menu/text-field-composition-api.vue +1 -1
- package/demos/pc/app/action-menu/text-field.spec.ts +1 -1
- package/demos/pc/app/action-menu/text-field.vue +1 -1
- package/demos/pc/app/amount/custom-service.spec.js +4 -4
- package/demos/pc/app/base-select/slot-reference.spec.ts +1 -1
- package/demos/pc/app/button/icon-composition-api.vue +3 -1
- package/demos/pc/app/button/icon.vue +3 -1
- package/demos/pc/app/button/webdoc/button.js +3 -2
- package/demos/pc/app/calendar-view/calendar-mode-composition-api.vue +7 -1
- package/demos/pc/app/calendar-view/calendar-mode.spec.ts +3 -0
- package/demos/pc/app/calendar-view/calendar-mode.vue +7 -1
- package/demos/pc/app/carousel/webdoc/carousel.js +0 -18
- package/demos/pc/app/color-picker/alpha-composition-api.vue +1 -1
- package/demos/pc/app/color-picker/alpha.spec.ts +2 -2
- package/demos/pc/app/color-picker/alpha.vue +1 -1
- package/demos/pc/app/color-picker/base.spec.ts +2 -2
- package/demos/pc/app/color-picker/default-visible.spec.ts +1 -1
- package/demos/pc/app/color-picker/event-composition-api.vue +2 -2
- package/demos/pc/app/color-picker/event.spec.ts +4 -4
- package/demos/pc/app/color-picker/event.vue +1 -1
- package/demos/pc/app/color-picker/format.spec.ts +6 -6
- package/demos/pc/app/color-picker/history.spec.ts +1 -7
- package/demos/pc/app/color-picker/predefine.spec.ts +3 -10
- package/demos/pc/app/color-picker/size.spec.ts +4 -4
- package/demos/pc/app/color-select-panel/format.spec.ts +2 -8
- package/demos/pc/app/color-select-panel/history.spec.ts +0 -2
- package/demos/pc/app/color-select-panel/predefine.spec.ts +0 -3
- package/demos/pc/app/container/basic-usage-composition-api.vue +10 -10
- package/demos/pc/app/container/basic-usage.vue +10 -10
- package/demos/pc/app/container/custom-with-height-composition-api.vue +8 -8
- package/demos/pc/app/container/custom-with-height.vue +10 -10
- package/demos/pc/app/date-panel/custom-week.spec.ts +2 -2
- package/demos/pc/app/dialog-select/nest-grid-single.spec.ts +40 -0
- package/demos/pc/app/dialog-select/nest-tree-multi.spec.ts +53 -0
- package/demos/pc/app/dialog-select/nest-tree-single.spec.ts +25 -0
- package/demos/pc/app/dialog-select/set-selection.spec.ts +20 -0
- package/demos/pc/app/file-upload/before-upload-limit-composition-api.vue +1 -1
- package/demos/pc/app/file-upload/before-upload-limit.spec.ts +1 -1
- package/demos/pc/app/file-upload/before-upload-limit.vue +1 -1
- package/demos/pc/app/file-upload/custom-trigger-composition-api.vue +1 -1
- package/demos/pc/app/file-upload/custom-trigger.spec.ts +1 -1
- package/demos/pc/app/file-upload/custom-trigger.vue +1 -1
- package/demos/pc/app/file-upload/custom-upload-tip-composition-api.vue +1 -1
- package/demos/pc/app/file-upload/custom-upload-tip.vue +1 -1
- package/demos/pc/app/file-upload/form-validation-composition-api.vue +1 -1
- package/demos/pc/app/file-upload/form-validation.vue +1 -1
- package/demos/pc/app/file-upload/image-size-composition-api.vue +1 -1
- package/demos/pc/app/file-upload/image-size.spec.ts +1 -1
- package/demos/pc/app/file-upload/image-size.vue +1 -1
- package/demos/pc/app/file-upload/multiple-file-composition-api.vue +1 -1
- package/demos/pc/app/file-upload/multiple-file.spec.ts +1 -1
- package/demos/pc/app/file-upload/multiple-file.vue +1 -1
- package/demos/pc/app/file-upload/prevent-delete-file-composition-api.vue +1 -1
- package/demos/pc/app/file-upload/prevent-delete-file.vue +1 -1
- package/demos/pc/app/file-upload/upload-request-composition-api.vue +1 -1
- package/demos/pc/app/file-upload/upload-request.spec.ts +2 -2
- package/demos/pc/app/file-upload/upload-request.vue +1 -1
- package/demos/pc/app/grid/base/basic-usage-composition-api.vue +1 -17
- package/demos/pc/app/grid/custom/column-fixed.spec.js +2 -1
- package/demos/pc/app/grid/custom/page-size.spec.js +1 -1
- package/demos/pc/app/grid/data-source/auto-load.spec.js +0 -1
- package/demos/pc/app/grid/data-source/request-service.spec.js +1 -1
- package/demos/pc/app/grid/data-source/static-data.spec.js +1 -1
- package/demos/pc/app/grid/dynamically-columns/dynamically-columns.spec.js +2 -1
- package/demos/pc/app/grid/edit/scrollbar-not-blur-composition-api.vue +119 -0
- package/demos/pc/app/grid/edit/scrollbar-not-blur.spec.ts +28 -0
- package/demos/pc/app/grid/edit/scrollbar-not-blur.vue +129 -0
- package/demos/pc/app/grid/editor/custom-edit.spec.js +7 -2
- package/demos/pc/app/grid/empty/empty-data-iscenter.spec.js +1 -1
- package/demos/pc/app/grid/event/toolbar-button-click-event.spec.js +1 -1
- package/demos/pc/app/grid/expand/expand-trigger-slot-composition-api.vue +85 -0
- package/demos/pc/app/grid/expand/expand-trigger-slot.spec.ts +11 -0
- package/demos/pc/app/grid/expand/expand-trigger-slot.vue +95 -0
- package/demos/pc/app/grid/expand/set-row-expansion.spec.js +4 -0
- package/demos/pc/app/grid/filter/custom-filter.spec.js +3 -3
- package/demos/pc/app/grid/filter/default-filter-composition-api.vue +6 -0
- package/demos/pc/app/grid/filter/default-filter.vue +6 -0
- package/demos/pc/app/grid/filter/default-relation.spec.js +1 -1
- package/demos/pc/app/grid/filter/server-filter.spec.js +1 -1
- package/demos/pc/app/grid/filter/simple-filter.spec.ts +5 -4
- package/demos/pc/app/grid/fixed/right-fixed-composition-api.vue +4 -4
- package/demos/pc/app/grid/fixed/right-fixed.vue +4 -4
- package/demos/pc/app/grid/footer/footer-summation-empty.spec.js +0 -1
- package/demos/pc/app/grid/large-data/full-data-loading.spec.js +10 -3
- package/demos/pc/app/grid/large-data/virtual-rolling.spec.js +9 -2
- package/demos/pc/app/grid/mouse-keyboard/keyboard-navigation.spec.js +4 -1
- package/demos/pc/app/grid/renderer/inner-renderer-date-composition-api.vue +4 -3
- package/demos/pc/app/grid/renderer/inner-renderer-date.spec.js +2 -2
- package/demos/pc/app/grid/renderer/inner-renderer-date.vue +3 -3
- package/demos/pc/app/grid/renderer/inner-renderer.spec.js +4 -0
- package/demos/pc/app/grid/size/max-min-grid-height.spec.js +2 -2
- package/demos/pc/app/grid/slot/slot-conf-composition-api.vue +141 -0
- package/demos/pc/app/grid/slot/slot-conf.spec.js +12 -0
- package/demos/pc/app/grid/slot/slot-conf.vue +151 -0
- package/demos/pc/app/grid/sort/combinations-sort.spec.js +2 -2
- package/demos/pc/app/grid/webdoc/grid-edit.js +12 -0
- package/demos/pc/app/grid/webdoc/grid-empty.js +1 -1
- package/demos/pc/app/grid/webdoc/grid-expand.js +11 -0
- package/demos/pc/app/grid/webdoc/grid-slot.js +9 -0
- package/demos/pc/app/icon/iconGroups.js +8 -2
- package/demos/pc/app/input/basic-usage.spec.ts +1 -1
- package/demos/pc/app/loading/background.spec.ts +3 -1
- package/demos/pc/app/loading/custom-class.spec.ts +4 -2
- package/demos/pc/app/loading/fullscreen.spec.ts +6 -4
- package/demos/pc/app/loading/loading-tip-text.spec.ts +3 -1
- package/demos/pc/app/loading/size.spec.ts +5 -3
- package/demos/pc/app/locales/custom-service-composition-api.vue +3 -3
- package/demos/pc/app/locales/custom-service.spec.ts +1 -1
- package/demos/pc/app/locales/custom-service.vue +3 -3
- package/demos/pc/app/modal/basic-usage.spec.ts +2 -1
- package/demos/pc/app/modal/message-close.spec.ts +2 -2
- package/demos/pc/app/modal/message-id.spec.ts +2 -2
- package/demos/pc/app/modal/modal-fn-slots.spec.ts +5 -7
- package/demos/pc/app/modal/modal-header.spec.ts +2 -1
- package/demos/pc/app/numeric/input-event-composition-api.vue +26 -0
- package/demos/pc/app/numeric/input-event.spec.ts +15 -0
- package/demos/pc/app/numeric/input-event.vue +34 -0
- package/demos/pc/app/numeric/webdoc/numeric.js +12 -0
- package/demos/pc/app/pager/align-composition-api.vue +10 -13
- package/demos/pc/app/pager/align.spec.ts +8 -3
- package/demos/pc/app/pager/align.vue +11 -5
- package/demos/pc/app/pager/page-size-composition-api.vue +2 -2
- package/demos/pc/app/pager/page-size.spec.ts +1 -1
- package/demos/pc/app/pager/page-size.vue +2 -2
- package/demos/pc/app/pager/pager-in-grid-composition-api.vue +0 -1
- package/demos/pc/app/pager/pager-in-grid.vue +0 -1
- package/demos/pc/app/pager/popper-append-to-body-composition-api.vue +1 -7
- package/demos/pc/app/pager/popper-append-to-body.vue +1 -7
- package/demos/pc/app/pager/popper-class-composition-api.vue +1 -7
- package/demos/pc/app/pager/popper-class.vue +1 -7
- package/demos/pc/app/popeditor/conditions.spec.ts +1 -1
- package/demos/pc/app/popeditor/suggest.spec.ts +1 -1
- package/demos/pc/app/qr-code/icon-composition-api.vue +17 -3
- package/demos/pc/app/qr-code/icon.spec.ts +19 -0
- package/demos/pc/app/qr-code/icon.vue +25 -4
- package/demos/pc/app/qr-code/style-composition-api.vue +2 -9
- package/demos/pc/app/qr-code/style.spec.ts +18 -1
- package/demos/pc/app/qr-code/style.vue +11 -8
- package/demos/pc/app/query-builder/webdoc/query-builder.js +5 -3
- package/demos/pc/app/search/events.spec.ts +1 -1
- package/demos/pc/app/search/events.vue +9 -0
- package/demos/pc/app/search/slot-prefix-suffix.spec.ts +1 -1
- package/demos/pc/app/search/webdoc/search.js +12 -4
- package/demos/pc/app/select/nest-grid-remote.spec.ts +3 -3
- package/demos/pc/app/select/nest-grid.spec.ts +1 -1
- package/demos/pc/app/select/nest-radio-grid-much-data.spec.ts +5 -7
- package/demos/pc/app/tabs/basic-usage.spec.ts +2 -2
- package/demos/pc/app/tabs/header-only.vue +56 -0
- package/demos/pc/app/tabs/size.spec.ts +2 -2
- package/demos/pc/app/tabs/webdoc/tabs.js +12 -0
- package/demos/pc/app/time-line/slot-default-composition-api.vue +81 -0
- package/demos/pc/app/time-line/slot-default.spec.ts +13 -0
- package/demos/pc/app/time-line/slot-default.vue +95 -0
- package/demos/pc/app/time-line/webdoc/time-line.js +12 -0
- package/demos/pc/menus.js +20 -10
- package/demos/pc/webdoc/changelog-en.md +224 -197
- package/demos/pc/webdoc/changelog.md +167 -387
- package/demos/pc/webdoc/faq.md +14 -0
- package/demos/saas/menus.js +2 -14
- package/env/.env +3 -0
- package/package.json +25 -24
- package/playground/App.vue +2 -2
- package/postcss.config.cjs +1 -0
- package/src/App.vue +26 -59
- package/src/components/anchor.vue +5 -1
- package/src/components/demo.vue +18 -7
- package/src/components/design-token.vue +90 -0
- package/src/components/float-settings.vue +4 -23
- package/src/components/mcp-docs.vue +4 -26
- package/src/components/version-tip.vue +1 -1
- package/src/composable/useTinyRemoter.ts +176 -0
- package/src/composable/utils.ts +2 -166
- package/src/const.ts +6 -1
- package/src/i18n/en.json +2 -0
- package/src/i18n/es.json +47 -0
- package/src/i18n/index.js +24 -5
- package/src/i18n/pt.json +47 -0
- package/src/i18n/zh.json +2 -0
- package/src/main.js +17 -13
- package/src/{menus.jsx → menus.js} +0 -1
- package/src/router.js +3 -18
- package/src/tools/appData.js +6 -16
- package/src/tools/storage.js +5 -3
- package/src/tools/useApiMode.js +11 -3
- package/src/tools/useBulletin.jsx +9 -8
- package/src/tools/useStyleSettings.js +8 -0
- package/src/tools/useTemplateMode.js +5 -1
- package/src/tools/utils.js +32 -1
- package/src/views/components-doc/cmp-config.js +13 -1
- package/src/views/components-doc/common.vue +42 -15
- package/src/views/layout/layout.vue +5 -8
- package/src/views/overview.vue +1 -1
- package/tsconfig.node.json +2 -4
- package/src/components/MessageCard.vue +0 -117
- package/src/components/tiny-robot-chat.vue +0 -128
- package/src/composable/DifyModelProvider.ts +0 -65
- package/src/composable/useTinyRobot.ts +0 -167
- package/src/tools/useAllTaskFinish.ts +0 -0
- package/src/views/comprehensive/Demo.vue +0 -212
- package/src/views/comprehensive/index.vue +0 -380
- package/src/views/comprehensive/products.json +0 -98
- package/src/views/comprehensive/types/index.ts +0 -37
- package/src/views/remoter/index.vue +0 -63
- package/src/views/remoter/sound.vue +0 -349
- /package/demos/pc/app/grid/expand/{expand-config.spec.js → expand-config.spec.ts} +0 -0
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { WebMcpServer, WebMcpClient, createMessageChannelPairTransport, z } from '@opentiny/next-sdk'
|
|
2
|
+
import { genMenus } from '../menus'
|
|
3
|
+
import { useRouter } from 'vue-router'
|
|
4
|
+
import { ref } from 'vue'
|
|
5
|
+
|
|
6
|
+
export const AGENT_ROOT = 'https://agent.opentiny.design/api/v1/webmcp-trial/'
|
|
7
|
+
|
|
8
|
+
// 调用 useTinyRemoter() 完毕后,下面三个变量变会有值。
|
|
9
|
+
export const webMcpServer: { value: null | WebMcpServer } = { value: null }
|
|
10
|
+
export const webMcpClient: { value: null | WebMcpClient } = { value: null }
|
|
11
|
+
export const webMcpSessionId: { value: null | string } = ref('')
|
|
12
|
+
|
|
13
|
+
export async function useTinyRemoter() {
|
|
14
|
+
const [serverTransport, clientTransport] = createMessageChannelPairTransport()
|
|
15
|
+
|
|
16
|
+
// 定义 MCP Server
|
|
17
|
+
const server = new WebMcpServer(
|
|
18
|
+
{ name: 'base-config', version: '1.0.0' },
|
|
19
|
+
{
|
|
20
|
+
capabilities: {
|
|
21
|
+
prompts: { listChanged: true },
|
|
22
|
+
resources: { subscribe: true, listChanged: true },
|
|
23
|
+
tools: { listChanged: true },
|
|
24
|
+
completions: {},
|
|
25
|
+
logging: {}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
)
|
|
29
|
+
webMcpServer.value = server
|
|
30
|
+
createGlobalMcpTool(server)
|
|
31
|
+
|
|
32
|
+
serverTransport.onerror = (error) => {
|
|
33
|
+
console.error(`ServerTransport error:`, error)
|
|
34
|
+
}
|
|
35
|
+
await server.connect(serverTransport)
|
|
36
|
+
|
|
37
|
+
// 定义 MCP Client
|
|
38
|
+
const client = new WebMcpClient(
|
|
39
|
+
{ name: 'mcp-web-client', version: '1.0.0' },
|
|
40
|
+
{ capabilities: { roots: { listChanged: true }, sampling: {}, elicitation: {} } }
|
|
41
|
+
)
|
|
42
|
+
webMcpClient.value = client
|
|
43
|
+
|
|
44
|
+
await client.connect(clientTransport)
|
|
45
|
+
|
|
46
|
+
// 不能传入固定的sessionId, 让它每次自动生成一个。
|
|
47
|
+
const { sessionId } = await client.connect({
|
|
48
|
+
url: AGENT_ROOT + 'mcp',
|
|
49
|
+
agent: true,
|
|
50
|
+
onError: (error: Error) => {
|
|
51
|
+
console.error('Connect proxy error:', error)
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
webMcpSessionId.value = sessionId
|
|
55
|
+
|
|
56
|
+
window.addEventListener('pagehide', client.onPagehide)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// 组件页面的右上导航的数据回调函数
|
|
60
|
+
export const cmpAnchorDataCallback = { value: null }
|
|
61
|
+
|
|
62
|
+
export const createGlobalMcpTool = (server) => {
|
|
63
|
+
const router = useRouter()
|
|
64
|
+
server.registerResource(
|
|
65
|
+
'site-menus',
|
|
66
|
+
'site-menus://app',
|
|
67
|
+
{
|
|
68
|
+
title: 'TinyVue官网的菜单数据',
|
|
69
|
+
description: 'TinyVue官网的菜单数据,其中"key"为路由路径,"name"为菜单名称,"children"为子菜单',
|
|
70
|
+
mimeType: 'text/plain'
|
|
71
|
+
},
|
|
72
|
+
async (uri) => ({
|
|
73
|
+
contents: [
|
|
74
|
+
{
|
|
75
|
+
uri: uri.href,
|
|
76
|
+
text: JSON.stringify(genMenus())
|
|
77
|
+
}
|
|
78
|
+
]
|
|
79
|
+
})
|
|
80
|
+
)
|
|
81
|
+
// 帮我查看button组件的API
|
|
82
|
+
server.registerTool(
|
|
83
|
+
'swtich-router',
|
|
84
|
+
{
|
|
85
|
+
title: 'router',
|
|
86
|
+
description: '可以帮用户跳转到文档页面,组件示例的总页面或组件API文档页面,或组件库的概览页面',
|
|
87
|
+
inputSchema: {
|
|
88
|
+
key: z.string().describe('跳转页面路径'),
|
|
89
|
+
type: z
|
|
90
|
+
.enum(['components', 'docs', 'overview', 'features'])
|
|
91
|
+
.describe('跳转页面类型,比如:组件的页面,文档的页面,组件的概览页面'),
|
|
92
|
+
isOpenApi: z.boolean().describe('跳转到组件页面时,是否打开API文档')
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
async ({ key, type, isOpenApi }) => {
|
|
96
|
+
const { params, fullPath } = router.currentRoute.value
|
|
97
|
+
const { theme } = params
|
|
98
|
+
const themeIndex = fullPath.indexOf(theme)
|
|
99
|
+
const linkUrl =
|
|
100
|
+
fullPath.slice(0, themeIndex) + `${theme}/${type}/${key === 'overview' ? '' : key}${isOpenApi ? '#api' : ''}`
|
|
101
|
+
router.push(linkUrl)
|
|
102
|
+
return {
|
|
103
|
+
content: [
|
|
104
|
+
{
|
|
105
|
+
type: 'text',
|
|
106
|
+
text: `跳转页面成功: ${key}`
|
|
107
|
+
}
|
|
108
|
+
]
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
server.registerTool(
|
|
114
|
+
'get-component-demos',
|
|
115
|
+
{
|
|
116
|
+
title: '查询全部示例的信息',
|
|
117
|
+
description:
|
|
118
|
+
'查询当前组件的全部示例信息,demos信息。返回值是一个数组,其中每一项的 demoId 属性是示例的键,通过键可以跳转到该示例。desc属性是示例的详细描述。',
|
|
119
|
+
inputSchema: {}
|
|
120
|
+
},
|
|
121
|
+
async () => {
|
|
122
|
+
// 通知组件页面返回右侧导航的数据
|
|
123
|
+
if (cmpAnchorDataCallback.value != null) {
|
|
124
|
+
const links = cmpAnchorDataCallback.value()
|
|
125
|
+
|
|
126
|
+
return {
|
|
127
|
+
content: [{ type: 'text', text: JSON.stringify(links) }]
|
|
128
|
+
}
|
|
129
|
+
} else {
|
|
130
|
+
return {
|
|
131
|
+
content: [{ type: 'text', text: '找不到示例' }]
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
server.registerTool(
|
|
138
|
+
'jump-to-demo',
|
|
139
|
+
{
|
|
140
|
+
title: '跳转到组件的示例demo',
|
|
141
|
+
description: '根据参数demoId, 跳转到指定的示例demo。',
|
|
142
|
+
inputSchema: {
|
|
143
|
+
demoId: z.string().describe('示例的id,唯一标识。')
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
async ({ demoId }) => {
|
|
147
|
+
// 通知组件页面返回右侧导航的数据
|
|
148
|
+
location.hash = '#' + demoId
|
|
149
|
+
|
|
150
|
+
return {
|
|
151
|
+
content: [{ type: 'text', text: '跳转示例成功' }]
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
// 长任务示例
|
|
157
|
+
server.registerTool(
|
|
158
|
+
'long-task',
|
|
159
|
+
{
|
|
160
|
+
title: 'long-task',
|
|
161
|
+
description: '可以帮用户订机票'
|
|
162
|
+
},
|
|
163
|
+
async () => {
|
|
164
|
+
// 执行一个长任务
|
|
165
|
+
await new Promise((resolve) => setTimeout(resolve, 10000))
|
|
166
|
+
return {
|
|
167
|
+
content: [
|
|
168
|
+
{
|
|
169
|
+
type: 'text',
|
|
170
|
+
text: '执行一个长任务,执行完成'
|
|
171
|
+
}
|
|
172
|
+
]
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
)
|
|
176
|
+
}
|
package/src/composable/utils.ts
CHANGED
|
@@ -3,170 +3,6 @@
|
|
|
3
3
|
* 提供一些实用的辅助函数
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import
|
|
7
|
-
import type { ChatCompletionRequest } from '@opentiny/tiny-robot-kit'
|
|
8
|
-
import { ref, reactive, type Ref } from 'vue'
|
|
6
|
+
import { $local, $session } from './storage'
|
|
9
7
|
|
|
10
|
-
export { $local, $session }
|
|
11
|
-
|
|
12
|
-
export const showTinyRobot = ref(true)
|
|
13
|
-
|
|
14
|
-
export const globalConversation = reactive({
|
|
15
|
-
id: '',
|
|
16
|
-
sessionId: ''
|
|
17
|
-
})
|
|
18
|
-
/**
|
|
19
|
-
* 处理SSE流式响应
|
|
20
|
-
* @param response fetch响应对象
|
|
21
|
-
* @param handler 流处理器
|
|
22
|
-
*/
|
|
23
|
-
export async function handleSSEStream(
|
|
24
|
-
response: Response,
|
|
25
|
-
handler: StreamHandler,
|
|
26
|
-
message: Ref<ChatCompletionRequest['messages']>,
|
|
27
|
-
signal?: AbortSignal
|
|
28
|
-
): Promise<void> {
|
|
29
|
-
// 获取ReadableStream
|
|
30
|
-
const reader = response.body?.getReader()
|
|
31
|
-
if (!reader) {
|
|
32
|
-
throw new Error('Response body is null')
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// 处理流式数据
|
|
36
|
-
const decoder = new TextDecoder()
|
|
37
|
-
let buffer = ''
|
|
38
|
-
|
|
39
|
-
if (signal) {
|
|
40
|
-
signal.addEventListener(
|
|
41
|
-
'abort',
|
|
42
|
-
() => {
|
|
43
|
-
reader.cancel().catch((err) => console.error('Error cancelling reader:', err))
|
|
44
|
-
},
|
|
45
|
-
{ once: true }
|
|
46
|
-
)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
let messageIndex = 0
|
|
50
|
-
function printMessage(data, str: string, endln = false) {
|
|
51
|
-
handler.onData({
|
|
52
|
-
id: '',
|
|
53
|
-
created: data.created_at,
|
|
54
|
-
choices: [
|
|
55
|
-
{
|
|
56
|
-
index: messageIndex++,
|
|
57
|
-
delta: {
|
|
58
|
-
role: 'assistant',
|
|
59
|
-
content: str + (endln ? '\n\n' : '')
|
|
60
|
-
},
|
|
61
|
-
finish_reason: null
|
|
62
|
-
}
|
|
63
|
-
],
|
|
64
|
-
object: '',
|
|
65
|
-
model: ''
|
|
66
|
-
})
|
|
67
|
-
}
|
|
68
|
-
try {
|
|
69
|
-
while (true) {
|
|
70
|
-
if (signal?.aborted) {
|
|
71
|
-
await reader.cancel()
|
|
72
|
-
break
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const { done, value } = await reader.read()
|
|
76
|
-
if (done) break
|
|
77
|
-
|
|
78
|
-
// 解码二进制数据
|
|
79
|
-
const chunk = decoder.decode(value, { stream: true })
|
|
80
|
-
buffer += chunk
|
|
81
|
-
|
|
82
|
-
// 处理完整的SSE消息
|
|
83
|
-
const lines = buffer.split('\n\n')
|
|
84
|
-
buffer = lines.pop() || ''
|
|
85
|
-
|
|
86
|
-
for (const line of lines) {
|
|
87
|
-
if (line.trim() === '') continue
|
|
88
|
-
if (line.trim() === 'data: [DONE]') {
|
|
89
|
-
handler.onDone()
|
|
90
|
-
continue
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
try {
|
|
94
|
-
// 解析SSE消息
|
|
95
|
-
const dataMatch = line.match(/^data: (.+)$/m)
|
|
96
|
-
if (!dataMatch) continue
|
|
97
|
-
|
|
98
|
-
const data = JSON.parse(dataMatch[1])
|
|
99
|
-
// console.log('SSE data:', data)
|
|
100
|
-
if (data?.event === 'node_started') {
|
|
101
|
-
printMessage(data, `${data.data.title} 节点运行...`, true)
|
|
102
|
-
}
|
|
103
|
-
if (data?.event === 'node_finished') {
|
|
104
|
-
printMessage(
|
|
105
|
-
data,
|
|
106
|
-
`${data.data.title} 节点结束\n\n` +
|
|
107
|
-
(data.data.node_type === 'answer' ? `${data.data.outputs.answer}` : '')
|
|
108
|
-
)
|
|
109
|
-
}
|
|
110
|
-
if (data?.event === 'agent_log' && data.data.status === 'success' && data.data.label.startsWith('CALL')) {
|
|
111
|
-
printMessage(data, `--${data.data.label}(${JSON.stringify(data.data.data.output.tool_call_input)})`, true)
|
|
112
|
-
}
|
|
113
|
-
} catch (error) {
|
|
114
|
-
console.error('Error parsing SSE message:', error)
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
if (buffer.trim() === 'data: [DONE]' || signal?.aborted) {
|
|
120
|
-
handler.onDone()
|
|
121
|
-
}
|
|
122
|
-
} catch (error) {
|
|
123
|
-
if (signal?.aborted) return
|
|
124
|
-
throw error
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* 格式化消息
|
|
130
|
-
* 将各种格式的消息转换为标准的ChatMessage格式
|
|
131
|
-
* @param messages 消息数组
|
|
132
|
-
* @returns 标准格式的消息数组
|
|
133
|
-
*/
|
|
134
|
-
export function formatMessages(messages: Array<ChatMessage | string>): ChatMessage[] {
|
|
135
|
-
return messages.map((msg) => {
|
|
136
|
-
// 如果已经是标准格式,直接返回
|
|
137
|
-
if (typeof msg === 'object' && 'role' in msg && 'content' in msg) {
|
|
138
|
-
return {
|
|
139
|
-
role: msg.role,
|
|
140
|
-
content: String(msg.content),
|
|
141
|
-
...(msg.name ? { name: msg.name } : {})
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// 如果是字符串,默认为用户消息
|
|
146
|
-
if (typeof msg === 'string') {
|
|
147
|
-
return {
|
|
148
|
-
role: 'user',
|
|
149
|
-
content: msg
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
// 其他情况,尝试转换为字符串
|
|
154
|
-
return {
|
|
155
|
-
role: 'user',
|
|
156
|
-
content: String(msg)
|
|
157
|
-
}
|
|
158
|
-
})
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* 从响应中提取文本内容
|
|
163
|
-
* @param response 聊天完成响应
|
|
164
|
-
* @returns 文本内容
|
|
165
|
-
*/
|
|
166
|
-
export function extractTextFromResponse(response: ChatCompletionResponse): string {
|
|
167
|
-
if (!response.choices || !response.choices.length) {
|
|
168
|
-
return ''
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
return response.choices[0].message?.content || ''
|
|
172
|
-
}
|
|
8
|
+
export { $local, $session }
|
package/src/const.ts
CHANGED
|
@@ -5,10 +5,15 @@ export const LANG_KEY = '_lang'
|
|
|
5
5
|
// localStorage中保存语言的value
|
|
6
6
|
export const ZH_CN_LANG = 'zhCN'
|
|
7
7
|
export const EN_US_LANG = 'enUS'
|
|
8
|
+
export const ES_LA_LANG = 'esLA'
|
|
9
|
+
export const PT_BR_LANG = 'ptBR'
|
|
10
|
+
|
|
8
11
|
// 语言key值对应的路由
|
|
9
12
|
export const LANG_PATH_MAP = {
|
|
10
13
|
[ZH_CN_LANG]: 'zh-CN',
|
|
11
|
-
[EN_US_LANG]: 'en-US'
|
|
14
|
+
[EN_US_LANG]: 'en-US',
|
|
15
|
+
[ES_LA_LANG]: 'es-LA',
|
|
16
|
+
[PT_BR_LANG]: 'pt-BR'
|
|
12
17
|
}
|
|
13
18
|
|
|
14
19
|
export const CURRENT_THEME_KEY = 'tiny-current-theme'
|
package/src/i18n/en.json
CHANGED
package/src/i18n/es.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"zh-cn": "Chinese",
|
|
3
|
+
"en-us": "English",
|
|
4
|
+
"es-la": "Spanish",
|
|
5
|
+
"pt-br": "Portuguese",
|
|
6
|
+
"localeType": "Language Selection",
|
|
7
|
+
"dark": "Dark",
|
|
8
|
+
"light": "Light",
|
|
9
|
+
"searchPlaceholder": "Search",
|
|
10
|
+
"home": "Home",
|
|
11
|
+
"doc": "Docs",
|
|
12
|
+
"component": "Components",
|
|
13
|
+
"common": "Common",
|
|
14
|
+
"apiPreference": "Framework",
|
|
15
|
+
"apiTiny": "Vue",
|
|
16
|
+
"yan-shi": "Demo",
|
|
17
|
+
"demos": "Demos",
|
|
18
|
+
"api": "API",
|
|
19
|
+
"name": "Name",
|
|
20
|
+
"propType": "Type",
|
|
21
|
+
"defValue": "Default",
|
|
22
|
+
"typeValue": "Option Value",
|
|
23
|
+
"desc": "Description",
|
|
24
|
+
"showCode": "Show Code",
|
|
25
|
+
"hideCode": "Hide Code",
|
|
26
|
+
"copyCode": "Copy Code",
|
|
27
|
+
"doc-owner": "Owner",
|
|
28
|
+
"copyCodeOk": "Copy Success",
|
|
29
|
+
"frameAngular": "Angular",
|
|
30
|
+
"playground": "Open Playground",
|
|
31
|
+
"changeLanguage": "Change Language",
|
|
32
|
+
"changeTheme": "Change Components Theme",
|
|
33
|
+
"changeApiType": "Change Api Type",
|
|
34
|
+
"backTop": "Back To Top",
|
|
35
|
+
"overview": "Components Overview",
|
|
36
|
+
"overviewDesc": "TinyVue provides a wealth of basic UI components for web applications, and we will continue to explore the best UI practices for enterprise-level applications. Welcome to try TinyVue.",
|
|
37
|
+
"overviewDescPlus": "TinyVuePlus is a component library for Cloud business scenarios based on TinyVue, following the new design specifications of Cloud CloudDesign and utilizing Vite+Vue3+TypeScript technology stack.",
|
|
38
|
+
"searchComponents": "search components",
|
|
39
|
+
"apiType": "Components demos code style",
|
|
40
|
+
"apiStyleOptions": "Options",
|
|
41
|
+
"apiStyleComposition": "Composition",
|
|
42
|
+
"demoMode": "Demo display mode",
|
|
43
|
+
"demoModeSingle": "Single",
|
|
44
|
+
"demoModeMultiple": "Multiple",
|
|
45
|
+
"contributor": "Contributors",
|
|
46
|
+
"noData": "No Data"
|
|
47
|
+
}
|
package/src/i18n/index.js
CHANGED
|
@@ -3,11 +3,21 @@ import { initI18n, t } from '@opentiny/vue-locale'
|
|
|
3
3
|
import { $local } from '../tools'
|
|
4
4
|
import zh from './zh.json'
|
|
5
5
|
import en from './en.json'
|
|
6
|
+
import esLA from './es.json'
|
|
7
|
+
import ptBR from './pt.json'
|
|
6
8
|
import { zhCN, enUS } from '@opentiny/tiny-vue-mcp'
|
|
7
9
|
|
|
8
|
-
const messages = { enUS: { ...en, ...enUS }, zhCN: { ...zh, ...zhCN } }
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
const messages = { enUS: { ...en, ...enUS }, zhCN: { ...zh, ...zhCN }, esLA: { ...esLA }, ptBR: { ...ptBR } }
|
|
11
|
+
|
|
12
|
+
const langMap = new Map([
|
|
13
|
+
['zhCN', 'zhCN'],
|
|
14
|
+
['enUS', 'enUS'],
|
|
15
|
+
['esLA', 'esLA'],
|
|
16
|
+
['ptBR', 'ptBR']
|
|
17
|
+
])
|
|
18
|
+
|
|
19
|
+
$local._lang = langMap.get($local._lang) || 'zhCN'
|
|
20
|
+
|
|
11
21
|
const customCreateI18n = ({ locale, messages }) =>
|
|
12
22
|
createI18n({
|
|
13
23
|
locale, // set locale
|
|
@@ -15,7 +25,6 @@ const customCreateI18n = ({ locale, messages }) =>
|
|
|
15
25
|
fallbackLocale: 'zhCN', // set fallback locale
|
|
16
26
|
messages // set locale messages
|
|
17
27
|
})
|
|
18
|
-
|
|
19
28
|
const i18n = initI18n({
|
|
20
29
|
createI18n: customCreateI18n,
|
|
21
30
|
i18n: {
|
|
@@ -24,7 +33,17 @@ const i18n = initI18n({
|
|
|
24
33
|
messages
|
|
25
34
|
})
|
|
26
35
|
const i18nByKey = i18n.global.t
|
|
27
|
-
const getWord = (cn, en) =>
|
|
36
|
+
const getWord = (cn, en, es, pt) => {
|
|
37
|
+
const localeMap = new Map([
|
|
38
|
+
['zhCN', cn], // 简体中文
|
|
39
|
+
['enUS', en], // 英语
|
|
40
|
+
['esLA', es], // 西班牙语
|
|
41
|
+
['ptBR', pt] // 葡萄牙语
|
|
42
|
+
])
|
|
43
|
+
const currentLocale = i18n.global.locale
|
|
44
|
+
|
|
45
|
+
return localeMap.get(currentLocale) ?? cn
|
|
46
|
+
}
|
|
28
47
|
|
|
29
48
|
export { i18n, i18nByKey, getWord }
|
|
30
49
|
|
package/src/i18n/pt.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"zh-cn": "Chinese",
|
|
3
|
+
"en-us": "English",
|
|
4
|
+
"es-la": "Spanish",
|
|
5
|
+
"pt-br": "Portuguese",
|
|
6
|
+
"localeType": "Language Selection",
|
|
7
|
+
"dark": "Dark",
|
|
8
|
+
"light": "Light",
|
|
9
|
+
"searchPlaceholder": "Search",
|
|
10
|
+
"home": "Home",
|
|
11
|
+
"doc": "Docs",
|
|
12
|
+
"component": "Components",
|
|
13
|
+
"common": "Common",
|
|
14
|
+
"apiPreference": "Framework",
|
|
15
|
+
"apiTiny": "Vue",
|
|
16
|
+
"yan-shi": "Demo",
|
|
17
|
+
"demos": "Demos",
|
|
18
|
+
"api": "API",
|
|
19
|
+
"name": "Name",
|
|
20
|
+
"propType": "Type",
|
|
21
|
+
"defValue": "Default",
|
|
22
|
+
"typeValue": "Option Value",
|
|
23
|
+
"desc": "Description",
|
|
24
|
+
"showCode": "Show Code",
|
|
25
|
+
"hideCode": "Hide Code",
|
|
26
|
+
"copyCode": "Copy Code",
|
|
27
|
+
"doc-owner": "Owner",
|
|
28
|
+
"copyCodeOk": "Copy Success",
|
|
29
|
+
"frameAngular": "Angular",
|
|
30
|
+
"playground": "Open Playground",
|
|
31
|
+
"changeLanguage": "Change Language",
|
|
32
|
+
"changeTheme": "Change Components Theme",
|
|
33
|
+
"changeApiType": "Change Api Type",
|
|
34
|
+
"backTop": "Back To Top",
|
|
35
|
+
"overview": "Components Overview",
|
|
36
|
+
"overviewDesc": "TinyVue provides a wealth of basic UI components for web applications, and we will continue to explore the best UI practices for enterprise-level applications. Welcome to try TinyVue.",
|
|
37
|
+
"overviewDescPlus": "TinyVuePlus is a component library for Cloud business scenarios based on TinyVue, following the new design specifications of Cloud CloudDesign and utilizing Vite+Vue3+TypeScript technology stack.",
|
|
38
|
+
"searchComponents": "search components",
|
|
39
|
+
"apiType": "Components demos code style",
|
|
40
|
+
"apiStyleOptions": "Options",
|
|
41
|
+
"apiStyleComposition": "Composition",
|
|
42
|
+
"demoMode": "Demo display mode",
|
|
43
|
+
"demoModeSingle": "Single",
|
|
44
|
+
"demoModeMultiple": "Multiple",
|
|
45
|
+
"contributor": "Contributors",
|
|
46
|
+
"noData": "No Data"
|
|
47
|
+
}
|
package/src/i18n/zh.json
CHANGED
package/src/main.js
CHANGED
|
@@ -2,9 +2,6 @@ import { createHead } from '@vueuse/head'
|
|
|
2
2
|
import { createApp } from 'vue'
|
|
3
3
|
import '@unocss/reset/eric-meyer.css'
|
|
4
4
|
|
|
5
|
-
// tiny-robot 对话框
|
|
6
|
-
import '@opentiny/tiny-robot/dist/style.css'
|
|
7
|
-
|
|
8
5
|
// markdown文件内代码高亮
|
|
9
6
|
import 'prismjs/themes/prism.css'
|
|
10
7
|
import 'uno.css'
|
|
@@ -19,11 +16,11 @@ import './assets/custom-markdown.css'
|
|
|
19
16
|
import './assets/custom-block.less'
|
|
20
17
|
import './assets/md-preview.less'
|
|
21
18
|
|
|
22
|
-
import { i18n
|
|
19
|
+
import { i18n } from './i18n/index'
|
|
23
20
|
import { router } from './router'
|
|
24
21
|
import App from './App.vue'
|
|
25
22
|
import { appData } from './tools'
|
|
26
|
-
import { ZH_CN_LANG, EN_US_LANG, LANG_PATH_MAP } from './const'
|
|
23
|
+
import { ZH_CN_LANG, EN_US_LANG, LANG_PATH_MAP, ES_LA_LANG, PT_BR_LANG } from './const'
|
|
27
24
|
import demoConfig from '@demos/config.js'
|
|
28
25
|
|
|
29
26
|
import hljs from 'highlight.js/lib/core'
|
|
@@ -34,13 +31,11 @@ import tsPath from 'highlight.js/lib/languages/typescript'
|
|
|
34
31
|
import docsearch from '@docsearch/js'
|
|
35
32
|
import '@docsearch/css'
|
|
36
33
|
import { doSearchEverySite } from './tools/docsearch'
|
|
34
|
+
import { getLocaleMode } from './tools/utils.js'
|
|
37
35
|
import '@opentiny/vue-theme/dark-theme-index.css'
|
|
38
|
-
|
|
39
|
-
import { registerMcpConfig } from '@opentiny/vue-common'
|
|
40
36
|
import { createMcpTools, getTinyVueMcpConfig } from '@opentiny/tiny-vue-mcp'
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
registerMcpConfig(getTinyVueMcpConfig({ t }), createMcpTools)
|
|
37
|
+
import { t } from '@opentiny/vue-locale'
|
|
38
|
+
import { registerMcpConfig } from '@opentiny/vue-common'
|
|
44
39
|
|
|
45
40
|
const envTarget = import.meta.env.VITE_BUILD_TARGET || 'open'
|
|
46
41
|
|
|
@@ -74,12 +69,19 @@ setTimeout(() => {
|
|
|
74
69
|
|
|
75
70
|
const zhPath = LANG_PATH_MAP[ZH_CN_LANG]
|
|
76
71
|
const enPath = LANG_PATH_MAP[EN_US_LANG]
|
|
72
|
+
const esPath = LANG_PATH_MAP[ES_LA_LANG]
|
|
73
|
+
const ptPath = LANG_PATH_MAP[PT_BR_LANG]
|
|
77
74
|
const isZhCn = location.href.includes(`/${zhPath}`)
|
|
78
75
|
const isEnUs = location.href.includes(`/${enPath}`)
|
|
79
|
-
const
|
|
76
|
+
const isEsLa = location.href.includes(`/${esPath}`)
|
|
77
|
+
const isPtBr = location.href.includes(`/${ptPath}`)
|
|
78
|
+
const notMatchLang =
|
|
79
|
+
(isZhCn && appData.lang !== ZH_CN_LANG) ||
|
|
80
|
+
(isEnUs && appData.lang !== EN_US_LANG) ||
|
|
81
|
+
(isEsLa && appData.lang !== ES_LA_LANG) ||
|
|
82
|
+
(isPtBr && appData.lang !== PT_BR_LANG)
|
|
80
83
|
if (notMatchLang) {
|
|
81
|
-
|
|
82
|
-
appData.lang = isEnUs ? ZH_CN_LANG : ZH_CN_LANG
|
|
84
|
+
appData.lang = getLocaleMode()
|
|
83
85
|
i18n.global.locale = appData.lang
|
|
84
86
|
}
|
|
85
87
|
|
|
@@ -91,6 +93,8 @@ app.config.globalProperties.tiny_theme = { value: import.meta.env.VITE_TINY_THEM
|
|
|
91
93
|
if (import.meta.env.VITE_TINY_THEME === 'saas') {
|
|
92
94
|
import('./tailwind.css')
|
|
93
95
|
}
|
|
96
|
+
// 注册TinyVue组件mcp配置
|
|
97
|
+
registerMcpConfig(getTinyVueMcpConfig({ t }), createMcpTools)
|
|
94
98
|
|
|
95
99
|
app.use(router).use(i18n).use(createHead()) // 支持md修改title
|
|
96
100
|
|
package/src/router.js
CHANGED
|
@@ -7,29 +7,16 @@ const Components = () => import('@/views/components-doc/index.vue')
|
|
|
7
7
|
const Docs = () => import('@/views/docs/docs.vue')
|
|
8
8
|
const Overview = () => import('@/views/overview.vue')
|
|
9
9
|
const Features = () => import('@/views/features.vue')
|
|
10
|
-
const Comprehensive = () => import('@/views/comprehensive/index.vue')
|
|
11
|
-
const Remoter = () => import('@/views/remoter/index.vue')
|
|
12
10
|
|
|
13
11
|
const context = import.meta.env.VITE_CONTEXT
|
|
14
|
-
|
|
15
12
|
let routes = [
|
|
16
13
|
// 组件总览
|
|
17
14
|
{
|
|
18
|
-
path: `${context}:all
|
|
15
|
+
path: `${context}:all?/${LANG_PATH_MAP[appData.lang] || 'zh-CN'}/:theme/overview`,
|
|
19
16
|
component: Layout,
|
|
20
17
|
name: 'overview',
|
|
21
18
|
children: [{ name: 'Overview', path: '', component: Overview, meta: { title: '组件总览 | TinyVue' } }]
|
|
22
19
|
},
|
|
23
|
-
{
|
|
24
|
-
path: `${context}:all?/zh-CN/:theme/comprehensive`,
|
|
25
|
-
component: Comprehensive,
|
|
26
|
-
name: 'comprehensive'
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
path: `${context}:all?/zh-CN/:theme/remoter`,
|
|
30
|
-
component: Remoter,
|
|
31
|
-
name: 'remoter'
|
|
32
|
-
},
|
|
33
20
|
// 文档
|
|
34
21
|
{
|
|
35
22
|
path: `${context}:all?/:lang/:theme/docs/:docId`,
|
|
@@ -39,7 +26,7 @@ let routes = [
|
|
|
39
26
|
},
|
|
40
27
|
// 组件
|
|
41
28
|
{
|
|
42
|
-
path: `${context}:all
|
|
29
|
+
path: `${context}:all?/${LANG_PATH_MAP[appData.lang] || 'zh-CN'}/:theme/components/:cmpId`,
|
|
43
30
|
component: Layout,
|
|
44
31
|
name: 'components',
|
|
45
32
|
children: [{ name: 'Components', path: '', component: Components }]
|
|
@@ -55,7 +42,7 @@ let routes = [
|
|
|
55
42
|
{
|
|
56
43
|
path: '/:pathMatch(.*)*',
|
|
57
44
|
redirect: () => {
|
|
58
|
-
const langPath = LANG_PATH_MAP[ZH_CN_LANG]
|
|
45
|
+
const langPath = LANG_PATH_MAP[appData.lang] || LANG_PATH_MAP[ZH_CN_LANG]
|
|
59
46
|
return { path: `${context}${langPath}/${DEFAULT_THEME}/overview` }
|
|
60
47
|
}
|
|
61
48
|
}
|
|
@@ -70,7 +57,5 @@ router.afterEach((to, from) => {
|
|
|
70
57
|
if (to.meta.title) {
|
|
71
58
|
document.title = to.meta.title
|
|
72
59
|
}
|
|
73
|
-
// tiny-robot 通过路由,确定浮动区,是否显示AI按钮
|
|
74
|
-
appData.hasFloatRobot = to.path.endsWith('components/grid')
|
|
75
60
|
})
|
|
76
61
|
export { router }
|