create-young-proj 1.4.0 → 1.6.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.
Files changed (101) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/package.json +1 -1
  3. package/template-nuxt-admin/README.md +1 -1
  4. package/template-nuxt-admin/nuxt.config.ts +4 -5
  5. package/template-nuxt-admin/package.json +0 -1
  6. package/template-nuxt-admin/server/plugins/env.ts +8 -0
  7. package/template-nuxt-admin/yarn.lock +0 -5
  8. package/template-nuxt-mobile/.nvmrc +1 -0
  9. package/{template-vue-mobile → template-nuxt-mobile}/.vscode/extensions.json +5 -3
  10. package/template-nuxt-mobile/.vscode/settings.json +39 -0
  11. package/{template-vue-mobile → template-nuxt-mobile}/Dockerfile +12 -13
  12. package/template-nuxt-mobile/README.md +90 -0
  13. package/template-nuxt-mobile/_gitignore +26 -0
  14. package/template-nuxt-mobile/_npmrc +2 -0
  15. package/template-nuxt-mobile/_nvmrc +1 -0
  16. package/template-nuxt-mobile/app.vue +79 -0
  17. package/template-nuxt-mobile/boot.mjs +17 -0
  18. package/template-nuxt-mobile/components/young/CodeInput.vue +72 -0
  19. package/template-nuxt-mobile/composables/api.ts +57 -0
  20. package/template-nuxt-mobile/composables/apis/get.ts +22 -0
  21. package/template-nuxt-mobile/composables/apis/index.ts +8 -0
  22. package/template-nuxt-mobile/composables/apis/post.ts +39 -0
  23. package/template-nuxt-mobile/composables/share.ts +22 -0
  24. package/template-nuxt-mobile/composables/user.ts +48 -0
  25. package/template-nuxt-mobile/composables/utils.ts +80 -0
  26. package/template-nuxt-mobile/config/.devrc +2 -0
  27. package/template-nuxt-mobile/env.d.ts +65 -0
  28. package/template-nuxt-mobile/error.vue +69 -0
  29. package/template-nuxt-mobile/eslint.config.js +33 -0
  30. package/template-nuxt-mobile/layouts/blank.vue +11 -0
  31. package/template-nuxt-mobile/layouts/default.vue +32 -0
  32. package/template-nuxt-mobile/layouts/tabbar.vue +29 -0
  33. package/template-nuxt-mobile/middleware/auth.global.ts +34 -0
  34. package/template-nuxt-mobile/nuxt.config.ts +78 -0
  35. package/template-nuxt-mobile/package.json +40 -0
  36. package/template-nuxt-mobile/pages/base/login.vue +124 -0
  37. package/template-nuxt-mobile/pages/base/resetPasswd.vue +84 -0
  38. package/template-nuxt-mobile/pages/index.vue +22 -0
  39. package/template-nuxt-mobile/pages/my.vue +18 -0
  40. package/template-nuxt-mobile/pages/sub/[id].vue +21 -0
  41. package/template-nuxt-mobile/public/favicon.ico +0 -0
  42. package/template-nuxt-mobile/public/robots.txt +2 -0
  43. package/template-nuxt-mobile/server/plugins/init.ts +94 -0
  44. package/template-nuxt-mobile/server/routes/get/env.ts +13 -0
  45. package/template-nuxt-mobile/server/tsconfig.json +3 -0
  46. package/template-nuxt-mobile/server/utils/index.ts +12 -0
  47. package/template-nuxt-mobile/server/utils/proxy.ts +59 -0
  48. package/template-nuxt-mobile/tsconfig.json +4 -0
  49. package/template-nuxt-mobile/typings/system.d.ts +22 -0
  50. package/template-nuxt-mobile/uno.config.ts +40 -0
  51. package/template-nuxt-mobile/utils/tool.ts +153 -0
  52. package/template-nuxt-mobile/yarn.lock +7737 -0
  53. package/template-nuxt-website/README.md +3 -1
  54. package/template-nuxt-website/nuxt.config.ts +4 -5
  55. package/template-vitepress/Dockerfile +6 -2
  56. package/template-vue-mobile/.vscode/base.code-snippets +0 -24
  57. package/template-vue-mobile/.vscode/settings.json +0 -7
  58. package/template-vue-mobile/README.md +0 -71
  59. package/template-vue-mobile/_env +0 -6
  60. package/template-vue-mobile/_gitignore +0 -30
  61. package/template-vue-mobile/boot.mjs +0 -16
  62. package/template-vue-mobile/build/custom-plugin.ts +0 -30
  63. package/template-vue-mobile/build/index.ts +0 -7
  64. package/template-vue-mobile/build/plugins.ts +0 -68
  65. package/template-vue-mobile/config/.devrc +0 -2
  66. package/template-vue-mobile/index.html +0 -25
  67. package/template-vue-mobile/nitro.config.ts +0 -19
  68. package/template-vue-mobile/package.json +0 -48
  69. package/template-vue-mobile/plugins/env.ts +0 -26
  70. package/template-vue-mobile/public/vite.svg +0 -1
  71. package/template-vue-mobile/rome.json +0 -24
  72. package/template-vue-mobile/routes/[...all].ts +0 -11
  73. package/template-vue-mobile/routes/get/env.ts +0 -25
  74. package/template-vue-mobile/src/App.vue +0 -29
  75. package/template-vue-mobile/src/auto-components.d.ts +0 -24
  76. package/template-vue-mobile/src/auto-imports.d.ts +0 -289
  77. package/template-vue-mobile/src/components/Init.vue +0 -36
  78. package/template-vue-mobile/src/global.d.ts +0 -7
  79. package/template-vue-mobile/src/hooks/useVerifyCode.ts +0 -46
  80. package/template-vue-mobile/src/layouts/blank.vue +0 -9
  81. package/template-vue-mobile/src/layouts/default.vue +0 -27
  82. package/template-vue-mobile/src/layouts/sub.vue +0 -20
  83. package/template-vue-mobile/src/main.ts +0 -35
  84. package/template-vue-mobile/src/modules/1-router.ts +0 -40
  85. package/template-vue-mobile/src/modules/2-pinia.ts +0 -10
  86. package/template-vue-mobile/src/modules/3-net.ts +0 -46
  87. package/template-vue-mobile/src/modules/4-auth.ts +0 -64
  88. package/template-vue-mobile/src/views/[...all_404].vue +0 -557
  89. package/template-vue-mobile/src/views/base/login.vue +0 -110
  90. package/template-vue-mobile/src/views/base/resetPasswd.vue +0 -88
  91. package/template-vue-mobile/src/views/index.vue +0 -18
  92. package/template-vue-mobile/src/views/my.vue +0 -15
  93. package/template-vue-mobile/src/views/sub.vue +0 -18
  94. package/template-vue-mobile/src/vite-env.d.ts +0 -43
  95. package/template-vue-mobile/tsconfig.json +0 -21
  96. package/template-vue-mobile/tsconfig.node.json +0 -9
  97. package/template-vue-mobile/unocss.config.ts +0 -47
  98. package/template-vue-mobile/vite.config.ts +0 -32
  99. package/template-vue-mobile/yarn.lock +0 -4395
  100. /package/{template-vue-mobile → template-nuxt-mobile}/config/.onlinerc +0 -0
  101. /package/{template-vue-mobile → template-nuxt-mobile}/config/.testrc +0 -0
package/CHANGELOG.md CHANGED
@@ -1,6 +1,38 @@
1
1
  # Changelog
2
2
 
3
3
 
4
+ ## v1.6.0
5
+
6
+ [compare changes](https://github.com/BluesYoung-web/create-young-proj/compare/v1.5.0...v1.6.0)
7
+
8
+ ### 🚀 Enhancements
9
+
10
+ - 🚀 优化后台移动端表现 ([7895259](https://github.com/BluesYoung-web/create-young-proj/commit/7895259))
11
+ - 🚀 template-nuxt-mobile ([664dcdb](https://github.com/BluesYoung-web/create-young-proj/commit/664dcdb))
12
+
13
+ ### 🏡 Chore
14
+
15
+ - 🏡 后台无用依赖删除 ([48ce806](https://github.com/BluesYoung-web/create-young-proj/commit/48ce806))
16
+ - 🏡 remove template-vue-mobile ([df30f76](https://github.com/BluesYoung-web/create-young-proj/commit/df30f76))
17
+ - 🏡 后台模板兼容配置调整 ([f662f94](https://github.com/BluesYoung-web/create-young-proj/commit/f662f94))
18
+ - 🏡 官网模板兼容配置调整 ([3138569](https://github.com/BluesYoung-web/create-young-proj/commit/3138569))
19
+
20
+ ### ❤️ Contributors
21
+
22
+ - 张扬 <bluesyoung_web@163.com>
23
+
24
+ ## v1.5.0
25
+
26
+ [compare changes](https://github.com/BluesYoung-web/create-young-proj/compare/v1.4.0...v1.5.0)
27
+
28
+ ### 🩹 Fixes
29
+
30
+ - 🩹 fix Dockerfile ([b29b402](https://github.com/BluesYoung-web/create-young-proj/commit/b29b402))
31
+
32
+ ### ❤️ Contributors
33
+
34
+ - 张扬 <bluesyoung_web@163.com>
35
+
4
36
  ## v1.4.0
5
37
 
6
38
  [compare changes](https://github.com/BluesYoung-web/create-young-proj/compare/v1.3.0...v1.4.0)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "create-young-proj",
3
3
  "type": "module",
4
- "version": "1.4.0",
4
+ "version": "1.6.0",
5
5
  "description": "create project from template",
6
6
  "author": "BluesYoung-web",
7
7
  "license": "MIT",
@@ -80,7 +80,7 @@ npm i -g young-commit
80
80
 
81
81
  兼容 `PC` 端与移动端
82
82
 
83
- **移动端最低兼容钉钉浏览器**
83
+ **理论上最低兼容 `chrome58`**
84
84
 
85
85
  ## 常用的操作
86
86
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * @Author: zhangyang
3
3
  * @Date: 2023-09-21 15:57:55
4
- * @LastEditTime: 2023-11-15 11:52:33
4
+ * @LastEditTime: 2023-11-30 11:03:49
5
5
  * @Description:
6
6
  */
7
7
  import { resolve } from 'node:path'
@@ -84,11 +84,10 @@ export default defineNuxtConfig({
84
84
 
85
85
  vite: {
86
86
  build: {
87
- // 兼容钉钉浏览器
88
- target: 'es2015',
89
87
  sourcemap: false,
90
- /* hack fix 360 极速浏览器 13.5 不支持 inset */
91
- cssTarget: 'chrome61',
88
+ // 兼容旧浏览器
89
+ target: ['chrome58'],
90
+ cssTarget: ['chrome58'],
92
91
  },
93
92
  css: {
94
93
  preprocessorOptions: {
@@ -42,7 +42,6 @@
42
42
  "@unocss/nuxt": "^0.57.2",
43
43
  "@vant/nuxt": "^1.0.2",
44
44
  "@vueuse/nuxt": "^10.2.1",
45
- "add": "^2.0.6",
46
45
  "dayjs": "^1.11.9",
47
46
  "element-plus": "^2.3.8",
48
47
  "eslint": "^8.48.0",
@@ -62,6 +62,14 @@ export default defineNitroPlugin(async (nitroApp) => {
62
62
  })
63
63
 
64
64
  nitroApp.hooks.hook('render:html', (html, { event }) => {
65
+ // 设定视口高度,防止软键盘影响布局
66
+ html.bodyPrepend.push(`
67
+ <script>
68
+ const metaElement = document.querySelector('#viewportMeta');
69
+ metaElement.setAttribute('content', \`maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0,height=\${window.innerHeight}\`);
70
+ </script>
71
+ `)
72
+
65
73
  // 直接注入环境变量到前端
66
74
  html.bodyPrepend.push(`
67
75
  <!-- 注入环境变量 -->
@@ -2284,11 +2284,6 @@ acorn@8.11.2, acorn@^8.10.0, acorn@^8.5.0, acorn@^8.6.0, acorn@^8.8.2, acorn@^8.
2284
2284
  resolved "https://registry.npmmirror.com/acorn/-/acorn-8.11.2.tgz#ca0d78b51895be5390a5903c5b3bdcdaf78ae40b"
2285
2285
  integrity sha512-nc0Axzp/0FILLEVsm4fNwLCwMttvhEI263QtVPQcbpfZZ3ts0hLsZGOpE6czNlid7CJ9MlyH8reXkpsf3YUY4w==
2286
2286
 
2287
- add@^2.0.6:
2288
- version "2.0.6"
2289
- resolved "https://registry.npmmirror.com/add/-/add-2.0.6.tgz#248f0a9f6e5a528ef2295dbeec30532130ae2235"
2290
- integrity sha512-j5QzrmsokwWWp6kUcJQySpbG+xfOBqqKnup3OIk1pz+kB/80SLorZ9V8zHFLO92Lcd+hbvq8bT+zOGoPkmBV0Q==
2291
-
2292
2287
  adler-32@~1.3.0:
2293
2288
  version "1.3.1"
2294
2289
  resolved "https://registry.npmmirror.com/adler-32/-/adler-32-1.3.1.tgz#1dbf0b36dda0012189a32b3679061932df1821e2"
@@ -0,0 +1 @@
1
+ 20.9.0
@@ -1,10 +1,12 @@
1
1
  {
2
2
  "recommendations": [
3
- "vue.volar",
4
- "rome.rome",
5
- "obkoro1.korofileheader",
3
+ "dbaeumer.vscode-eslint",
4
+ "editorconfig.editorconfig",
5
+ "mhutchie.git-graph",
6
6
  "vue.vscode-typescript-vue-plugin",
7
7
  "antfu.unocss",
8
+ "antfu.vscode-server-controller",
9
+ "vue.volar",
8
10
  "voorjaar.windicss-intellisense"
9
11
  ]
10
12
  }
@@ -0,0 +1,39 @@
1
+ {
2
+ "prettier.enable": false,
3
+ "editor.formatOnSave": false,
4
+
5
+ // Enable the ESlint flat config support
6
+ "eslint.experimental.useFlatConfig": true,
7
+ // Auto fix
8
+ "editor.codeActionsOnSave": {
9
+ "source.fixAll.eslint": "explicit",
10
+ "source.organizeImports": "never"
11
+ },
12
+
13
+ // Silent the stylistic rules in you IDE, but still auto fix them
14
+ "eslint.rules.customizations": [
15
+ { "rule": "style/*", "severity": "off" },
16
+ { "rule": "*-indent", "severity": "off" },
17
+ { "rule": "*-spacing", "severity": "off" },
18
+ { "rule": "*-spaces", "severity": "off" },
19
+ { "rule": "*-order", "severity": "off" },
20
+ { "rule": "*-dangle", "severity": "off" },
21
+ { "rule": "*-newline", "severity": "off" },
22
+ { "rule": "*quotes", "severity": "off" },
23
+ { "rule": "*semi", "severity": "off" }
24
+ ],
25
+
26
+ // Enable eslint for all supported languages
27
+ "eslint.validate": [
28
+ "javascript",
29
+ "javascriptreact",
30
+ "typescript",
31
+ "typescriptreact",
32
+ "vue",
33
+ "html",
34
+ "markdown",
35
+ "json",
36
+ "jsonc",
37
+ "yaml"
38
+ ]
39
+ }
@@ -1,8 +1,14 @@
1
1
  # 拉取基础镜像
2
- FROM node:16-alpine as builder
2
+ FROM intranet-harbor.laiyouxi.com/base/alpine/node:20.9.0 as builder
3
+ # 添加部分元数据,暂无意义
4
+ LABEL vendor="Lyx-yunwei" \
5
+ com.example.release-date="2022-11-10" \
6
+ com.example.version.is-production="false"
3
7
 
4
8
  # 维护者
5
9
  MAINTAINER BluesYoung "bluesyoung_web@163.com"
10
+ # 配置环境变量
11
+ ENV WORK_DIR=/app
6
12
 
7
13
  # 工作目录
8
14
  WORKDIR /app
@@ -23,20 +29,13 @@ COPY . /app
23
29
  RUN yarn build
24
30
 
25
31
  # 打包完成,构建最终的极简镜像
26
- FROM node:16-alpine
32
+ FROM intranet-harbor.laiyouxi.com/base/alpine/node:20.9.0
27
33
 
28
- # 工作目录
29
34
  WORKDIR /app
30
-
31
- # 复制运行需要的文件[及依赖]
32
- # 直接复制源代码
35
+ # 复制源码
33
36
  COPY boot.mjs /app/
34
37
  COPY config /app/config
35
- # 复制上一步的打包产物
36
- COPY --from=builder /app/.output /app/.output
37
-
38
- # 暴露指定的端口号,暂不需要
39
- # EXPOSE 3001
38
+ # 复制编译后的代码
39
+ COPY --from=builder /app/dist /app/dist
40
40
 
41
- # 启动容器时运行的命令
42
- ENTRYPOINT ["node", "boot.mjs"]
41
+ ENTRYPOINT ["node", "boot.mjs"]
@@ -0,0 +1,90 @@
1
+ # 基于 Nuxt 3 的服务端渲染响应式网站
2
+
3
+
4
+ [![](https://img.shields.io/badge/Author-BluesYoung--web-blue)](https://gitee.com/BluesYoung-web)
5
+
6
+ [![code style](https://antfu.me/badge-code-style.svg)](https://github.com/antfu/eslint-config)
7
+
8
+ ## 特性
9
+
10
+ - 基于 [@nuxtjs/device](https://github.com/nuxt-modules/device) 的设备判断
11
+
12
+ - 基于 [@unocss/nuxt](https://github.com/unocss/unocss) 的样式自动生成
13
+
14
+ - 理论最低兼容 `chrome58`
15
+
16
+ ## 配套 git 提交工具
17
+
18
+ ### 安装
19
+
20
+ ```bash
21
+ npm i -g young-commit
22
+ ```
23
+
24
+ ### 使用
25
+
26
+ - 正常使用 `git add` 将要提交的文件添加到暂存区
27
+
28
+ - 提交步骤使用 `yc` 或者 `young-commit` 进行提交
29
+
30
+ #### 命令选项
31
+
32
+ - `yc -i` 初始化(仅刚创建项目时使用,会自动执行 `git init`)
33
+
34
+ - `yc -r` 进行版本发布,会根据之前的提交及最近一个 `tag` 生成 `changelog`
35
+
36
+
37
+ ## 使用响应式布局
38
+
39
+ 兼容 `PC` 端与移动端,大屏表现为 `800px` 居中
40
+
41
+ ## 常用的操作
42
+
43
+ ### 抛出错误
44
+
45
+ ```ts
46
+ throw createError({ statusCode: 404, message: '数据迷路了' })
47
+ ```
48
+
49
+ ### 响应式屏幕尺寸
50
+
51
+
52
+ ```ts
53
+ /*
54
+ export const WindowSize = reactive({
55
+ 'lt-sm': useMediaQuery('(max-width: 639.9px)'),
56
+ 'sm': useMediaQuery('(min-width: 640px)'),
57
+ 'lt-md': useMediaQuery('(max-width: 767.9px)'),
58
+ 'md': useMediaQuery('(min-width: 768px)'),
59
+ 'lt-lg': useMediaQuery('(max-width: 1023.9px)'),
60
+ 'lg': useMediaQuery('(min-width: 1024px)'),
61
+ 'lt-xl': useMediaQuery('(max-width: 1279.9px)'),
62
+ 'xl': useMediaQuery('(min-width: 1280px)'),
63
+ 'lt-2xl': useMediaQuery('(max-width: 1535.9px)'),
64
+ '2xl': useMediaQuery('(min-width: 1536px)'),
65
+ });
66
+ */
67
+ ```
68
+
69
+ ### 设备判断
70
+
71
+ ```ts
72
+ const $device = useDevice()
73
+
74
+ $device.isDesktop
75
+ $device.isMobile
76
+ $device.isTablet
77
+ $device.isMobileOrTablet
78
+ $device.isDesktopOrTablet
79
+ $device.isIos
80
+ $device.isWindows
81
+ $device.isMacOS
82
+ $device.isApple
83
+ $device.isAndroid
84
+ $device.isFirefox
85
+ $device.isEdge
86
+ $device.isChrome
87
+ $device.isSafari
88
+ $device.isSamsung
89
+ $device.isCrawler
90
+ ```
@@ -0,0 +1,26 @@
1
+ # Nuxt dev/build outputs
2
+ .output
3
+ .data
4
+ .nuxt
5
+ .nitro
6
+ .cache
7
+ dist
8
+
9
+ # Node dependencies
10
+ node_modules
11
+
12
+ # Logs
13
+ logs
14
+ *.log
15
+
16
+ # Misc
17
+ .DS_Store
18
+ .fleet
19
+ .idea
20
+
21
+ # Local env files
22
+ .env
23
+ .env.*
24
+ !.env.example
25
+
26
+ config/*.js
@@ -0,0 +1,2 @@
1
+ shamefully-hoist=true
2
+ strict-peer-dependencies=false
@@ -0,0 +1 @@
1
+ 20.9.0
@@ -0,0 +1,79 @@
1
+ <!--
2
+ * @Author: zhangyang
3
+ * @Date: 2023-05-25 19:53:07
4
+ * @LastEditTime: 2023-11-29 16:57:22
5
+ * @Description:
6
+ -->
7
+ <script lang="ts" setup>
8
+ import '@unocss/reset/tailwind-compat.css'
9
+
10
+ const app = useNuxtApp()
11
+
12
+ // !!! 这两个钩子函数不能异步调用,否则会造成页面的 useFetch 报错 !!!
13
+ app.hook('page:start', () => {
14
+ // console.log('loading...');
15
+ showLoading()
16
+ })
17
+ // !!! 这两个钩子函数不能异步调用,否则会造成页面的 useFetch 报错 !!!
18
+ app.hook('page:finish', () => {
19
+ // console.log('loading end ...')
20
+ hideLoading()
21
+ })
22
+
23
+ const title = process.server ? '' : window.__YOUNG_ENV__.VITE_TITLE
24
+ </script>
25
+
26
+ <template>
27
+ <Title>{{ title }}</Title>
28
+ <NuxtLayout>
29
+ <NuxtPage />
30
+ </NuxtLayout>
31
+ </template>
32
+
33
+ <style>
34
+ img,
35
+ video {
36
+ max-width: 100%;
37
+ height: auto;
38
+ }
39
+
40
+ .reset-img img,
41
+ .reset-img video,
42
+ .reset-img svg,
43
+ .reset-img audio {
44
+ display: initial;
45
+ }
46
+
47
+ ::-webkit-scrollbar {
48
+ width: 8px;
49
+ height: 8px
50
+ }
51
+
52
+ ::-webkit-scrollbar-track {
53
+ background-color: #fff;
54
+ border-radius: 2em
55
+ }
56
+
57
+ ::-webkit-scrollbar-thumb {
58
+ background-color: #aaa;
59
+ border-radius: 2em;
60
+ }
61
+
62
+ ::-webkit-scrollbar-corner {
63
+ background-color: transparent
64
+ }
65
+
66
+ :root {
67
+ --van-nav-bar-background: #0083CE !important;
68
+ --van-nav-bar-title-text-color: #FFFFFF !important;
69
+ --van-nav-bar-icon-color: #fff !important;
70
+ --van-grid-item-text-color: #111 !important;
71
+ }
72
+
73
+ html,
74
+ body {
75
+ width: 100%;
76
+ height: 100%;
77
+ background: #F7F8FA;
78
+ }
79
+ </style>
@@ -0,0 +1,17 @@
1
+ /*
2
+ * @Author: zhangyang
3
+ * @Date: 2022-09-07 09:31:12
4
+ * @LastEditTime: 2023-11-29 16:36:36
5
+ * @Description:
6
+ */
7
+ (async () => {
8
+ const env = process.env.DEPLOY_ENV
9
+ const listenPort = process.env.LISTEN_PORT || 3003
10
+
11
+ console.log('当前环境:', env)
12
+ console.log('服务监听端口:', listenPort)
13
+
14
+ process.env.NITRO_PORT = listenPort
15
+
16
+ await import('./dist/server/index.mjs')
17
+ })()
@@ -0,0 +1,72 @@
1
+ <!--
2
+ * @Author: zhangyang
3
+ * @Date: 2023-09-28 11:09:14
4
+ * @LastEditTime: 2023-11-29 17:36:42
5
+ * @Description:
6
+ -->
7
+ <script lang="ts" setup>
8
+ import { YoungSlideVerify } from '@bluesyoung/ui-vue3'
9
+ import { useVerifyCode } from '@bluesyoung/ui-vue3-element-plus'
10
+
11
+ interface Props {
12
+ modelValue: string
13
+ tel: string
14
+ maxlength?: number
15
+ forceEl?: boolean
16
+ }
17
+
18
+ const props = withDefaults(defineProps<Props>(), {
19
+ maxlength: 6,
20
+ forceEl: false,
21
+ })
22
+
23
+ const emit = defineEmits<{
24
+ (e: 'update:modelValue', v: string): void
25
+ (e: 'enter'): void
26
+ }>()
27
+
28
+ const canGet = computed(() => {
29
+ return props.tel.length === 11
30
+ })
31
+
32
+ const {
33
+ getCode,
34
+ tip,
35
+ showSlider,
36
+ pass,
37
+ cancel,
38
+ disabled,
39
+ } = useVerifyCode(async () => {
40
+ apis.get.sendCode(props.tel)
41
+ showNotify({
42
+ message: '短信已发送至您的手机,请注意查收!',
43
+ type: 'success',
44
+ })
45
+ })
46
+ </script>
47
+
48
+ <template>
49
+ <div class="w-full">
50
+ <VanField
51
+ v-bind="$attrs"
52
+ class="mt-4 rounded-md" :model-value="modelValue" type="text" placeholder="请输入验证码"
53
+ @update:model-value="(e) => emit('update:modelValue', e)" @keyup.enter="emit('enter')"
54
+ >
55
+ <template #button>
56
+ <VanButton v-if="!disabled" type="primary" class="!text-[#1AAADA]" :disabled="!canGet" plain @click="getCode">
57
+ {{ tip }}
58
+ </VanButton>
59
+ <div v-else class="text-[#ccc]">
60
+ {{ tip }}
61
+ </div>
62
+ </template>
63
+ </VanField>
64
+ <YoungSlideVerify :show="showSlider" @success="pass" @close="cancel" />
65
+ </div>
66
+ </template>
67
+
68
+ <style>
69
+ .vue-puzzle-vcode {
70
+ z-index: 10001 !important;
71
+ }
72
+ </style>
@@ -0,0 +1,57 @@
1
+ /*
2
+ * @Author: zhangyang
3
+ * @Date: 2023-06-20 17:14:58
4
+ * @LastEditTime: 2023-11-29 17:50:40
5
+ * @Description:
6
+ */
7
+ import { useHttp } from '@bluesyoung/http'
8
+ import { useGet, usePost } from './apis'
9
+
10
+ const http = useHttp<{
11
+ code: number
12
+ data: any
13
+ msg: string
14
+ }>({
15
+ timeout: -1,
16
+ loading: {
17
+ start: showLoading,
18
+ end: hideLoading,
19
+ },
20
+ fail: (err: any) => {
21
+ console.log('🚀 ~ file: api.ts:28 ~ err:', err)
22
+ const user = useUserStore()
23
+ if (err?.response?.status === 401) {
24
+ user.removeToken()
25
+ checkLogin(true)
26
+
27
+ throw err
28
+ }
29
+
30
+ if (typeof err === 'string') {
31
+ // 通用失败,弹出提示信息
32
+ ElMessage.error(err)
33
+ }
34
+ if ((err as any) instanceof Error) {
35
+ ElMessage.error(err?.response?.data?.message
36
+ || err?.response?.data?.msg
37
+ || err?.response?.data
38
+ || err.message
39
+ || '网络错误!')
40
+ }
41
+
42
+ throw err
43
+ },
44
+ headers: {
45
+ getAuthHeaders: () => {
46
+ const { token } = storeToRefs(useUserStore())
47
+ return {
48
+ Authorization: `Bearer ${token.value}`,
49
+ }
50
+ },
51
+ },
52
+ })
53
+
54
+ export const apis = http.__mixin__({
55
+ get: useGet(http),
56
+ post: usePost(http),
57
+ })
@@ -0,0 +1,22 @@
1
+ /*
2
+ * @Author: zhangyang
3
+ * @Date: 2023-07-21 09:09:37
4
+ * @LastEditTime: 2023-11-29 17:36:23
5
+ * @Description:
6
+ */
7
+ import type { YoungHttp, YoungHttpAuthReq, YoungHttpFreeReq } from '@bluesyoung/http'
8
+
9
+ export function useGet(http: YoungHttp) {
10
+ const FreeReq: YoungHttpFreeReq = args => http.freeReq({ method: 'GET', ...args })
11
+ const AuthReq: YoungHttpAuthReq = args => http.authReq({ method: 'GET', ...args })
12
+
13
+ return {
14
+ /**
15
+ * 发送短信验证码
16
+ */
17
+ sendCode: async (phone: string) => {
18
+ showToast(`todo: ${phone}发送短信验证码`)
19
+ // await FreeReq({ url: '/v1/user/sendCode', params: { phone } });
20
+ },
21
+ }
22
+ }
@@ -0,0 +1,8 @@
1
+ /*
2
+ * @Author: zhangyang
3
+ * @Date: 2023-07-21 09:22:00
4
+ * @LastEditTime: 2023-11-29 17:45:25
5
+ * @Description:
6
+ */
7
+ export * from './get'
8
+ export * from './post'
@@ -0,0 +1,39 @@
1
+ /*
2
+ * @Author: zhangyang
3
+ * @Date: 2023-07-21 09:21:02
4
+ * @LastEditTime: 2023-11-29 17:53:30
5
+ * @Description:
6
+ */
7
+ import type { YoungHttp, YoungHttpAuthReq, YoungHttpFreeReq } from '@bluesyoung/http'
8
+ import { telMasaike } from '@bluesyoung/utils'
9
+
10
+ export function usePost(http: YoungHttp) {
11
+ const FreeReq: YoungHttpFreeReq = args => http.freeReq({ method: 'POST', ...args })
12
+ const AuthReq: YoungHttpAuthReq = args => http.authReq({ method: 'POST', ...args })
13
+
14
+ return {
15
+ login: async (args: LoginForm) => {
16
+ console.log('🚀 ~ file: post.ts:15 ~ login: ~ args:', args)
17
+
18
+ return {
19
+ uuid: '9527',
20
+ nickname: '用户xxx',
21
+ headimgurl: 'https://avatars.githubusercontent.com/u/55608642?v=4',
22
+ token: 'xxxxxxxxx',
23
+ phone: telMasaike(args.tel),
24
+ } as UserLoginRes
25
+ },
26
+ changePassword: async (args: ResetPasswdForm) => {
27
+ console.log('🚀 ~ file: post.ts:15 ~ login: ~ args:', args)
28
+ showToast('todo: user change password')
29
+
30
+ return {
31
+ uuid: '9527',
32
+ nickname: '用户xxx',
33
+ headimgurl: 'https://avatars.githubusercontent.com/u/55608642?v=4',
34
+ token: 'xxx',
35
+ phone: telMasaike(args.tel),
36
+ } as UserLoginRes
37
+ },
38
+ }
39
+ }
@@ -0,0 +1,22 @@
1
+ /*
2
+ * @Author: zhangyang
3
+ * @Date: 2023-06-25 15:01:47
4
+ * @LastEditTime: 2023-09-27 12:00:49
5
+ * @Description:
6
+ */
7
+ export const useShareStore = defineStore('useShareStore', {
8
+ state: () => {
9
+ const jssdkShareSign = ref({
10
+ timestamp: '',
11
+ nonceStr: '',
12
+ signature: '',
13
+ })
14
+
15
+ return {
16
+ jssdkShareSign,
17
+ }
18
+ },
19
+ })
20
+
21
+ if (import.meta.hot)
22
+ import.meta.hot.accept(acceptHMRUpdate(useShareStore, import.meta.hot))