@gx-design-vue/create-gx-cli 0.0.1
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/LICENSE +21 -0
- package/README.md +22 -0
- package/bin/create-gx-cli +4 -0
- package/package.json +31 -0
- package/src/cli.js +78 -0
- package/src/main.js +75 -0
- package/template-mobile-ts/.editorconfig +19 -0
- package/template-mobile-ts/.env.development +19 -0
- package/template-mobile-ts/.env.pro +19 -0
- package/template-mobile-ts/.env.production +19 -0
- package/template-mobile-ts/.eslintignore +16 -0
- package/template-mobile-ts/.eslintrc.js +64 -0
- package/template-mobile-ts/.prettierignore +9 -0
- package/template-mobile-ts/.stylelintignore +3 -0
- package/template-mobile-ts/README.md +16 -0
- package/template-mobile-ts/build/cdn.ts +5 -0
- package/template-mobile-ts/build/optimizer.ts +18 -0
- package/template-mobile-ts/build/plugin/autoImport.ts +26 -0
- package/template-mobile-ts/build/plugin/html.ts +26 -0
- package/template-mobile-ts/build/plugin/index.ts +38 -0
- package/template-mobile-ts/build/plugin/mock.ts +20 -0
- package/template-mobile-ts/index.html +24 -0
- package/template-mobile-ts/mock/_createProductionServer.ts +19 -0
- package/template-mobile-ts/mock/api/index.ts +66 -0
- package/template-mobile-ts/mock/utils.ts +9 -0
- package/template-mobile-ts/package.json +57 -0
- package/template-mobile-ts/pnpm-lock.yaml +3890 -0
- package/template-mobile-ts/postcss.config.js +11 -0
- package/template-mobile-ts/prettier.config.js +18 -0
- package/template-mobile-ts/public/favicon.ico +0 -0
- package/template-mobile-ts/public/js/flexible.js +44 -0
- package/template-mobile-ts/src/App.vue +5 -0
- package/template-mobile-ts/src/components/PageContainer/ProSkeleton.tsx +30 -0
- package/template-mobile-ts/src/components/PageContainer/index.tsx +113 -0
- package/template-mobile-ts/src/components/PageContainer/style.module.less +14 -0
- package/template-mobile-ts/src/core/gx-design/index.ts +7 -0
- package/template-mobile-ts/src/core/index.ts +12 -0
- package/template-mobile-ts/src/core/vant-design/index.ts +9 -0
- package/template-mobile-ts/src/design/index.less +3 -0
- package/template-mobile-ts/src/design/reset.less +155 -0
- package/template-mobile-ts/src/design/root.less +3 -0
- package/template-mobile-ts/src/design/vant.less +2 -0
- package/template-mobile-ts/src/global.less +1 -0
- package/template-mobile-ts/src/hooks/web/index.ts +5 -0
- package/template-mobile-ts/src/hooks/web/usePageLoading.ts +58 -0
- package/template-mobile-ts/src/layout/BasicLayout.vue +16 -0
- package/template-mobile-ts/src/layout/basicLayout.less +11 -0
- package/template-mobile-ts/src/main.ts +25 -0
- package/template-mobile-ts/src/router/index.ts +25 -0
- package/template-mobile-ts/src/router/routes.ts +20 -0
- package/template-mobile-ts/src/router/typings.ts +8 -0
- package/template-mobile-ts/src/services/index.ts +31 -0
- package/template-mobile-ts/src/store/index.ts +17 -0
- package/template-mobile-ts/src/store/modules/global.ts +33 -0
- package/template-mobile-ts/src/utils/cryptoJS.ts +25 -0
- package/template-mobile-ts/src/utils/index.ts +52 -0
- package/template-mobile-ts/src/utils/pageTitle.ts +12 -0
- package/template-mobile-ts/src/utils/request.ts +105 -0
- package/template-mobile-ts/src/utils/util.ts +32 -0
- package/template-mobile-ts/src/utils/validate.ts +292 -0
- package/template-mobile-ts/src/views/home.vue +82 -0
- package/template-mobile-ts/stylelint.config.js +106 -0
- package/template-mobile-ts/tsconfig.json +43 -0
- package/template-mobile-ts/types/auto-imports.d.ts +61 -0
- package/template-mobile-ts/types/components.d.ts +17 -0
- package/template-mobile-ts/types/global.d.ts +20 -0
- package/template-mobile-ts/types/gx-components.d.ts +13 -0
- package/template-mobile-ts/types/module.d.ts +9 -0
- package/template-mobile-ts/types/response.d.ts +12 -0
- package/template-mobile-ts/vite.config.ts +100 -0
- package/template-vue-ts/.vscode/extensions.json +3 -0
- package/template-vue-ts/README.md +18 -0
- package/template-vue-ts/index.html +13 -0
- package/template-vue-ts/package.json +20 -0
- package/template-vue-ts/public/vite.svg +1 -0
- package/template-vue-ts/src/App.vue +30 -0
- package/template-vue-ts/src/assets/vue.svg +1 -0
- package/template-vue-ts/src/components/HelloWorld.vue +38 -0
- package/template-vue-ts/src/main.ts +5 -0
- package/template-vue-ts/src/style.css +81 -0
- package/template-vue-ts/src/vite-env.d.ts +1 -0
- package/template-vue-ts/tsconfig.json +18 -0
- package/template-vue-ts/tsconfig.node.json +9 -0
- package/template-vue-ts/vite.config.ts +7 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
printWidth: 100,
|
|
3
|
+
useTabs: false,
|
|
4
|
+
semi: false,
|
|
5
|
+
singleQuote: true,
|
|
6
|
+
quoteProps: 'as-needed',
|
|
7
|
+
bracketSpacing: true,
|
|
8
|
+
trailingComma: 'none',
|
|
9
|
+
jsxBracketSameLine: false,
|
|
10
|
+
jsxSingleQuote: false,
|
|
11
|
+
arrowParens: 'always',
|
|
12
|
+
insertPragma: false,
|
|
13
|
+
requirePragma: false,
|
|
14
|
+
proseWrap: 'never',
|
|
15
|
+
htmlWhitespaceSensitivity: 'strict',
|
|
16
|
+
endOfLine: 'auto',
|
|
17
|
+
rangeStart: 0,
|
|
18
|
+
};
|
|
Binary file
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
(function flexible (window, document) {
|
|
2
|
+
var docEl = document.documentElement
|
|
3
|
+
var dpr = window.devicePixelRatio || 1
|
|
4
|
+
|
|
5
|
+
// adjust body font size
|
|
6
|
+
function setBodyFontSize () {
|
|
7
|
+
if (document.body) {
|
|
8
|
+
document.body.style.fontSize = (12 * dpr) + 'px'
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
document.addEventListener('DOMContentLoaded', setBodyFontSize)
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
setBodyFontSize();
|
|
15
|
+
|
|
16
|
+
// set 1rem = viewWidth / 10
|
|
17
|
+
function setRemUnit () {
|
|
18
|
+
var rem = (docEl.clientWidth < 600 ? docEl.clientWidth : 600) / 10
|
|
19
|
+
docEl.style.fontSize = rem + 'px'
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
setRemUnit()
|
|
23
|
+
|
|
24
|
+
// reset rem unit on page resize
|
|
25
|
+
window.addEventListener('resize', setRemUnit)
|
|
26
|
+
window.addEventListener('pageshow', function (e) {
|
|
27
|
+
if (e.persisted) {
|
|
28
|
+
setRemUnit()
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
// detect 0.5px supports
|
|
33
|
+
if (dpr >= 2) {
|
|
34
|
+
var fakeBody = document.createElement('body')
|
|
35
|
+
var testElement = document.createElement('div')
|
|
36
|
+
testElement.style.border = '.5px solid transparent'
|
|
37
|
+
fakeBody.appendChild(testElement)
|
|
38
|
+
docEl.appendChild(fakeBody)
|
|
39
|
+
if (testElement.offsetHeight === 1) {
|
|
40
|
+
docEl.classList.add('hairlines')
|
|
41
|
+
}
|
|
42
|
+
docEl.removeChild(fakeBody)
|
|
43
|
+
}
|
|
44
|
+
}(window, document))
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { FunctionalComponent } from 'vue'
|
|
2
|
+
import { Skeleton } from 'vant'
|
|
3
|
+
import styles from './style.module.less'
|
|
4
|
+
|
|
5
|
+
import 'vant/es/skeleton/style'
|
|
6
|
+
|
|
7
|
+
const Proskeleton: FunctionalComponent<{ line: number; loading: boolean }> = (props, { slots }) => {
|
|
8
|
+
|
|
9
|
+
const renderMapItem = () => {
|
|
10
|
+
const show = []
|
|
11
|
+
for(let i = 0; i < props.line; i += 1) {
|
|
12
|
+
show.push(
|
|
13
|
+
<div class={styles.skeletonItem}>
|
|
14
|
+
<Skeleton row={3} loading />
|
|
15
|
+
</div>
|
|
16
|
+
)
|
|
17
|
+
}
|
|
18
|
+
return show
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<>
|
|
23
|
+
{
|
|
24
|
+
props.loading ? renderMapItem() : <>{ slots.default?.() }</>
|
|
25
|
+
}
|
|
26
|
+
</>
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default Proskeleton
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { defineComponent, toRefs, watch } from 'vue'
|
|
2
|
+
import { usePageLoading } from '@gx-mobile/hooks/web'
|
|
3
|
+
import ProSkeleton from './ProSkeleton'
|
|
4
|
+
import styles from './style.module.less'
|
|
5
|
+
import type { SetLoadingParams } from '@gx-mobile/hooks/web/usePageLoading'
|
|
6
|
+
|
|
7
|
+
export type PageLoadingTpe = 'toast' | 'skeleton'
|
|
8
|
+
|
|
9
|
+
type ChangeLoadingParams<T> = Omit<SetLoadingParams<T>, 'type'> & {
|
|
10
|
+
hiddenSlot?: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const PageContainer = defineComponent({
|
|
14
|
+
name: 'GProPageContainer',
|
|
15
|
+
props: {
|
|
16
|
+
loading: Boolean as PropType<boolean>,
|
|
17
|
+
hiddenSlot: {
|
|
18
|
+
type: Boolean as PropType<boolean>,
|
|
19
|
+
default: true
|
|
20
|
+
},
|
|
21
|
+
loadingMsg: {
|
|
22
|
+
type: String as PropType<string>,
|
|
23
|
+
default: '加载中'
|
|
24
|
+
},
|
|
25
|
+
loadingType: {
|
|
26
|
+
type: String as PropType<PageLoadingTpe>,
|
|
27
|
+
default: 'toast'
|
|
28
|
+
},
|
|
29
|
+
bgcolor: {
|
|
30
|
+
type: String as PropType<string>,
|
|
31
|
+
default: '#fafafa'
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
emits: [ 'update:loading' ],
|
|
35
|
+
setup(props, { slots, expose, emit }) {
|
|
36
|
+
const { loading: loadingRef, loadingType, loadingMsg, hiddenSlot } = toRefs(props)
|
|
37
|
+
|
|
38
|
+
const initStatus = ref(true)
|
|
39
|
+
|
|
40
|
+
const hiddenSlotRef = ref(props.hiddenSlot)
|
|
41
|
+
|
|
42
|
+
const [ loading, setLoading ] = usePageLoading({
|
|
43
|
+
defaultType: loadingType.value,
|
|
44
|
+
defaultMessage: loadingMsg.value,
|
|
45
|
+
defaultLoading: loadingRef.value
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
watch(() => loading.value, (val) => {
|
|
49
|
+
if (initStatus.value && val) initStatus.value = false
|
|
50
|
+
emit('update:loading', val)
|
|
51
|
+
}, {
|
|
52
|
+
deep: true,
|
|
53
|
+
immediate: true
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
watch(() => loadingRef.value, (val) => {
|
|
57
|
+
if (loadingType.value === 'toast') {
|
|
58
|
+
setLoading({
|
|
59
|
+
value: val,
|
|
60
|
+
type: loadingType.value,
|
|
61
|
+
message: loadingMsg.value
|
|
62
|
+
})
|
|
63
|
+
} else if (initStatus.value || !val) {
|
|
64
|
+
setLoading({
|
|
65
|
+
value: val,
|
|
66
|
+
type: loadingType.value,
|
|
67
|
+
message: loadingMsg.value
|
|
68
|
+
})
|
|
69
|
+
}
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
watch(() => hiddenSlot.value, (val) => {
|
|
73
|
+
hiddenSlotRef.value = val
|
|
74
|
+
}, {
|
|
75
|
+
immediate: true
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
const changeLoading = ({
|
|
79
|
+
value,
|
|
80
|
+
message,
|
|
81
|
+
hiddenSlot
|
|
82
|
+
}: ChangeLoadingParams<boolean>) => {
|
|
83
|
+
if (loadingType.value === 'toast') {
|
|
84
|
+
hiddenSlotRef.value = hiddenSlot
|
|
85
|
+
setLoading({ value, message, type: loadingType.value })
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
expose({
|
|
90
|
+
toggleLoading: changeLoading
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
return () => {
|
|
94
|
+
return (
|
|
95
|
+
<div class={styles.pageContainer} style={{ backgroundColor: props.bgcolor }}>
|
|
96
|
+
<div class={styles.pageContainerWrapper}>
|
|
97
|
+
{
|
|
98
|
+
loadingType.value === 'skeleton'
|
|
99
|
+
? (
|
|
100
|
+
<ProSkeleton line={3} loading={loading.value}>
|
|
101
|
+
{slots.default?.()}
|
|
102
|
+
</ProSkeleton>
|
|
103
|
+
)
|
|
104
|
+
: ((!loading.value || !hiddenSlotRef.value) && <>{slots.default?.()}</>)
|
|
105
|
+
}
|
|
106
|
+
</div>
|
|
107
|
+
</div>
|
|
108
|
+
)
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
export default PageContainer
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/****reset****/
|
|
2
|
+
body,
|
|
3
|
+
div,
|
|
4
|
+
table,
|
|
5
|
+
tr,
|
|
6
|
+
td,
|
|
7
|
+
th,
|
|
8
|
+
h1,
|
|
9
|
+
h2,
|
|
10
|
+
h3,
|
|
11
|
+
h4,
|
|
12
|
+
h5,
|
|
13
|
+
h6,
|
|
14
|
+
form,
|
|
15
|
+
input,
|
|
16
|
+
button,
|
|
17
|
+
label,
|
|
18
|
+
select,
|
|
19
|
+
textarea,
|
|
20
|
+
p,
|
|
21
|
+
u,
|
|
22
|
+
i,
|
|
23
|
+
em,
|
|
24
|
+
ul,
|
|
25
|
+
ol,
|
|
26
|
+
li,
|
|
27
|
+
dl,
|
|
28
|
+
dd,
|
|
29
|
+
dt,
|
|
30
|
+
img,
|
|
31
|
+
article,
|
|
32
|
+
aside,
|
|
33
|
+
details,
|
|
34
|
+
figcaption,
|
|
35
|
+
figure,
|
|
36
|
+
footer,
|
|
37
|
+
header,
|
|
38
|
+
menu,
|
|
39
|
+
nav,
|
|
40
|
+
section,
|
|
41
|
+
pre {
|
|
42
|
+
box-sizing: border-box;
|
|
43
|
+
margin: 0;
|
|
44
|
+
padding: 0;
|
|
45
|
+
font-size: 100%;
|
|
46
|
+
vertical-align: baseline;
|
|
47
|
+
border: 0;
|
|
48
|
+
outline: 0;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
li {
|
|
52
|
+
list-style: none;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
h1,
|
|
56
|
+
h2,
|
|
57
|
+
h3,
|
|
58
|
+
h4,
|
|
59
|
+
h5,
|
|
60
|
+
h6 {
|
|
61
|
+
font-size: 100%;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
table {
|
|
65
|
+
border-collapse: collapse;
|
|
66
|
+
border-spacing: 0;
|
|
67
|
+
width: 100%;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
a,
|
|
71
|
+
input,
|
|
72
|
+
select,
|
|
73
|
+
textarea,
|
|
74
|
+
area,
|
|
75
|
+
button {
|
|
76
|
+
outline: none;
|
|
77
|
+
font-family: inherit;
|
|
78
|
+
font-size: inherit;
|
|
79
|
+
border: none;
|
|
80
|
+
background: none;
|
|
81
|
+
color: inherit;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
a {
|
|
85
|
+
text-decoration: none;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
a:hover {
|
|
89
|
+
text-decoration: none;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
textarea {
|
|
93
|
+
overflow: auto;
|
|
94
|
+
resize: none;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
input[type='button'],
|
|
98
|
+
input[type='submit'],
|
|
99
|
+
input[type='reset'] {
|
|
100
|
+
cursor: pointer;
|
|
101
|
+
-webkit-appearance: none;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
html,
|
|
105
|
+
body {
|
|
106
|
+
overflow-x: hidden;
|
|
107
|
+
width: 100%;
|
|
108
|
+
height: 100%;
|
|
109
|
+
background: #ffffff;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
* {
|
|
113
|
+
-webkit-overflow-scrolling: touch;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
html {
|
|
117
|
+
-webkit-tap-highlight-color: transparent;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
body {
|
|
121
|
+
text-align: left;
|
|
122
|
+
padding-bottom: constant(safe-area-inset-bottom);
|
|
123
|
+
padding-bottom: env(safe-area-inset-bottom);
|
|
124
|
+
|
|
125
|
+
#app {
|
|
126
|
+
height: 100%;
|
|
127
|
+
-webkit-font-smoothing: antialiased;
|
|
128
|
+
-moz-osx-font-smoothing: grayscale;
|
|
129
|
+
overflow-x: hidden;
|
|
130
|
+
box-sizing: border-box;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.fl {
|
|
135
|
+
float: left;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.fr {
|
|
139
|
+
float: right;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.clearfix {
|
|
143
|
+
zoom: 1;
|
|
144
|
+
&::before,
|
|
145
|
+
&::after {
|
|
146
|
+
display: table;
|
|
147
|
+
content: ' ';
|
|
148
|
+
}
|
|
149
|
+
&::after {
|
|
150
|
+
clear: both;
|
|
151
|
+
height: 0;
|
|
152
|
+
font-size: 0;
|
|
153
|
+
visibility: hidden;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import './design/index';
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { Ref } from 'vue'
|
|
2
|
+
import { ref, watch } from 'vue'
|
|
3
|
+
import { Toast } from 'vant'
|
|
4
|
+
import { ToastWrapperInstance } from 'vant/lib/toast/types'
|
|
5
|
+
import type { PageLoadingTpe } from '@/components/PageContainer'
|
|
6
|
+
|
|
7
|
+
export type SetLoadingParams<T> = { value: T; type?: PageLoadingTpe; message?: string }
|
|
8
|
+
|
|
9
|
+
type ChangeLoadingFn<T> = ({ value, type, message }: SetLoadingParams<T>) => void
|
|
10
|
+
|
|
11
|
+
export default function usePageLoading<T, R = Ref<T>>({
|
|
12
|
+
defaultType,
|
|
13
|
+
defaultMessage,
|
|
14
|
+
defaultLoading,
|
|
15
|
+
}: {
|
|
16
|
+
defaultType?: PageLoadingTpe;
|
|
17
|
+
defaultMessage?: string;
|
|
18
|
+
defaultLoading?: T | (() => T);
|
|
19
|
+
}): [ R, ChangeLoadingFn<T> ] {
|
|
20
|
+
|
|
21
|
+
const initValue: T =
|
|
22
|
+
typeof defaultLoading === 'function' ? (defaultLoading as any)() : defaultLoading
|
|
23
|
+
|
|
24
|
+
const pageLoading = ref(initValue) as Ref<T>
|
|
25
|
+
|
|
26
|
+
const loadingMessage = ref(defaultMessage)
|
|
27
|
+
|
|
28
|
+
const loadingType = ref(defaultType)
|
|
29
|
+
|
|
30
|
+
const pageLoadingRef = ref<ToastWrapperInstance>()
|
|
31
|
+
|
|
32
|
+
watch(() => pageLoading.value, (val) => {
|
|
33
|
+
if (val) {
|
|
34
|
+
if (loadingType.value === 'toast') {
|
|
35
|
+
pageLoadingRef.value = Toast.loading({
|
|
36
|
+
duration: 0,
|
|
37
|
+
forbidClick: true,
|
|
38
|
+
message: loadingMessage.value || '加载中'
|
|
39
|
+
})
|
|
40
|
+
} else {
|
|
41
|
+
pageLoadingRef.value?.clear()
|
|
42
|
+
}
|
|
43
|
+
} else {
|
|
44
|
+
pageLoadingRef.value?.clear()
|
|
45
|
+
}
|
|
46
|
+
}, {
|
|
47
|
+
deep: true,
|
|
48
|
+
immediate: true
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
const changeLoading = ({ value, type, message }: SetLoadingParams<T>) => {
|
|
52
|
+
pageLoading.value = value
|
|
53
|
+
loadingMessage.value = message
|
|
54
|
+
if (type) loadingType.value = type
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return [ pageLoading as unknown as R, changeLoading ]
|
|
58
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="$style['basic-layout']">
|
|
3
|
+
<RouterView>
|
|
4
|
+
<template #default="{ Component }">
|
|
5
|
+
<component :is="Component" />
|
|
6
|
+
</template>
|
|
7
|
+
</RouterView>
|
|
8
|
+
</div>
|
|
9
|
+
</template>
|
|
10
|
+
|
|
11
|
+
<script setup lang="ts">
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<style lang="less" module>
|
|
15
|
+
@import './basicLayout';
|
|
16
|
+
</style>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createApp } from 'vue'
|
|
2
|
+
import { setupRouter } from '@/router'
|
|
3
|
+
import { setupStore } from './store'
|
|
4
|
+
import { setupGlobCommon } from './core'
|
|
5
|
+
import App from './App.vue'
|
|
6
|
+
|
|
7
|
+
import 'vant/es/toast/style';
|
|
8
|
+
|
|
9
|
+
import './global.less'
|
|
10
|
+
|
|
11
|
+
function startApp() {
|
|
12
|
+
const app = createApp(App)
|
|
13
|
+
|
|
14
|
+
// 配置store
|
|
15
|
+
setupStore(app)
|
|
16
|
+
|
|
17
|
+
// 配置路由
|
|
18
|
+
setupRouter(app)
|
|
19
|
+
|
|
20
|
+
setupGlobCommon(app)
|
|
21
|
+
|
|
22
|
+
app.mount('#app')
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
startApp()
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { App } from 'vue'
|
|
2
|
+
import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
|
|
3
|
+
import { useStoreGlobal } from '@/store'
|
|
4
|
+
import getPageTitle from '@/utils/pageTitle'
|
|
5
|
+
import { constantRoutes } from './routes'
|
|
6
|
+
|
|
7
|
+
const router = createRouter({
|
|
8
|
+
history: createWebHashHistory(),
|
|
9
|
+
routes: constantRoutes as unknown as RouteRecordRaw[]
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
const doRouterPermission = () => {
|
|
13
|
+
router.afterEach((to) => {
|
|
14
|
+
const global = useStoreGlobal()
|
|
15
|
+
const { meta }: any = to
|
|
16
|
+
document.title = getPageTitle(global.title, meta.title || '')
|
|
17
|
+
})
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// 配置路由器
|
|
21
|
+
export function setupRouter(app: App<Element>) {
|
|
22
|
+
app.use(router);
|
|
23
|
+
|
|
24
|
+
doRouterPermission()
|
|
25
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { AppRouteModule } from './typings'
|
|
2
|
+
import BasicLayout from '@/layout/BasicLayout.vue'
|
|
3
|
+
|
|
4
|
+
export const constantRoutes: AppRouteModule[] = [
|
|
5
|
+
{
|
|
6
|
+
path: '/',
|
|
7
|
+
component: BasicLayout,
|
|
8
|
+
redirect: '/home',
|
|
9
|
+
children: [
|
|
10
|
+
{
|
|
11
|
+
path: '/home',
|
|
12
|
+
name: 'Home',
|
|
13
|
+
meta: {
|
|
14
|
+
title: '首页'
|
|
15
|
+
},
|
|
16
|
+
component: () => import('@/views/home.vue')
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
}
|
|
20
|
+
]
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import request from '@/utils/request'
|
|
2
|
+
|
|
3
|
+
// get 请求
|
|
4
|
+
export function getMock(params) {
|
|
5
|
+
return request({
|
|
6
|
+
url: '/get/mock',
|
|
7
|
+
method: 'get',
|
|
8
|
+
isMock: true,
|
|
9
|
+
params
|
|
10
|
+
})
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// post 请求
|
|
14
|
+
export function postMock(data) {
|
|
15
|
+
return request({
|
|
16
|
+
url: '/post/mock',
|
|
17
|
+
method: 'post',
|
|
18
|
+
isMock: true,
|
|
19
|
+
data
|
|
20
|
+
})
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// formData 请求
|
|
24
|
+
export function formDataMock(data) {
|
|
25
|
+
return request({
|
|
26
|
+
url: '/formData/mock',
|
|
27
|
+
method: 'post',
|
|
28
|
+
isMock: true,
|
|
29
|
+
data
|
|
30
|
+
})
|
|
31
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { App } from 'vue'
|
|
2
|
+
import { createPinia } from 'pinia'
|
|
3
|
+
import { useStoreGlobal } from './modules/global'
|
|
4
|
+
|
|
5
|
+
export {
|
|
6
|
+
useStoreGlobal
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function useStore() {
|
|
10
|
+
return {
|
|
11
|
+
global: useStoreGlobal()
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function setupStore(app: App<Element>) {
|
|
16
|
+
app.use(createPinia())
|
|
17
|
+
}
|