create-young-proj 2.1.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +17 -0
- package/README.md +7 -1
- package/dist/index.mjs +6 -6
- package/package.json +1 -1
- package/src/index.ts +6 -1
- package/template-electron-win7/.vscode/extensions.json +5 -0
- package/template-electron-win7/.vscode/settings.json +49 -0
- package/template-electron-win7/README.md +65 -0
- package/template-electron-win7/RELEASE_NOTES.md +11 -0
- package/template-electron-win7/_gitignore +27 -0
- package/template-electron-win7/dev-app-update.yml +2 -0
- package/template-electron-win7/electron/config/0.local.config.ts +13 -0
- package/template-electron-win7/electron/config/1.dev.config.ts +13 -0
- package/template-electron-win7/electron/config/2.test.config.ts +13 -0
- package/template-electron-win7/electron/config/3.wtest.config.ts +13 -0
- package/template-electron-win7/electron/config/4.online.config.ts +13 -0
- package/template-electron-win7/electron/config.ts +13 -0
- package/template-electron-win7/electron/electron-env.d.ts +58 -0
- package/template-electron-win7/electron/main.ts +318 -0
- package/template-electron-win7/electron/preload.ts +23 -0
- package/template-electron-win7/electron/update.ts +78 -0
- package/template-electron-win7/electron-builder.yaml +67 -0
- package/template-electron-win7/env/.env +1 -0
- package/template-electron-win7/env/.env.development +9 -0
- package/template-electron-win7/env/.env.production +9 -0
- package/template-electron-win7/eslint.config.mjs +33 -0
- package/template-electron-win7/index.html +16 -0
- package/template-electron-win7/package.json +71 -0
- package/template-electron-win7/public/icon.ico +0 -0
- package/template-electron-win7/scripts/afterPack.mjs +36 -0
- package/template-electron-win7/scripts/build.mjs +55 -0
- package/template-electron-win7/src/App.vue +23 -0
- package/template-electron-win7/src/auto-imports.d.ts +305 -0
- package/template-electron-win7/src/components/UpdateDialog.vue +166 -0
- package/template-electron-win7/src/components.d.ts +18 -0
- package/template-electron-win7/src/layouts/blank.vue +11 -0
- package/template-electron-win7/src/layouts/default.vue +13 -0
- package/template-electron-win7/src/main.ts +36 -0
- package/template-electron-win7/src/modules/1-router.ts +72 -0
- package/template-electron-win7/src/modules/2-pinia.ts +13 -0
- package/template-electron-win7/src/styles/variables.scss +8 -0
- package/template-electron-win7/src/types/global.d.ts +0 -0
- package/template-electron-win7/src/utils/env.ts +4 -0
- package/template-electron-win7/src/utils/ls.ts +118 -0
- package/template-electron-win7/src/views/[...all_404].vue +539 -0
- package/template-electron-win7/src/views/index.vue +34 -0
- package/template-electron-win7/src/vite-env.d.ts +27 -0
- package/template-electron-win7/tsconfig.json +29 -0
- package/template-electron-win7/tsconfig.node.json +11 -0
- package/template-electron-win7/uno.config.ts +32 -0
- package/template-electron-win7/vite.config.ts +78 -0
- package/template-electron-win7/yarn.lock +5964 -0
@@ -0,0 +1,72 @@
|
|
1
|
+
/*
|
2
|
+
* @Author: zhangyang
|
3
|
+
* @Date: 2024-07-31 16:52:15
|
4
|
+
* @LastEditTime: 2024-07-31 17:28:36
|
5
|
+
* @Description:
|
6
|
+
* @LastEditors: zhangyang
|
7
|
+
* Copyright (c) 2024 to current by BluesYoung-web, All Rights Reserved.
|
8
|
+
*/
|
9
|
+
import { createRouter, createWebHashHistory } from 'vue-router'
|
10
|
+
import { setupLayouts } from 'virtual:generated-layouts'
|
11
|
+
import routes from '~pages'
|
12
|
+
|
13
|
+
/**
|
14
|
+
* 路由元数据类型扩展
|
15
|
+
*/
|
16
|
+
declare module 'vue-router' {
|
17
|
+
interface RouteMeta {
|
18
|
+
/**
|
19
|
+
* 页面标题
|
20
|
+
*/
|
21
|
+
title: string
|
22
|
+
/**
|
23
|
+
* 是否固定
|
24
|
+
*/
|
25
|
+
affix?: boolean
|
26
|
+
/**
|
27
|
+
* 是否禁用缓存
|
28
|
+
*/
|
29
|
+
noCache?: boolean
|
30
|
+
/**
|
31
|
+
* 鉴权路径,不设置则为白名单页面
|
32
|
+
*/
|
33
|
+
authPath?: string
|
34
|
+
/**
|
35
|
+
* 页面布局,对应 layouts 目录下的布局页面,默认为 default
|
36
|
+
*/
|
37
|
+
layout?: 'default' | 'blank'
|
38
|
+
}
|
39
|
+
};
|
40
|
+
|
41
|
+
export const finalRoutes = setupLayouts(routes)
|
42
|
+
console.log('🚀 ~ finalRoutes:', finalRoutes)
|
43
|
+
// export const navMap = new Map<string, string>()
|
44
|
+
// /**
|
45
|
+
// * 生成权限节点映射表
|
46
|
+
// */
|
47
|
+
// function generateNavMap(raw: RouteRecordRaw[], base = '') {
|
48
|
+
// for (const route of raw) {
|
49
|
+
// if (route.children) {
|
50
|
+
// generateNavMap(route.children, route.path)
|
51
|
+
// }
|
52
|
+
// else {
|
53
|
+
// const meta = route.meta
|
54
|
+
// if (meta && meta.authPath) {
|
55
|
+
// navMap.set(
|
56
|
+
// meta.authPath,
|
57
|
+
// `${base}${route.path.startsWith('/') ? '' : '/'}${route.path}`,
|
58
|
+
// )
|
59
|
+
// }
|
60
|
+
// }
|
61
|
+
// }
|
62
|
+
// }
|
63
|
+
// generateNavMap(finalRoutes)
|
64
|
+
|
65
|
+
export const router = createRouter({
|
66
|
+
history: createWebHashHistory(import.meta.env.BASE_URL),
|
67
|
+
routes: finalRoutes,
|
68
|
+
})
|
69
|
+
|
70
|
+
export const install: UserModule = (app) => {
|
71
|
+
app.use(router)
|
72
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/*
|
2
|
+
* @Author: zhangyang
|
3
|
+
* @Date: 2024-08-27 11:39:24
|
4
|
+
* @LastEditTime: 2024-08-27 11:39:35
|
5
|
+
* @Description:
|
6
|
+
* @LastEditors: zhangyang
|
7
|
+
* Copyright (c) 2024 to current by BluesYoung-web, All Rights Reserved.
|
8
|
+
*/
|
9
|
+
|
10
|
+
export const install: UserModule = (app) => {
|
11
|
+
const pinia = createPinia()
|
12
|
+
app.use(pinia)
|
13
|
+
}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
/**全局SCSS变量 样式值以同文件夹下的json主题配置的值为主,命名推荐全拼小驼峰,这里定义的值可随意取*/
|
2
|
+
|
3
|
+
$backgroundColor: var(--background-color, #fff);
|
4
|
+
$linkColor: var(--link-color, skyblue);
|
5
|
+
|
6
|
+
// 覆盖element的颜色配置 这里配置的颜色不会覆盖,初始化的时候通过代码进行覆盖
|
7
|
+
$primaryColor: var(--el-color-primary, #fe587f);
|
8
|
+
$textColor: var(--el-text-color, #232332);
|
File without changes
|
@@ -0,0 +1,118 @@
|
|
1
|
+
/* localstorage封装,缓存工具类 参考:https://blog.csdn.net/w544924116/article/details/120906411
|
2
|
+
|
3
|
+
/** key前缀 */
|
4
|
+
const keyPrefix = 'app_cahce$_'
|
5
|
+
|
6
|
+
/**
|
7
|
+
* @param value 内容
|
8
|
+
* @param addTime 存入时间
|
9
|
+
* @param expires 有效时间
|
10
|
+
*/
|
11
|
+
interface valObjParams {
|
12
|
+
value: any
|
13
|
+
addTime: number
|
14
|
+
expires: number
|
15
|
+
}
|
16
|
+
|
17
|
+
interface StorageInterface {
|
18
|
+
/**
|
19
|
+
* 设置localStorage
|
20
|
+
* @param value 内容
|
21
|
+
* @param expires 有效时间 单位 s
|
22
|
+
*/
|
23
|
+
set: (key: string, value: any, expires?: number) => void
|
24
|
+
/** 获取localStorage,会自动转json */
|
25
|
+
get: (key: string) => any
|
26
|
+
/** 是否含有key */
|
27
|
+
has: (key: string) => boolean
|
28
|
+
/** 移除 */
|
29
|
+
remove: (key: string) => void
|
30
|
+
/** 移除全部缓存 */
|
31
|
+
clear: () => void
|
32
|
+
/** 移除自己前缀的全部缓存 */
|
33
|
+
clearSelf: () => void
|
34
|
+
}
|
35
|
+
|
36
|
+
const storage: StorageInterface = {
|
37
|
+
set: () => {},
|
38
|
+
get: () => '',
|
39
|
+
has: () => false,
|
40
|
+
remove: () => {},
|
41
|
+
clear: () => {},
|
42
|
+
clearSelf: () => {},
|
43
|
+
}
|
44
|
+
|
45
|
+
/**
|
46
|
+
* 是否过期
|
47
|
+
*/
|
48
|
+
function isFresh(valObj: valObjParams) {
|
49
|
+
const now = new Date().getTime()
|
50
|
+
return valObj.addTime + valObj.expires >= now
|
51
|
+
}
|
52
|
+
|
53
|
+
/* 给key值添加前缀 */
|
54
|
+
function addPrefix(key: string) {
|
55
|
+
return `${keyPrefix}${key}`
|
56
|
+
}
|
57
|
+
|
58
|
+
/* 加方法 */
|
59
|
+
function extend(s: Storage) {
|
60
|
+
return {
|
61
|
+
set(key: string, value: any, expires?: number) {
|
62
|
+
const skey = addPrefix(key)
|
63
|
+
if (expires) {
|
64
|
+
expires *= 1000 // 将过期时间从微秒转为秒
|
65
|
+
s.setItem(
|
66
|
+
skey,
|
67
|
+
JSON.stringify({
|
68
|
+
value,
|
69
|
+
addTime: new Date().getTime(),
|
70
|
+
expires,
|
71
|
+
}),
|
72
|
+
)
|
73
|
+
}
|
74
|
+
else {
|
75
|
+
const val = JSON.stringify(value)
|
76
|
+
s.setItem(skey, val)
|
77
|
+
}
|
78
|
+
if (value === undefined || value === null) {
|
79
|
+
s.removeItem(skey)
|
80
|
+
}
|
81
|
+
},
|
82
|
+
get(key: string) {
|
83
|
+
const skey = addPrefix(key)
|
84
|
+
const item = JSON.parse(s.getItem(skey) as any)
|
85
|
+
// 如果有addTime的值,说明设置了失效时间
|
86
|
+
if (item && item.addTime) {
|
87
|
+
if (isFresh(item)) {
|
88
|
+
return item.value
|
89
|
+
}
|
90
|
+
/* 缓存过期,清除缓存,返回null */
|
91
|
+
s.removeItem(skey)
|
92
|
+
return null
|
93
|
+
}
|
94
|
+
return item
|
95
|
+
},
|
96
|
+
has(key: string) {
|
97
|
+
const skey = addPrefix(key)
|
98
|
+
return !!s.getItem(skey)
|
99
|
+
},
|
100
|
+
remove: (key: string) => {
|
101
|
+
const skey = addPrefix(key)
|
102
|
+
s.removeItem(skey)
|
103
|
+
},
|
104
|
+
clear: () => {
|
105
|
+
s.clear()
|
106
|
+
},
|
107
|
+
clearSelf: () => {
|
108
|
+
const arr = Array.from({ length: s.length }, (_, i) => s.key(i)).filter(
|
109
|
+
str => str?.startsWith(keyPrefix),
|
110
|
+
)
|
111
|
+
arr.forEach(str => s.removeItem(str as string))
|
112
|
+
},
|
113
|
+
}
|
114
|
+
}
|
115
|
+
|
116
|
+
Object.assign(storage, extend(window.localStorage))
|
117
|
+
|
118
|
+
export default storage
|