@gx-design-vue/create-gx-cli 0.1.25 → 0.1.27

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 (21) hide show
  1. package/package.json +4 -2
  2. package/template-vite-project/internal/rollupOptions/index.ts +28 -0
  3. package/template-vite-project/internal/{vite/vite/plugin → vite-plugin}/appConfig.ts +2 -2
  4. package/template-vite-project/internal/{vite/vite/plugin → vite-plugin}/visualizer.ts +1 -1
  5. package/template-vite-project/internal/{vite/vite/plugin → vite-plugin}/viteNotice.ts +1 -1
  6. package/template-vite-project/node_modules/.bin/autoprefixer +21 -0
  7. package/template-vite-project/node_modules/.bin/browserslist +21 -0
  8. package/template-vite-project/node_modules/.bin/rolldown +21 -0
  9. package/template-vite-project/node_modules/.bin/rollup-plugin-visualizer +21 -0
  10. package/template-vite-project/node_modules/.vite/deps/_metadata.json +7 -7
  11. package/template-vite-project/package.json +4 -0
  12. package/template-vite-project/src/utils/crypto/index.ts +56 -0
  13. package/template-vite-project/src/utils/storage.ts +215 -0
  14. package/template-vite-project/vite.config.ts +5 -5
  15. package/template-vite-project/internal/vite/rollupOptions/index.ts +0 -18
  16. package/template-vite-project/internal/vite/vite/cdn.ts +0 -65
  17. /package/template-vite-project/internal/{vite/generate → generate}/generateModifyVars.ts +0 -0
  18. /package/template-vite-project/internal/{vite/util → util}/hash.ts +0 -0
  19. /package/template-vite-project/internal/{vite/util → util}/index.ts +0 -0
  20. /package/template-vite-project/internal/{vite/vite/plugin → vite-plugin}/autoImport.ts +0 -0
  21. /package/template-vite-project/internal/{vite/vite/plugin → vite-plugin}/index.ts +0 -0
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@gx-design-vue/create-gx-cli",
3
- "version": "0.1.25",
3
+ "version": "0.1.27",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "bin": {
7
- "create-gx-cli": "index.js"
7
+ "create gx-best": "index.js"
8
8
  },
9
9
  "files": [
10
10
  "index.js",
@@ -14,6 +14,8 @@
14
14
  "dist"
15
15
  ],
16
16
  "keywords": [
17
+ "create gx-best",
18
+ "create gx best",
17
19
  "create-gx-cli"
18
20
  ],
19
21
  "scripts": {
@@ -0,0 +1,28 @@
1
+ import type { RolldownOptions } from 'rolldown'
2
+ import { pathResolve } from '../util'
3
+
4
+ export default function (): RolldownOptions {
5
+ return {
6
+ input: {
7
+ index: pathResolve('index.html')
8
+ },
9
+ // 静态资源分类打包
10
+ output: {
11
+ advancedChunks: {
12
+ groups: [
13
+ {
14
+ name: 'lodash-es',
15
+ test: /\/lodash-es/
16
+ },
17
+ {
18
+ name: 'crypto-js',
19
+ test: /\/crypto-js/
20
+ }
21
+ ]
22
+ },
23
+ chunkFileNames: 'static/js/[name]-[hash].js',
24
+ entryFileNames: 'static/js/[name]-[hash].js',
25
+ assetFileNames: 'static/[ext]/[name]-[hash].[ext]'
26
+ },
27
+ }
28
+ }
@@ -2,8 +2,8 @@ import type { PluginOption } from 'vite'
2
2
  import colors from 'picocolors'
3
3
  import { readPackageJSON } from 'pkg-types'
4
4
 
5
- import { getEnvConfig, rootPath } from '../../util'
6
- import { createContentHash, strToHex } from '../../util/hash'
5
+ import { getEnvConfig, rootPath } from '../util'
6
+ import { createContentHash, strToHex } from '../util/hash'
7
7
 
8
8
  const GLOBAL_CONFIG_FILE_NAME = '_app.config.js'
9
9
  const PLUGIN_NAME = 'app-config'
@@ -1,5 +1,5 @@
1
1
  import { visualizer } from 'rollup-plugin-visualizer'
2
- import { isReportMode } from '../../util'
2
+ import { isReportMode } from '../util'
3
3
 
4
4
  export function configVisualizerConfig() {
5
5
  if (isReportMode()) {
@@ -1,7 +1,7 @@
1
1
  import type { Plugin } from 'vite'
2
2
  import chalk from 'chalk'
3
3
  import { readPackageJSON } from 'pkg-types'
4
- import { getPackageSize, getRootPath, rootPath } from '../../util'
4
+ import { getPackageSize, getRootPath, rootPath } from '../util'
5
5
 
6
6
  export default async function viteNotice(): Promise<Plugin> {
7
7
  let config: { command: string }
@@ -0,0 +1,21 @@
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*|*MINGW*|*MSYS*)
6
+ if command -v cygpath > /dev/null 2>&1; then
7
+ basedir=`cygpath -w "$basedir"`
8
+ fi
9
+ ;;
10
+ esac
11
+
12
+ if [ -z "$NODE_PATH" ]; then
13
+ export NODE_PATH="/Users/gaoxiang/Documents/工作/工作项目/gx12358/vue/github/pro-components-vue-v2/node_modules/.pnpm/autoprefixer@10.4.21_postcss@8.5.6/node_modules/autoprefixer/bin/node_modules:/Users/gaoxiang/Documents/工作/工作项目/gx12358/vue/github/pro-components-vue-v2/node_modules/.pnpm/autoprefixer@10.4.21_postcss@8.5.6/node_modules/autoprefixer/node_modules:/Users/gaoxiang/Documents/工作/工作项目/gx12358/vue/github/pro-components-vue-v2/node_modules/.pnpm/autoprefixer@10.4.21_postcss@8.5.6/node_modules:/Users/gaoxiang/Documents/工作/工作项目/gx12358/vue/github/pro-components-vue-v2/node_modules/.pnpm/node_modules"
14
+ else
15
+ export NODE_PATH="/Users/gaoxiang/Documents/工作/工作项目/gx12358/vue/github/pro-components-vue-v2/node_modules/.pnpm/autoprefixer@10.4.21_postcss@8.5.6/node_modules/autoprefixer/bin/node_modules:/Users/gaoxiang/Documents/工作/工作项目/gx12358/vue/github/pro-components-vue-v2/node_modules/.pnpm/autoprefixer@10.4.21_postcss@8.5.6/node_modules/autoprefixer/node_modules:/Users/gaoxiang/Documents/工作/工作项目/gx12358/vue/github/pro-components-vue-v2/node_modules/.pnpm/autoprefixer@10.4.21_postcss@8.5.6/node_modules:/Users/gaoxiang/Documents/工作/工作项目/gx12358/vue/github/pro-components-vue-v2/node_modules/.pnpm/node_modules:$NODE_PATH"
16
+ fi
17
+ if [ -x "$basedir/node" ]; then
18
+ exec "$basedir/node" "$basedir/../autoprefixer/bin/autoprefixer" "$@"
19
+ else
20
+ exec node "$basedir/../autoprefixer/bin/autoprefixer" "$@"
21
+ fi
@@ -0,0 +1,21 @@
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*|*MINGW*|*MSYS*)
6
+ if command -v cygpath > /dev/null 2>&1; then
7
+ basedir=`cygpath -w "$basedir"`
8
+ fi
9
+ ;;
10
+ esac
11
+
12
+ if [ -z "$NODE_PATH" ]; then
13
+ export NODE_PATH="/Users/gaoxiang/Documents/工作/工作项目/gx12358/vue/github/pro-components-vue-v2/node_modules/.pnpm/browserslist@4.25.3/node_modules/browserslist/node_modules:/Users/gaoxiang/Documents/工作/工作项目/gx12358/vue/github/pro-components-vue-v2/node_modules/.pnpm/browserslist@4.25.3/node_modules:/Users/gaoxiang/Documents/工作/工作项目/gx12358/vue/github/pro-components-vue-v2/node_modules/.pnpm/node_modules"
14
+ else
15
+ export NODE_PATH="/Users/gaoxiang/Documents/工作/工作项目/gx12358/vue/github/pro-components-vue-v2/node_modules/.pnpm/browserslist@4.25.3/node_modules/browserslist/node_modules:/Users/gaoxiang/Documents/工作/工作项目/gx12358/vue/github/pro-components-vue-v2/node_modules/.pnpm/browserslist@4.25.3/node_modules:/Users/gaoxiang/Documents/工作/工作项目/gx12358/vue/github/pro-components-vue-v2/node_modules/.pnpm/node_modules:$NODE_PATH"
16
+ fi
17
+ if [ -x "$basedir/node" ]; then
18
+ exec "$basedir/node" "$basedir/../../../../../../node_modules/.pnpm/browserslist@4.25.3/node_modules/browserslist/cli.js" "$@"
19
+ else
20
+ exec node "$basedir/../../../../../../node_modules/.pnpm/browserslist@4.25.3/node_modules/browserslist/cli.js" "$@"
21
+ fi
@@ -0,0 +1,21 @@
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*|*MINGW*|*MSYS*)
6
+ if command -v cygpath > /dev/null 2>&1; then
7
+ basedir=`cygpath -w "$basedir"`
8
+ fi
9
+ ;;
10
+ esac
11
+
12
+ if [ -z "$NODE_PATH" ]; then
13
+ export NODE_PATH="/Users/gaoxiang/Documents/工作/工作项目/gx12358/vue/github/pro-components-vue-v2/node_modules/.pnpm/rolldown@1.0.0-beta.33/node_modules/rolldown/bin/node_modules:/Users/gaoxiang/Documents/工作/工作项目/gx12358/vue/github/pro-components-vue-v2/node_modules/.pnpm/rolldown@1.0.0-beta.33/node_modules/rolldown/node_modules:/Users/gaoxiang/Documents/工作/工作项目/gx12358/vue/github/pro-components-vue-v2/node_modules/.pnpm/rolldown@1.0.0-beta.33/node_modules:/Users/gaoxiang/Documents/工作/工作项目/gx12358/vue/github/pro-components-vue-v2/node_modules/.pnpm/node_modules"
14
+ else
15
+ export NODE_PATH="/Users/gaoxiang/Documents/工作/工作项目/gx12358/vue/github/pro-components-vue-v2/node_modules/.pnpm/rolldown@1.0.0-beta.33/node_modules/rolldown/bin/node_modules:/Users/gaoxiang/Documents/工作/工作项目/gx12358/vue/github/pro-components-vue-v2/node_modules/.pnpm/rolldown@1.0.0-beta.33/node_modules/rolldown/node_modules:/Users/gaoxiang/Documents/工作/工作项目/gx12358/vue/github/pro-components-vue-v2/node_modules/.pnpm/rolldown@1.0.0-beta.33/node_modules:/Users/gaoxiang/Documents/工作/工作项目/gx12358/vue/github/pro-components-vue-v2/node_modules/.pnpm/node_modules:$NODE_PATH"
16
+ fi
17
+ if [ -x "$basedir/node" ]; then
18
+ exec "$basedir/node" "$basedir/../../../../../../node_modules/.pnpm/rolldown@1.0.0-beta.33/node_modules/rolldown/bin/cli.mjs" "$@"
19
+ else
20
+ exec node "$basedir/../../../../../../node_modules/.pnpm/rolldown@1.0.0-beta.33/node_modules/rolldown/bin/cli.mjs" "$@"
21
+ fi
@@ -0,0 +1,21 @@
1
+ #!/bin/sh
2
+ basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3
+
4
+ case `uname` in
5
+ *CYGWIN*|*MINGW*|*MSYS*)
6
+ if command -v cygpath > /dev/null 2>&1; then
7
+ basedir=`cygpath -w "$basedir"`
8
+ fi
9
+ ;;
10
+ esac
11
+
12
+ if [ -z "$NODE_PATH" ]; then
13
+ export NODE_PATH="/Users/gaoxiang/Documents/工作/工作项目/gx12358/vue/github/pro-components-vue-v2/node_modules/.pnpm/rollup-plugin-visualizer@6.0.3_rolldown@1.0.0-beta.33_rollup@4.46.4/node_modules/rollup-plugin-visualizer/dist/bin/node_modules:/Users/gaoxiang/Documents/工作/工作项目/gx12358/vue/github/pro-components-vue-v2/node_modules/.pnpm/rollup-plugin-visualizer@6.0.3_rolldown@1.0.0-beta.33_rollup@4.46.4/node_modules/rollup-plugin-visualizer/dist/node_modules:/Users/gaoxiang/Documents/工作/工作项目/gx12358/vue/github/pro-components-vue-v2/node_modules/.pnpm/rollup-plugin-visualizer@6.0.3_rolldown@1.0.0-beta.33_rollup@4.46.4/node_modules/rollup-plugin-visualizer/node_modules:/Users/gaoxiang/Documents/工作/工作项目/gx12358/vue/github/pro-components-vue-v2/node_modules/.pnpm/rollup-plugin-visualizer@6.0.3_rolldown@1.0.0-beta.33_rollup@4.46.4/node_modules:/Users/gaoxiang/Documents/工作/工作项目/gx12358/vue/github/pro-components-vue-v2/node_modules/.pnpm/node_modules"
14
+ else
15
+ export NODE_PATH="/Users/gaoxiang/Documents/工作/工作项目/gx12358/vue/github/pro-components-vue-v2/node_modules/.pnpm/rollup-plugin-visualizer@6.0.3_rolldown@1.0.0-beta.33_rollup@4.46.4/node_modules/rollup-plugin-visualizer/dist/bin/node_modules:/Users/gaoxiang/Documents/工作/工作项目/gx12358/vue/github/pro-components-vue-v2/node_modules/.pnpm/rollup-plugin-visualizer@6.0.3_rolldown@1.0.0-beta.33_rollup@4.46.4/node_modules/rollup-plugin-visualizer/dist/node_modules:/Users/gaoxiang/Documents/工作/工作项目/gx12358/vue/github/pro-components-vue-v2/node_modules/.pnpm/rollup-plugin-visualizer@6.0.3_rolldown@1.0.0-beta.33_rollup@4.46.4/node_modules/rollup-plugin-visualizer/node_modules:/Users/gaoxiang/Documents/工作/工作项目/gx12358/vue/github/pro-components-vue-v2/node_modules/.pnpm/rollup-plugin-visualizer@6.0.3_rolldown@1.0.0-beta.33_rollup@4.46.4/node_modules:/Users/gaoxiang/Documents/工作/工作项目/gx12358/vue/github/pro-components-vue-v2/node_modules/.pnpm/node_modules:$NODE_PATH"
16
+ fi
17
+ if [ -x "$basedir/node" ]; then
18
+ exec "$basedir/node" "$basedir/../rollup-plugin-visualizer/dist/bin/cli.js" "$@"
19
+ else
20
+ exec node "$basedir/../rollup-plugin-visualizer/dist/bin/cli.js" "$@"
21
+ fi
@@ -1,31 +1,31 @@
1
1
  {
2
- "hash": "0d666e2f",
2
+ "hash": "85ab3cd0",
3
3
  "configHash": "611bbc96",
4
- "lockfileHash": "e5340a5a",
5
- "browserHash": "e352feaa",
4
+ "lockfileHash": "02215b4a",
5
+ "browserHash": "af69fffe",
6
6
  "optimized": {
7
7
  "@vueuse/core": {
8
8
  "src": "../../../../../../../node_modules/.pnpm/@vueuse+core@13.7.0_vue@3.5.18_typescript@5.8.3_/node_modules/@vueuse/core/index.mjs",
9
9
  "file": "@vueuse_core.js",
10
- "fileHash": "cf40aa80",
10
+ "fileHash": "d5b5ca94",
11
11
  "needsInterop": false
12
12
  },
13
13
  "dayjs": {
14
14
  "src": "../../../../../../../node_modules/.pnpm/dayjs@1.11.13/node_modules/dayjs/dayjs.min.js",
15
15
  "file": "dayjs.js",
16
- "fileHash": "b0d5df5a",
16
+ "fileHash": "23b18f47",
17
17
  "needsInterop": true
18
18
  },
19
19
  "vue-router": {
20
20
  "src": "../../../../../../../node_modules/.pnpm/vue-router@4.5.1_vue@3.5.18_typescript@5.9.2_/node_modules/vue-router/dist/vue-router.mjs",
21
21
  "file": "vue-router.js",
22
- "fileHash": "a442cb7f",
22
+ "fileHash": "88850376",
23
23
  "needsInterop": false
24
24
  },
25
25
  "vue": {
26
26
  "src": "../../../../../../../node_modules/.pnpm/vue@3.5.18_typescript@5.8.3/node_modules/vue/dist/vue.runtime.esm-bundler.js",
27
27
  "file": "vue.js",
28
- "fileHash": "3ce9ec91",
28
+ "fileHash": "4ceb843b",
29
29
  "needsInterop": false
30
30
  }
31
31
  },
@@ -16,6 +16,7 @@
16
16
  "@vueuse/shared": "^13.5.0",
17
17
  "ant-design-vue": "latest",
18
18
  "dayjs": "^1.11.13",
19
+ "crypto-js": "^4.1.1",
19
20
  "lodash-es": "^4.17.21",
20
21
  "vue": "^3.5.18"
21
22
  },
@@ -26,7 +27,10 @@
26
27
  "@vitejs/plugin-legacy": "^7.2.1",
27
28
  "@vitejs/plugin-vue": "^6.0.1",
28
29
  "@vitejs/plugin-vue-jsx": "^5.0.1",
30
+ "pkg-types": "^2.3.0",
31
+ "picocolors": "^1.1.1",
29
32
  "cross-env": "^10.0.0",
33
+ "dotenv": "^17.2.1",
30
34
  "less": "^4.1.2",
31
35
  "autoprefixer": "^10.4.5",
32
36
  "postcss": "^8.4.35",
@@ -0,0 +1,56 @@
1
+ import { isArray, isJSONStr, isObject } from '@gx-design-vue/pro-utils'
2
+ import CryptoProJS from 'crypto-js'
3
+ import * as CryptoJS from 'crypto-js/core'
4
+ import 'crypto-js/enc-utf8'
5
+ import 'crypto-js/tripledes'
6
+ import 'crypto-js/sha1'
7
+
8
+ const key = '1234123412ABCDEF' // 十六位十六进制数作为密钥
9
+
10
+ /**
11
+ * 登录密码加密
12
+ * @param password
13
+ * @returns {string}
14
+ */
15
+ export const encodePassword = (password: string) => {
16
+ const key = CryptoProJS.enc.Utf8.parse('8QONwyJtHesysWpM')
17
+ const passwordENC = CryptoProJS.AES.encrypt(password, key, {
18
+ mode: CryptoProJS.mode.ECB,
19
+ padding: CryptoProJS.pad.Pkcs7
20
+ })
21
+ const encodePW = passwordENC.ciphertext.toString()
22
+ return encodePW
23
+ }
24
+
25
+ // 加密方法
26
+ export function Encrypt(word) {
27
+ let str: string | object = word
28
+ if (isObject(word) || isArray(word)) {
29
+ str = JSON.stringify(word)
30
+ }
31
+ const keyHex = CryptoJS.enc.Utf8.parse(key)
32
+ const ivHex = CryptoJS.enc.Utf8.parse(key)
33
+ const encrypted = CryptoJS.DES.encrypt(str, keyHex, {
34
+ iv: ivHex,
35
+ mode: CryptoJS.mode.CBC,
36
+ padding: CryptoJS.pad.Pkcs7
37
+ })
38
+ return CryptoJS.enc.Base64.stringify(encrypted.ciphertext)
39
+ }
40
+
41
+ // 解密方法
42
+ export function Decrypt(word) {
43
+ const keyHex = CryptoJS.enc.Utf8.parse(key)
44
+ const ivHex = CryptoJS.enc.Utf8.parse(key)
45
+ const decrypted = CryptoJS.DES.decrypt({
46
+ ciphertext: CryptoJS.enc.Base64.parse(word)
47
+ }, keyHex, {
48
+ iv: ivHex,
49
+ mode: CryptoJS.mode.CBC,
50
+ padding: CryptoJS.pad.Pkcs7
51
+ })
52
+ const decryptedStr = decrypted.toString(CryptoJS.enc.Utf8)
53
+ return isJSONStr(decryptedStr.toString())
54
+ ? JSON.parse(decryptedStr.toString())
55
+ : decryptedStr.toString()
56
+ }
@@ -0,0 +1,215 @@
1
+ import { isJSONStr, isNumber, isObject, isString } from '@gx-design-vue/pro-utils'
2
+ import dayjs from 'dayjs'
3
+ import { Decrypt, Encrypt } from './crypto'
4
+ import { isPro, typeViteEnv } from './env'
5
+
6
+ function isEncryption(status: boolean) {
7
+ return isPro() ? status : false
8
+ }
9
+
10
+ function handleStorageValue(value: string) {
11
+ if (isJSONStr(value))
12
+ return JSON.parse(value)
13
+ return value
14
+ }
15
+
16
+ /**
17
+ * @Author gx12358
18
+ * @DateTime 2019/12/3
19
+ * @lastTime 2019/12/3
20
+ * @description 设置Local-key的规则
21
+ */
22
+ export function getStorageKey(key: string, originKey?: boolean) {
23
+ const { pkg } = __APP_INFO__
24
+ return originKey ? key : `${pkg.name}_${pkg.version}_${typeViteEnv('VITE_APP_ENV') === 'dev'
25
+ ? 'development'
26
+ : typeViteEnv('VITE_USE_MODE')}_${key}`
27
+ }
28
+
29
+ /**
30
+ * @Author gx12358
31
+ * @DateTime 2019/12/3
32
+ * @lastTime 2019/12/3
33
+ * @description 获取Storage
34
+ */
35
+ export function getStorage<T = any>({
36
+ key,
37
+ originKey,
38
+ type = 'local',
39
+ encryption = true
40
+ }: {
41
+ key: string;
42
+ encryption?: boolean;
43
+ type?: 'local' | 'cookie' | 'session';
44
+ originKey?: boolean;
45
+ }): T {
46
+ const storageValue = type === 'local'
47
+ ? localStorage.getItem(getStorageKey(key, originKey))
48
+ : type === 'session' ? sessionStorage.getItem(getStorageKey(key, originKey)) : getCookie(
49
+ getStorageKey(
50
+ key,
51
+ originKey
52
+ ))
53
+ const result: string | LocalResult = storageValue
54
+ ? isEncryption(encryption) ? Decrypt(storageValue) : handleStorageValue(storageValue)
55
+ : ''
56
+ if (result && isObject(result)) {
57
+ if (result.expired) {
58
+ const expiredStatus = dayjs().diff(dayjs(result.time)) >= result.expired
59
+ if (expiredStatus) {
60
+ removeStorage({ key, originKey, type })
61
+ return '' as unknown as T
62
+ }
63
+ }
64
+ } else if (result && isString(result)) {
65
+ return isJSONStr(result) ? JSON.parse(result) as T : result as unknown as T
66
+ }
67
+ return typeof result === 'string' ? result as T : result?.['value'] || result || ''
68
+ }
69
+
70
+ /**
71
+ * @Author gx12358
72
+ * @DateTime 2019/12/3
73
+ * @lastTime 2019/12/3
74
+ * @description 设置Storage
75
+ */
76
+ export function setStorage({
77
+ key,
78
+ value,
79
+ expired,
80
+ originKey,
81
+ type = 'local',
82
+ encryption = true
83
+ }: {
84
+ key: string;
85
+ value: any;
86
+ originKey?: boolean;
87
+ expired?: number;
88
+ encryption?: boolean;
89
+ type?: 'local' | 'cookie' | 'session';
90
+ }) {
91
+ const result: LocalResult = originKey ? value : {
92
+ value,
93
+ time: dayjs().format('YYYY-MM-DD HH:mm:ss'),
94
+ expired: expired || 0
95
+ }
96
+ const storageValue = isEncryption(encryption)
97
+ ? Encrypt(JSON.stringify(result))
98
+ : isString(result) || isNumber(result) ? result : JSON.stringify(result)
99
+ if (type === 'local') localStorage.setItem(getStorageKey(key, originKey), storageValue)
100
+ else if (type === 'cookie') setCookie(getStorageKey(key, originKey), storageValue)
101
+ else sessionStorage.setItem(getStorageKey(key, originKey), storageValue)
102
+ }
103
+
104
+ /**
105
+ * @Author gx12358
106
+ * @DateTime 2019/12/3
107
+ * @lastTime 2019/12/3
108
+ * @description 删除Storage
109
+ */
110
+ export function removeStorage({
111
+ key,
112
+ originKey,
113
+ type = 'local'
114
+ }: {
115
+ key: string;
116
+ originKey?: boolean;
117
+ type?: 'local' | 'cookie' | 'session';
118
+ }) {
119
+ if (type === 'local') localStorage.removeItem(getStorageKey(key, originKey))
120
+ else if (type === 'cookie') delCookie(getStorageKey(key, originKey))
121
+ else sessionStorage.removeItem(getStorageKey(key, originKey))
122
+ }
123
+
124
+ /**
125
+ * @Author gx12358
126
+ * @DateTime 2019-09-24
127
+ * @lastTime 2019-09-24
128
+ * @description 获取Cookie-name
129
+ */
130
+ function getCookies(cname: string) {
131
+ const name = `${cname}=`
132
+ const decodedCookie = decodeURIComponent(document.cookie)
133
+ const ca = decodedCookie.split(';')
134
+ for (let i = 0; i < ca.length; i += 1) {
135
+ let c = ca[i]
136
+ while (c.charAt(0) === ' ') {
137
+ c = c.substring(1)
138
+ }
139
+ if (c.indexOf(name) === 0) {
140
+ return decodeURIComponent(c.substring(name.length, c.length))
141
+ }
142
+ }
143
+ return ''
144
+ }
145
+
146
+ /**
147
+ * @Author gx12358
148
+ * @DateTime 2019-09-24
149
+ * @lastTime 2019-09-24
150
+ * @description 获取Cookiedomin
151
+ */
152
+ function GetCookieDomain() {
153
+ let host = location.hostname
154
+ const ip = /^(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/
155
+ if (ip.test(host) === true || host === 'localhost')
156
+ return host
157
+ // eslint-disable-next-line regexp/optimal-quantifier-concatenation
158
+ const regex = /([\s\S]*).*/
159
+ const match = host.match(regex)
160
+ if (typeof match !== 'undefined' && match !== null) {
161
+ const someIndex = 1
162
+ host = match[someIndex]
163
+ }
164
+ if (typeof host !== 'undefined' && host !== null) {
165
+ const strAry = host.split('.')
166
+ if (strAry.length > 1) {
167
+ host = `${strAry[strAry.length - 2]}.${strAry[strAry.length - 1]}`
168
+ }
169
+ }
170
+ return `.${host}`
171
+ }
172
+
173
+ /**
174
+ * @Author gx12358
175
+ * @DateTime 2019-09-24
176
+ * @lastTime 2019-09-24
177
+ * @description 设置Cookie
178
+ */
179
+ export function setCookie(cname: string, cvalue: string, exdays?: number) {
180
+ const d = new Date()
181
+ d.setTime(d.getTime() + (exdays || 365) * 24 * 60 * 60 * 1000)
182
+ const expires = `=${d.toUTCString()}`
183
+ document.cookie = `${cname}=${encodeURIComponent(
184
+ cvalue
185
+ )}; expires=${expires}; domain=${GetCookieDomain()}; path=/`
186
+ }
187
+
188
+ /**
189
+ * @Author gx12358
190
+ * @DateTime 2019-09-24
191
+ * @lastTime 2019-09-24
192
+ * @description 获取Cookie
193
+ */
194
+ export function getCookie(cname: string) {
195
+ const result = getCookies(cname)
196
+ if (result === '') {
197
+ return ''
198
+ }
199
+ return decodeURIComponent(result)
200
+ }
201
+
202
+ /**
203
+ * @Author gx12358
204
+ * @DateTime 2019-09-24
205
+ * @lastTime 2019-09-24
206
+ * @description 删除Cookie
207
+ */
208
+ export function delCookie(name: string) {
209
+ const exp = new Date()
210
+ exp.setTime(exp.getTime() - 1)
211
+ const val = getCookies(name)
212
+ if (val !== null) {
213
+ document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; domain=${GetCookieDomain()}; path=/`
214
+ }
215
+ }
@@ -3,12 +3,12 @@ import autoprefixer from 'autoprefixer'
3
3
  import dayjs from 'dayjs'
4
4
  import { loadEnv } from 'vite'
5
5
 
6
+ import { generateModifyVars } from './internal/generate/generateModifyVars'
6
7
  import { createProxy } from './internal/proxy'
7
- import { generateModifyVars } from './internal/vite/generate/generateModifyVars'
8
- import createRollupOptions from './internal/vite/rollupOptions'
9
- import { pathResolve, wrapperEnv } from './internal/vite/util'
8
+ import createRollupOptions from './internal/rollupOptions'
9
+ import { pathResolve, wrapperEnv } from './internal/util'
10
10
 
11
- import { createVitePlugins } from './internal/vite/vite/plugin'
11
+ import { createVitePlugins } from './internal/vite-plugin'
12
12
 
13
13
  import pkg from './package.json'
14
14
 
@@ -51,7 +51,7 @@ export default async ({ command, mode }: ConfigEnv): Promise<UserConfig> => {
51
51
  },
52
52
  build: {
53
53
  chunkSizeWarningLimit: 4000,
54
- rollupOptions: createRollupOptions()
54
+ rolldownOptions: createRollupOptions()
55
55
  },
56
56
  define: {
57
57
  __INTLIFY_PROD_DEVTOOLS__: false,
@@ -1,18 +0,0 @@
1
- import type { RollupOptions } from 'rollup'
2
- import { pathResolve } from '../util'
3
-
4
- export default function (): RollupOptions {
5
- return {
6
- input: {
7
- index: pathResolve('index.html')
8
- },
9
- // 静态资源分类打包
10
- output: {
11
- chunkFileNames: 'static/js/[name]-[hash].js',
12
- entryFileNames: 'static/js/[name]-[hash].js',
13
- assetFileNames: 'static/[ext]/[name]-[hash].[ext]'
14
- },
15
- external: [],
16
- plugins: []
17
- }
18
- }
@@ -1,65 +0,0 @@
1
- import fs from 'node:fs'
2
- import path from 'node:path'
3
- import { defaultSettings } from '../../../config'
4
-
5
- const { cdn } = defaultSettings
6
-
7
- const { modules = [], url = '' } = cdn
8
-
9
- function getModuleVersion(name: string): string {
10
- const pwd = process.cwd()
11
- const pkgFile = path.join(pwd, 'node_modules', name, 'package.json')
12
- if (fs.existsSync(pkgFile)) {
13
- const pkgJson = JSON.parse(fs.readFileSync(pkgFile, 'utf8'))
14
- return pkgJson.version
15
- }
16
-
17
- return ''
18
- }
19
-
20
- function isFullPath(path: string) {
21
- return path.startsWith('http:') || path.startsWith('https:') || path.startsWith('//')
22
- }
23
-
24
- function renderUrl(data: CdnModuleList & {
25
- version: string
26
- }) {
27
- const { path } = data
28
- if (isFullPath(path))
29
- return path
30
- return url.replace(/\{name\}/g, data.name)
31
- .replace(/\{version\}/g, data.version)
32
- .replace(/\{path\}/g, path)
33
- }
34
-
35
- function getCdnModuleFiles() {
36
- return modules.map((m) => {
37
- const version = getModuleVersion(m.name)
38
- if (!version) {
39
- throw new Error(`modules: ${m.name} package.json file does not exist`)
40
- }
41
-
42
- let css = m.css || [] as string[]
43
- if (!Array.isArray(css) && css) {
44
- css = [ css ]
45
- }
46
-
47
- return {
48
- js: renderUrl({
49
- ...m,
50
- version
51
- }),
52
- css
53
- }
54
- })
55
- }
56
-
57
- export function getExternalMap() {
58
- const externalMap = {}
59
- modules.forEach((v) => {
60
- externalMap[v.name] = v.globalName
61
- })
62
- return externalMap
63
- }
64
-
65
- export default getCdnModuleFiles()