create-jnrs-template-vue 1.2.7 → 1.2.8

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 CHANGED
@@ -9,15 +9,18 @@ TypeScript、Vue3 生态
9
9
  ## 🧩 安装使用说明
10
10
  新项目默认名称为 jnrs-template-vue
11
11
  ```shell
12
- ✅ 正确用法
12
+ # ✅ 正确用法
13
+ # 创建新项目
13
14
  pnpm create jnrs-template-vue@latest
15
+ # 在当前目录下创建项目
16
+ pnpm create jnrs-template-vue@latest .
14
17
 
15
- cd jnrs-template-vue
18
+ # 安装依赖/启动开发/打包构建
16
19
  pnpm i
17
20
  pnpm dev
18
21
  pnpm build
19
22
 
20
- 错误用法(不要这样做!)
23
+ # 错误用法
21
24
  pnpm add create-jnrs-template-vue
22
25
  ```
23
26
 
package/bin/create.mjs CHANGED
@@ -1,3 +1,11 @@
1
+ /**
2
+ * @Author : TanRui
3
+ * @WeChat : Tan578853789
4
+ * @File : create.mjs
5
+ * @Date : 2026/01/01
6
+ * @Desc. : 脚手架创建脚本
7
+ */
8
+
1
9
  import { fileURLToPath } from 'url'
2
10
  import { dirname, join, relative } from 'path'
3
11
  import { promises as fs, existsSync } from 'fs'
@@ -68,6 +76,9 @@ async function main() {
68
76
  const argv = minimist(process.argv.slice(2), { string: ['_'] })
69
77
  let targetDir = argv._[0]
70
78
 
79
+ // 新增:判断是否使用当前目录
80
+ const isCurrentDir = targetDir === '.'
81
+
71
82
  if (!targetDir) {
72
83
  const { name } = await prompts({
73
84
  type: 'text',
@@ -85,7 +96,8 @@ async function main() {
85
96
  })
86
97
  if (!name) process.exit(1)
87
98
  targetDir = name
88
- } else {
99
+ } else if (!isCurrentDir) {
100
+ // 仅当不是当前目录时,才校验包名和目录是否存在
89
101
  if (!isValidPackageName(targetDir)) {
90
102
  console.error('❌ 无效的项目名称:', targetDir)
91
103
  console.error(' 包名称必须有效(小写、无空格等)')
@@ -97,7 +109,8 @@ async function main() {
97
109
  }
98
110
  }
99
111
 
100
- const root = join(process.cwd(), targetDir.trim())
112
+ // 设置根目录:如果是当前目录,则用 process.cwd()
113
+ const root = isCurrentDir ? process.cwd() : join(process.cwd(), targetDir.trim())
101
114
 
102
115
  // 复制模板
103
116
  const templateDir = join(__dirname, '..', 'jnrs-template-vue')
@@ -106,7 +119,13 @@ async function main() {
106
119
  // 更新 package.json
107
120
  const pkgPath = join(root, 'package.json')
108
121
  const pkg = JSON.parse(await fs.readFile(pkgPath, 'utf8'))
109
- pkg.name = toValidPackageName(targetDir)
122
+
123
+ // 如果是当前目录,使用当前文件夹名称作为包名;否则使用 targetDir
124
+ const pkgName = isCurrentDir
125
+ ? toValidPackageName(process.cwd().split(/[\\/]/).pop() || 'jnrs-template-vue')
126
+ : toValidPackageName(targetDir)
127
+
128
+ pkg.name = pkgName
110
129
  await fs.writeFile(pkgPath, JSON.stringify(pkg, null, 2))
111
130
 
112
131
  // 检测可用包管理器
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jnrs-template-vue",
3
- "version": "1.2.7",
3
+ "version": "1.2.8",
4
4
  "description": "JNRS 信息化管理系统",
5
5
  "author": "talia_tan",
6
6
  "private": true,
@@ -19,10 +19,11 @@
19
19
  },
20
20
  "dependencies": {
21
21
  "@element-plus/icons-vue": "^2.3.2",
22
- "@jnrs/shared": "1.1.11",
22
+ "@jnrs/shared": "1.1.12",
23
23
  "@jnrs/vue-core": "1.2.9",
24
+ "@jnrs/lingshu-smart": "2.2.3",
24
25
  "@vueuse/core": "^14.1.0",
25
- "element-plus": "^2.11.9",
26
+ "element-plus": "^2.13.3",
26
27
  "pinia": "^3.0.4",
27
28
  "pinia-plugin-persistedstate": "^4.7.1",
28
29
  "vue": "^3.5.25",
@@ -66,6 +66,17 @@
66
66
  },
67
67
  "component": "/visual/index"
68
68
  },
69
+ {
70
+ "path": "/lingshuSmart/editorPage",
71
+ "name": "LingshuSmartEditorPage",
72
+ "meta": {
73
+ "title": "Lingshu Smart",
74
+ "icon": "Promotion",
75
+ "noAuth": true,
76
+ "global": true
77
+ },
78
+ "component": "/lingshuSmart/editorPage"
79
+ },
69
80
  {
70
81
  "meta": {
71
82
  "title": "系统管理",
@@ -0,0 +1,150 @@
1
+ <template>
2
+ <div class="routerTabs">
3
+ <el-tabs v-model="activeTab" type="card" @tab-remove="removeTab" @tab-click="handleTabClick">
4
+ <el-tab-pane
5
+ v-for="item in tabs"
6
+ :key="item.fullPath"
7
+ :name="item.fullPath"
8
+ :closable="item.path !== HOME_PATH"
9
+ >
10
+ <template #label>
11
+ <span>{{ tabLabel(item) }}</span>
12
+ </template>
13
+ </el-tab-pane>
14
+ </el-tabs>
15
+ </div>
16
+ </template>
17
+
18
+ <script setup>
19
+ import { ref, watch, computed, onMounted } from 'vue'
20
+ import { useRouter, useRoute } from 'vue-router'
21
+
22
+ const HOME_PATH = '/home/index'
23
+ const router = useRouter()
24
+ const route = useRoute()
25
+
26
+ // 使用 fullPath 作为激活 Tab 的值
27
+ const activeTab = ref(route.fullPath)
28
+
29
+ // Tab 列表:每个 tab 包含 fullPath、path、meta
30
+ const tabs = ref([
31
+ {
32
+ fullPath: route.fullPath,
33
+ path: route.path,
34
+ meta: route.meta
35
+ }
36
+ ])
37
+
38
+ // 标签页标题计算
39
+ const tabLabel = computed(() => {
40
+ return function (item) {
41
+ let label = item.meta?.title || '未命名'
42
+ if (item.meta?.fullPathTitle) {
43
+ label = item.meta.fullPathTitle.replace(/,/g, '/')
44
+ }
45
+ return label
46
+ }
47
+ })
48
+
49
+ // 初始化:插入首页(如果当前不是首页)
50
+ onMounted(() => {
51
+ if (route.path !== HOME_PATH) {
52
+ tabs.value.unshift({
53
+ fullPath: HOME_PATH,
54
+ path: HOME_PATH,
55
+ meta: { title: '工作台' }
56
+ })
57
+ }
58
+ })
59
+
60
+ // 添加标签页(基于当前 route)
61
+ const addTab = () => {
62
+ const currentRoute = route
63
+
64
+ // 如果已存在相同 fullPath 的 Tab,直接激活,不重复添加
65
+ const existingTab = tabs.value.find((tab) => tab.fullPath === currentRoute.fullPath)
66
+ if (existingTab) {
67
+ activeTab.value = currentRoute.fullPath
68
+ return
69
+ }
70
+
71
+ // 添加新 Tab
72
+ tabs.value.push({
73
+ fullPath: currentRoute.fullPath,
74
+ path: currentRoute.path,
75
+ meta: currentRoute.meta
76
+ })
77
+ activeTab.value = currentRoute.fullPath
78
+ }
79
+
80
+ // 移除标签页
81
+ const removeTab = (targetFullPath) => {
82
+ if (targetFullPath === HOME_PATH) return
83
+
84
+ const currentIndex = tabs.value.findIndex((tab) => tab.fullPath === targetFullPath)
85
+ if (currentIndex === -1) return
86
+
87
+ // 删除 Tab
88
+ tabs.value.splice(currentIndex, 1)
89
+
90
+ // 如果删除的是当前激活的 Tab
91
+ if (activeTab.value === targetFullPath) {
92
+ const nextTab = tabs.value[currentIndex] || tabs.value[currentIndex - 1]
93
+ if (nextTab) {
94
+ activeTab.value = nextTab.fullPath
95
+ router.push(nextTab.fullPath)
96
+ } else {
97
+ // 回退到首页
98
+ activeTab.value = HOME_PATH
99
+ router.push(HOME_PATH)
100
+ }
101
+ }
102
+ }
103
+
104
+ // 监听路由变化(使用 fullPath)
105
+ watch(
106
+ () => route.fullPath,
107
+ (newFullPath) => {
108
+ // 避免由 Tab 点击触发的导航再次添加 Tab(防止循环)
109
+ if (newFullPath !== activeTab.value) {
110
+ addTab()
111
+ }
112
+ },
113
+ { immediate: true }
114
+ )
115
+
116
+ // 处理标签页点击
117
+ const handleTabClick = (tab) => {
118
+ const fullPath = tab.props.name // el-tab-pane 的 name 即 fullPath
119
+ if (fullPath !== activeTab.value) {
120
+ activeTab.value = fullPath
121
+ router.push(fullPath)
122
+ }
123
+ }
124
+ </script>
125
+
126
+ <style lang="scss" scoped>
127
+ .routerTabs {
128
+ :deep(.el-tabs__header) {
129
+ margin-bottom: 0;
130
+ height: 32px;
131
+ }
132
+ :deep(.el-tabs__item) {
133
+ color: #888;
134
+ font-size: 12px;
135
+ height: 32px;
136
+ }
137
+ :deep(.el-tabs__item.is-active) {
138
+ color: #09a2a5;
139
+ border-bottom-color: #f2f2f2;
140
+ }
141
+ :deep(.el-tabs__nav-prev) {
142
+ color: #09a2a5;
143
+ background: #fff;
144
+ }
145
+ :deep(.el-tabs__nav-next) {
146
+ color: #09a2a5;
147
+ background: #fff;
148
+ }
149
+ }
150
+ </style>
@@ -0,0 +1,9 @@
1
+ <script setup lang="ts">
2
+ import { LingshuSmartEditor } from '@jnrs/lingshu-smart/components'
3
+ </script>
4
+
5
+ <template>
6
+ <LingshuSmartEditor />
7
+ </template>
8
+
9
+ <style lang="scss" scoped></style>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-jnrs-template-vue",
3
- "version": "1.2.7",
3
+ "version": "1.2.8",
4
4
  "description": "巨能前端工程化开发,Vue 项目模板脚手架",
5
5
  "keywords": [
6
6
  "vue",