create-young-proj 1.7.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. package/CHANGELOG.md +117 -1
  2. package/README.md +6 -1
  3. package/dist/index.mjs +19 -19
  4. package/package.json +1 -1
  5. package/src/index.ts +6 -1
  6. package/template-admin-server/src/service/role.service.ts +5 -3
  7. package/template-big-screen/.editorconfig +14 -0
  8. package/template-big-screen/.nvmrc +1 -0
  9. package/template-big-screen/.vscode/extensions.json +12 -0
  10. package/template-big-screen/.vscode/settings.json +39 -0
  11. package/template-big-screen/Dockerfile +49 -0
  12. package/template-big-screen/README.md +20 -0
  13. package/template-big-screen/_gitignore +23 -0
  14. package/template-big-screen/_npmrc +2 -0
  15. package/template-big-screen/_nvmrc +1 -0
  16. package/template-big-screen/boot.mjs +16 -0
  17. package/template-big-screen/config/.devrc +1 -0
  18. package/template-big-screen/config/.onlinerc +1 -0
  19. package/template-big-screen/config/.testrc +1 -0
  20. package/template-big-screen/eslint.config.js +34 -0
  21. package/template-big-screen/index.html +48 -0
  22. package/template-big-screen/nitro.config.ts +23 -0
  23. package/template-big-screen/package.json +66 -0
  24. package/template-big-screen/plugins/init.ts +57 -0
  25. package/template-big-screen/public/favicon.svg +3 -0
  26. package/template-big-screen/routes/api/[...all].ts +19 -0
  27. package/template-big-screen/routes/get/env.ts +13 -0
  28. package/template-big-screen/src/App.vue +24 -0
  29. package/template-big-screen/src/apis/get.ts +77 -0
  30. package/template-big-screen/src/apis/index.ts +53 -0
  31. package/template-big-screen/src/apis/post.ts +14 -0
  32. package/template-big-screen/src/assets/data/china.json +1 -0
  33. package/template-big-screen/src/components/YoungCountUp.vue +29 -0
  34. package/template-big-screen/src/components/YoungECharts/config.ts +56 -0
  35. package/template-big-screen/src/components/YoungECharts/index.vue +111 -0
  36. package/template-big-screen/src/components/YoungHeader.vue +54 -0
  37. package/template-big-screen/src/components/YoungSectionContainer.vue +55 -0
  38. package/template-big-screen/src/components/YoungSectionHeader.vue +23 -0
  39. package/template-big-screen/src/composables/breakPoint.ts +20 -0
  40. package/template-big-screen/src/composables/dark.ts +52 -0
  41. package/template-big-screen/src/composables/echarts.ts +17 -0
  42. package/template-big-screen/src/composables/loadData.ts +38 -0
  43. package/template-big-screen/src/directives/ellipsis.ts +20 -0
  44. package/template-big-screen/src/directives/index.ts +13 -0
  45. package/template-big-screen/src/enums/breakpointEnum.ts +9 -0
  46. package/template-big-screen/src/layouts/404.vue +19 -0
  47. package/template-big-screen/src/layouts/blank.vue +9 -0
  48. package/template-big-screen/src/layouts/default.vue +17 -0
  49. package/template-big-screen/src/main.ts +59 -0
  50. package/template-big-screen/src/modules/index.ts +8 -0
  51. package/template-big-screen/src/modules/pinia.ts +11 -0
  52. package/template-big-screen/src/modules/router.ts +28 -0
  53. package/template-big-screen/src/pages/[...all].vue +16 -0
  54. package/template-big-screen/src/pages/electricity/build.vue +135 -0
  55. package/template-big-screen/src/pages/electricity/reliability.vue +137 -0
  56. package/template-big-screen/src/pages/electricity/sale-and-cost.vue +158 -0
  57. package/template-big-screen/src/pages/index.vue +59 -0
  58. package/template-big-screen/src/pages/kpi.vue +129 -0
  59. package/template-big-screen/src/pages/manage-improve.vue +114 -0
  60. package/template-big-screen/src/pages/social/condition.vue +202 -0
  61. package/template-big-screen/src/pages/social/electricity-usage.vue +140 -0
  62. package/template-big-screen/src/styles/index.scss +82 -0
  63. package/template-big-screen/tsconfig.json +38 -0
  64. package/template-big-screen/types/auto-imports.d.ts +949 -0
  65. package/template-big-screen/types/components.d.ts +19 -0
  66. package/template-big-screen/types/echarts.d.ts +36 -0
  67. package/template-big-screen/types/index.d.ts +45 -0
  68. package/template-big-screen/types/type.d.ts +38 -0
  69. package/template-big-screen/uno.config.ts +68 -0
  70. package/template-big-screen/vite.config.ts +131 -0
  71. package/template-big-screen/yarn.lock +7443 -0
  72. package/template-nuxt-admin/README.md +3 -3
  73. package/template-nuxt-admin/boot.mjs +4 -1
  74. package/template-nuxt-admin/composables/config.ts +2 -2
  75. package/template-nuxt-admin/config/.devrc +1 -1
  76. package/template-nuxt-admin/config/.onlinerc +1 -1
  77. package/template-nuxt-admin/config/.testrc +1 -1
  78. package/template-nuxt-admin/error.vue +3 -3
  79. package/template-nuxt-admin/nuxt.config.ts +33 -11
  80. package/template-nuxt-admin/package.json +14 -11
  81. package/template-nuxt-admin/pages/system/api.vue +6 -6
  82. package/template-nuxt-admin/pages/system/role.vue +4 -4
  83. package/template-nuxt-admin/pages/system/user.vue +4 -4
  84. package/template-nuxt-admin/server/api/[...all].ts +10 -3
  85. package/template-nuxt-admin/server/plugins/env.ts +5 -4
  86. package/template-nuxt-admin/uno.config.ts +1 -9
  87. package/template-nuxt-admin/yarn.lock +5271 -4123
  88. package/template-nuxt-mobile/package.json +1 -0
  89. package/template-nuxt-mobile/server/utils/proxy.ts +1 -30
  90. package/template-nuxt-mobile/yarn.lock +9 -0
  91. package/template-nuxt-website/app.vue +45 -1
  92. package/template-nuxt-website/layouts/default.vue +18 -16
  93. package/template-nuxt-website/layouts/home.vue +14 -12
  94. package/template-nuxt-website/layouts/tabbar.vue +18 -16
  95. package/template-nuxt-website/nuxt.config.ts +20 -5
  96. package/template-nuxt-website/package.json +3 -1
  97. package/template-nuxt-website/server/utils/proxy.ts +1 -30
  98. package/template-nuxt-website/yarn.lock +4683 -3595
  99. package/template-nuxt-admin/server/utils/index.ts +0 -36
@@ -0,0 +1,49 @@
1
+ # 拉取基础镜像
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"
7
+
8
+ # 维护者
9
+ MAINTAINER BluesYoung "bluesyoung_web@163.com"
10
+
11
+ # 配置环境变量
12
+ ENV WORK_DIR=/app
13
+
14
+ # 工作目录
15
+ WORKDIR /app
16
+
17
+ # 没有压缩包,首选 COPY,如果需要自动解包或下载,则使用 ADD
18
+
19
+ # 对比依赖是否变更
20
+ COPY package.json yarn.lock /app/
21
+
22
+ # 设置npm仓库 + 下载依赖,上面的文件如果没有变化则跳过下载,直接使用缓存
23
+ RUN npm config set registry https://registry.npmmirror.com && \
24
+ yarn config set registry https://registry.npmmirror.com && \
25
+ yarn
26
+
27
+ # 加入代码
28
+ COPY . /app
29
+ # 打包
30
+ RUN yarn build
31
+
32
+ # 打包完成,构建最终的极简镜像
33
+ FROM intranet-harbor.laiyouxi.com/base/alpine/node:20.9.0
34
+
35
+ # 工作目录
36
+ WORKDIR /app
37
+
38
+ # 复制运行需要的文件[及依赖]
39
+ # 直接复制源代码
40
+ COPY boot.mjs /app/
41
+ COPY config /app/config
42
+ # 复制上一步的打包产物,.out 为 nitropack 打包后的目录
43
+ COPY --from=builder /app/.output /app/.output
44
+
45
+ # 暴露指定的端口号,暂不需要
46
+ # EXPOSE 3001
47
+
48
+ # 启动容器时运行的命令
49
+ ENTRYPOINT ["node", "boot.mjs"]
@@ -0,0 +1,20 @@
1
+ ## 大屏系统
2
+
3
+ [![](https://img.shields.io/badge/Author-BluesYoung--web-blue)](https://gitee.com/BluesYoung-web)
4
+
5
+ [![code style](https://antfu.me/badge-code-style.svg)](https://github.com/antfu/eslint-config)
6
+
7
+ ### 组件库
8
+
9
+ > 可以预先提供给 `UI` 进行参考,减少双方工作量
10
+
11
+ [DataV](https://datav-vue3.netlify.app/)
12
+
13
+ ### todo
14
+
15
+ - [ ] 登录 + 权限控制
16
+ - [ ] 真实 api 接入
17
+
18
+ ### Credit
19
+
20
+ [电力大屏可视化 vue3](https://github.com/LeoKun1231/power-system-visualization)
@@ -0,0 +1,23 @@
1
+ # Nuxt dev/build outputs
2
+ .output
3
+ .nuxt
4
+ .nitro
5
+ .cache
6
+ dist
7
+
8
+ # Node dependencies
9
+ node_modules
10
+
11
+ # Logs
12
+ logs
13
+ *.log
14
+
15
+ # Misc
16
+ .DS_Store
17
+ .fleet
18
+ .idea
19
+
20
+ # Local env files
21
+ .env
22
+ .env.*
23
+ !.env.example
@@ -0,0 +1,2 @@
1
+ shamefully-hoist=true
2
+ strict-peer-dependencies=false
@@ -0,0 +1 @@
1
+ 20.9.0
@@ -0,0 +1,16 @@
1
+ /*
2
+ * @Author: zhangyang
3
+ * @Date: 2022-09-16 11:48:05
4
+ * @LastEditTime: 2023-11-09 11:59:07
5
+ * @Description:
6
+ */
7
+ (async () => {
8
+ const env = process.env.DEPLOY_ENV || 'dev'
9
+ const listenPort = process.env.LISTEN_PORT || 3333
10
+ console.log('当前环境:', env)
11
+ console.log('服务监听端口:', listenPort)
12
+
13
+ process.env.NITRO_PORT = listenPort
14
+
15
+ await import('./.output/server/index.mjs')
16
+ })()
@@ -0,0 +1 @@
1
+ NUXT_PUBLIC_API_BASE = http://localhost:7001
@@ -0,0 +1 @@
1
+ NUXT_PUBLIC_API_BASE = http://localhost:9000
@@ -0,0 +1 @@
1
+ NUXT_PUBLIC_API_BASE = http://localhost:9000
@@ -0,0 +1,34 @@
1
+ /*
2
+ * @Author: zhangyang
3
+ * @Date: 2023-11-01 10:13:50
4
+ * @LastEditTime: 2024-02-02 15:33:54
5
+ * @Description:
6
+ */
7
+ import antfu from '@antfu/eslint-config'
8
+
9
+ export default antfu({
10
+ overrides: {
11
+ vue: {
12
+ 'vue/valid-v-model': 'off',
13
+ },
14
+ typescript: {
15
+ 'ts/no-use-before-define': 'off',
16
+ 'ts/no-unused-vars': 'off',
17
+ 'ts/ban-types': 'off',
18
+ 'ts/ban-ts-comment': 'off',
19
+ },
20
+ },
21
+ rules: {
22
+ 'no-console': 'off',
23
+ 'node/prefer-global/process': 'off',
24
+ 'unused-imports/no-unused-vars': 'off',
25
+ 'no-throw-literal': 'off',
26
+ 'antfu/consistent-list-newline': 'off',
27
+ 'style/jsx-indent': 'off',
28
+ },
29
+ }, {
30
+ ignores: [
31
+ 'public',
32
+ 'src/assets/*',
33
+ ],
34
+ })
@@ -0,0 +1,48 @@
1
+ <!DOCTYPE html>
2
+ <html lang="zh-CN">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" href="/favicon.svg" />
6
+ <meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no,shrink-to-fit=no" />
7
+ <meta name="theme-color" content="#fff" />
8
+ <meta name="screen-orientation" content="portrait" />
9
+ <meta name="x5-orientation" content="portrait" />
10
+ <meta name="render" content="webkit" />
11
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
12
+ <meta name="mobile-web-app-capable" content="yes" />
13
+ <meta id="viewportMeta" name="viewport"
14
+ content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
15
+ <meta name="creator" content="BluesYoung-web" />
16
+ <meta name="msapplication-TileColor" content="#00aba9">
17
+ <!-- 设定视口高度,防止软键盘影响布局 -->
18
+ <script>
19
+ const metaElement = document.querySelector('#viewportMeta')
20
+ metaElement.setAttribute('content', `maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0,height=${window.innerHeight}`)
21
+ </script>
22
+ <script>
23
+ // eslint-disable-next-line @typescript-eslint/no-invalid-this
24
+ this.globalThis || (this.globalThis = this)
25
+ window.onerror = function (e) {
26
+ if (e.toString().includes('ResizeObserver loop'))
27
+ return
28
+
29
+ console.log(e)
30
+ // eslint-disable-next-line no-alert
31
+ window.alert('您的浏览器版本过低,请尝试使用其他浏览器或将浏览器升级至最新版本后重试!')
32
+ }
33
+ </script>
34
+ <script>
35
+ (function () {
36
+ const prefersDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches
37
+ const setting = localStorage.getItem('vueuse-color-scheme') || 'auto'
38
+ if (setting === 'dark' || (prefersDark && setting !== 'light'))
39
+ document.documentElement.classList.toggle('dark', true)
40
+ })()
41
+ </script>
42
+ </head>
43
+ <body id="body">
44
+ <div id="app"></div>
45
+ <script type="module" src="/src/main.ts"></script>
46
+ <noscript>This website requires JavaScript to function properly. Please enable JavaScript to continue.</noscript>
47
+ </body>
48
+ </html>
@@ -0,0 +1,23 @@
1
+ /*
2
+ * @Author: zhangyang
3
+ * @Date: 2022-12-28 11:59:56
4
+ * @LastEditTime: 2024-02-02 16:20:57
5
+ * @Description:
6
+ */
7
+ export default defineNitroConfig({
8
+ /**
9
+ * 托管前端静态资源
10
+ */
11
+ serveStatic: 'node',
12
+ publicAssets: [
13
+ {
14
+ // 原始静态资源打包后的目录
15
+ dir: 'dist',
16
+ },
17
+ ],
18
+ routeRules: {
19
+ '/get/env': {
20
+ cors: true,
21
+ },
22
+ },
23
+ })
@@ -0,0 +1,66 @@
1
+ {
2
+ "type": "module",
3
+ "version": "0.0.1",
4
+ "private": true,
5
+ "scripts": {
6
+ "build": "vite build && nitropack build",
7
+ "dev": "run-p dev:*",
8
+ "dev:client": "vite",
9
+ "dev:server": "nitropack dev --host",
10
+ "lint": "eslint .",
11
+ "lint:fix": "eslint . --fix",
12
+ "preview": "vite preview",
13
+ "sizecheck": "npx vite-bundle-visualizer",
14
+ "postinstall": "nitropack prepare && simple-git-hooks"
15
+ },
16
+ "dependencies": {
17
+ "@bluesyoung/http": "^1.2.1",
18
+ "@bluesyoung/utils": "^0.2.1",
19
+ "@kjgl77/datav-vue3": "^1.6.1",
20
+ "@unocss/reset": "^0.58.4",
21
+ "@vueuse/core": "^10.1.2",
22
+ "autofit.js": "^3.0.4",
23
+ "echarts": "^5.4.3",
24
+ "mockjs": "^1.1.0",
25
+ "nprogress": "^0.2.0",
26
+ "pinia": "^2.1.3",
27
+ "sass": "^1.68.0",
28
+ "vue": "^3.3.4",
29
+ "vue-countup-v3": "^1.3.0",
30
+ "vue-router": "^4.2.1"
31
+ },
32
+ "devDependencies": {
33
+ "@antfu/eslint-config": "^2.6.3",
34
+ "@bluesyoung/logger": "^0.0.1",
35
+ "@iconify-json/carbon": "^1.1.16",
36
+ "@types/mockjs": "^1.0.7",
37
+ "@types/nprogress": "^0.2.0",
38
+ "@unocss/eslint-config": "^0.58.4",
39
+ "@vitejs/plugin-legacy": "^5.3.0",
40
+ "@vitejs/plugin-vue": "^4.2.3",
41
+ "c12": "^1.6.1",
42
+ "cross-env": "^7.0.3",
43
+ "eslint": "^8.41.0",
44
+ "h3-proxy": "^1.13.0",
45
+ "http-proxy": "^1.18.1",
46
+ "lint-staged": "^15.2.1",
47
+ "nitropack": "^2.8.1",
48
+ "npm-run-all": "^4.1.5",
49
+ "pnpm": "^8.5.1",
50
+ "simple-git-hooks": "^2.9.0",
51
+ "typescript": "^5.0.4",
52
+ "unocss": "^0.58.4",
53
+ "unplugin-auto-import": "^0.17.5",
54
+ "unplugin-vue-components": "^0.26.0",
55
+ "vite": "^4.3.8",
56
+ "vite-plugin-inspect": "^0.7.27",
57
+ "vite-plugin-pages": "^0.32.0",
58
+ "vite-plugin-vue-layouts": "^0.11.0"
59
+ },
60
+ "simple-git-hooks": {
61
+ "pre-commit": "npx lint-staged"
62
+ },
63
+ "lint-staged": {
64
+ "*": "eslint --fix"
65
+ }
66
+ }
@@ -0,0 +1,57 @@
1
+ /*
2
+ * @Author: zhangyang
3
+ * @Date: 2022-12-30 17:19:42
4
+ * @LastEditTime: 2024-02-02 15:51:14
5
+ * @Description:
6
+ */
7
+ import { resolve } from 'node:path'
8
+ import { loadConfig } from 'c12'
9
+ import { useYoungLogger } from '@bluesyoung/logger'
10
+
11
+ export default defineNitroPlugin(async (nitroApp) => {
12
+ const env = (process.env.DEPLOY_ENV as 'dev' | 'test' | 'online') || 'dev'
13
+ const { config } = await loadConfig<Record<string, any>>({
14
+ name: env,
15
+ cwd: resolve(process.cwd(), 'config'),
16
+ defaultConfig: {
17
+ // 此处可以放置通用的环境变量
18
+ // 由于频繁修改 package.json 会浪费 docker 性能,故将版本信息放于此处
19
+ // 优先读取环境变量中的版本信息(自己打的 Tag)
20
+ NUXT_PUBLIC_CURRENT_VERSION: process.env.PROJECT_VERSION || 'v0.0.1',
21
+ },
22
+ })
23
+
24
+ for (const key in config) {
25
+ if (process.env[key]) {
26
+ console.log(
27
+ '系统环境变量优先: ',
28
+ key,
29
+ ' = ',
30
+ process.env[key],
31
+ ' -> ',
32
+ config[key],
33
+ ' -> ',
34
+ '覆盖',
35
+ )
36
+ config[key] = process.env[key]
37
+ }
38
+ else {
39
+ process.env[key] = config[key]
40
+ }
41
+ if (!(key.indexOf('NUXT_PUBLIC_') === 0))
42
+ delete config[key]
43
+ }
44
+
45
+ // 仅打包之后格式化日志
46
+ if (process.env.NODE_ENV !== 'development')
47
+ useYoungLogger()
48
+
49
+ console.log('------------------------读取配置文件------------------------')
50
+ console.log(config)
51
+ console.log('-------------------------------------------------------------')
52
+
53
+ nitroApp.hooks.hook('request', (event) => {
54
+ const headers = event.node.req.headers
55
+ console.log('ua', headers['user-agent'], 'x-forwarded-for', headers['x-forwarded-for'], 'x-real-ip', headers['x-real-ip'])
56
+ })
57
+ })
@@ -0,0 +1,3 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32" fill="none">
2
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M27.562 26L17.17 8.928l2.366-3.888L17.828 4L16 7.005L14.17 4l-1.708 1.04l2.366 3.888L4.438 26H2v2h28v-2zM16 10.85L25.22 26H17v-8h-2v8H6.78z" fill="#222" />
3
+ </svg>
@@ -0,0 +1,19 @@
1
+ /*
2
+ * @Author: zhangyang
3
+ * @Date: 2024-05-08 15:40:36
4
+ * @LastEditTime: 2024-05-08 17:26:35
5
+ * @Description:
6
+ * @LastEditors: zhangyang
7
+ */
8
+ import { createProxyEventHandler } from 'h3-proxy'
9
+
10
+ export default eventHandler(async (event) => {
11
+ const proxy = createProxyEventHandler({
12
+ target: process.env.NUXT_PUBLIC_API_BASE as string,
13
+ })
14
+
15
+ return proxy(event).catch((error: Error) => {
16
+ console.error('🚀 ~ api proxy error:', error)
17
+ throw error
18
+ })
19
+ })
@@ -0,0 +1,13 @@
1
+ /*
2
+ * @Author: zhangyang
3
+ * @Date: 2023-07-20 19:48:12
4
+ * @LastEditTime: 2024-02-02 15:53:15
5
+ * @Description:
6
+ */
7
+ export default eventHandler(async (event) => {
8
+ const envObj = {
9
+ NUXT_PUBLIC_CURRENT_VERSION: process.env.PROJECT_VERSION || 'v0.0.1',
10
+ }
11
+
12
+ return envObj
13
+ })
@@ -0,0 +1,24 @@
1
+ <!--
2
+ * @Author: Leo l024983409@qq.com
3
+ * @Date: 2023-09-19 20:22:55
4
+ * @LastEditors: Leo l024983409@qq.com
5
+ * @LastEditTime: 2023-09-30 19:43:33
6
+ * @Description:
7
+ -->
8
+ <script setup lang="ts">
9
+ import autofit from 'autofit.js'
10
+
11
+ onMounted(() => {
12
+ if (!isDark.value)
13
+ toggleDark()
14
+
15
+ autofit.init({
16
+ el: '#body',
17
+
18
+ }, false)
19
+ })
20
+ </script>
21
+
22
+ <template>
23
+ <RouterView />
24
+ </template>
@@ -0,0 +1,77 @@
1
+ /*
2
+ * @Author: zhangyang
3
+ * @Date: 2023-07-21 09:09:37
4
+ * @LastEditTime: 2024-02-01 18:09:15
5
+ * @Description:
6
+ */
7
+ import type { YoungHttp, YoungHttpAuthReq, YoungHttpFreeReq } from '@bluesyoung/http'
8
+ import * as Mock from 'mockjs'
9
+
10
+ function generateRandomIntegersWithSum(sum: number) {
11
+ const result = []
12
+
13
+ // 生成两个随机整数
14
+ result.push(Mock.Random.integer(1, sum - 2))
15
+ result.push(Mock.Random.integer(1, sum - result[0] - 1))
16
+
17
+ // 计算第三个整数,使总和等于指定的值
18
+ result.push(sum - result[0] - result[1])
19
+
20
+ // 打乱数组顺序,以确保随机性
21
+ Mock.Random.shuffle(result)
22
+
23
+ return result
24
+ }
25
+
26
+ export function useGet(http: YoungHttp) {
27
+ const FreeReq: YoungHttpFreeReq = args => http.freeReq({ method: 'GET', ...args })
28
+ const AuthReq: YoungHttpAuthReq = args => http.authReq({ method: 'GET', ...args })
29
+
30
+ return {
31
+ getSocialCondition: async () => {
32
+ return {
33
+ values: Array.from({ length: 3 }).map(() => Mock.Random.integer(100000, 9999999)),
34
+ increment: Array.from({ length: 3 }).map(() => Mock.Random.float(0, 10, 0, 2)),
35
+ industry: generateRandomIntegersWithSum(100),
36
+ } as ISocialCondition
37
+ },
38
+ getPowerGridConstruction: async () => {
39
+ const res = {
40
+ values: Array.from({ length: 2 }, () => Mock.Random.float(10000, 99999, 0, 2)),
41
+ increment: Array.from({ length: 2 }, () => Mock.Random.float(0, 15, 0, 1)),
42
+ province: Array.from({ length: 5 }, () => Mock.Random.integer(5, 100)),
43
+ } as IPowerGridConstruction
44
+
45
+ return res
46
+ },
47
+ getElectricityUsage: async () => {
48
+ return {
49
+ values: [Mock.Random.float(100, 10000, 0, 2), Mock.Random.integer(1000, 10000000)],
50
+ increment: [Mock.Random.float(0, 10, 0, 2), Mock.Random.float(0, 10, 0, 2)],
51
+ electricity: Array.from({ length: 5 }, () => Mock.Random.integer(500, 4000)),
52
+ } as IElectricityUsage
53
+ },
54
+ getManagementImprovement: async () => {
55
+ return {
56
+ values: Array.from({ length: 2 }, () => Mock.Random.float(100, 9999, 0, 2)),
57
+ increment: Array.from({ length: 2 }, () => Mock.Random.float(0, 15, 0, 1)),
58
+ data: Mock.Random.integer(5, 100),
59
+ } as IManagementImprovement
60
+ },
61
+ getGridReliability: async () => {
62
+ return {
63
+ values: Array.from({ length: 3 }).map(() => Mock.Random.integer(0, 10)),
64
+ data1: Array.from({ length: 12 }).map(() => Mock.Random.integer(1, 8)),
65
+ data2: Array.from({ length: 12 }).map(() => Mock.Random.integer(1, 8)),
66
+ } as IGridReliability
67
+ },
68
+ getSalesOfElectricityAndLineLoss: async () => {
69
+ return {
70
+ values: Array.from({ length: 3 }).map(() => Mock.Random.integer(1000, 99999)),
71
+ increment: Array.from({ length: 3 }).map(() => Mock.Random.float(0, 10, 0, 2)),
72
+ data1: Array.from({ length: 5 }).map(() => Mock.Random.integer(1, 15)),
73
+ data2: Array.from({ length: 5 }).map(() => Mock.Random.integer(1, 7)),
74
+ } as ISalesOfElectricityAndLineLoss
75
+ },
76
+ }
77
+ }
@@ -0,0 +1,53 @@
1
+ /*
2
+ * @Author: zhangyang
3
+ * @Date: 2024-01-18 09:36:06
4
+ * @LastEditTime: 2024-05-08 15:39:36
5
+ * @Description:
6
+ */
7
+ import { useHttp } from '@bluesyoung/http'
8
+ import { useGet } from './get'
9
+ import { usePost } from './post'
10
+
11
+ export function ajaxStartLoading() {
12
+ console.log('todo: start loading')
13
+ }
14
+
15
+ export function ajaxEndLoading() {
16
+ console.log('todo: end loading')
17
+ }
18
+
19
+ export const http = useHttp<IResult>({
20
+ timeout: -1,
21
+ loading: {
22
+ start: ajaxStartLoading,
23
+ end: ajaxEndLoading,
24
+ },
25
+ fail: (err: any) => {
26
+ console.log('🚀 ~ file: 3-net.ts:60 ~ err', err, typeof err)
27
+ // if (err?.response?.status === 401) {
28
+ // useUserStore().removeToken()
29
+ // checkLogin(true)
30
+
31
+ // throw err
32
+ // }
33
+ // if (typeof err === 'string') {
34
+ // // 通用失败,弹出提示信息
35
+ // ElMessage.error(err)
36
+ // }
37
+ // if (isObject(err)) {
38
+ // ElMessage.error(err?.response?.data?.retinfo
39
+ // || err?.response?.data?.message
40
+ // || err?.response?.data?.msg
41
+ // || err?.response?.data
42
+ // || err.message
43
+ // || '网络错误!')
44
+ // }
45
+
46
+ throw err
47
+ },
48
+ })
49
+
50
+ export const apis = http.__mixin__({
51
+ get: useGet(http),
52
+ post: usePost(http),
53
+ })
@@ -0,0 +1,14 @@
1
+ /*
2
+ * @Author: zhangyang
3
+ * @Date: 2023-07-21 09:21:02
4
+ * @LastEditTime: 2024-02-01 19:16:34
5
+ * @Description:
6
+ */
7
+ import type { YoungHttp, YoungHttpAuthReq, YoungHttpFreeReq } from '@bluesyoung/http'
8
+
9
+ export function usePost(http: YoungHttp) {
10
+ const FreeReq: YoungHttpFreeReq = args => http.freeReq({ method: 'POST', ...args })
11
+ const AuthReq: YoungHttpAuthReq = args => http.authReq({ method: 'POST', ...args })
12
+
13
+ return {}
14
+ }