@winjs-dev/create-win 1.0.0-alpha.2

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 (150) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +195 -0
  3. package/bin/create-win.js +4 -0
  4. package/dist/cli.d.ts +1 -0
  5. package/dist/cli.js +23 -0
  6. package/dist/index.d.ts +45 -0
  7. package/dist/index.js +396 -0
  8. package/dist/template.d.ts +13 -0
  9. package/dist/template.js +123 -0
  10. package/package.json +36 -0
  11. package/templates/app/.cursor/rules/clean-code.mdc +55 -0
  12. package/templates/app/.cursor/rules/general.mdc +51 -0
  13. package/templates/app/.cursor/rules/git-conventional-commit-messages.mdc +127 -0
  14. package/templates/app/.cursor/rules/gitflow.mdc +111 -0
  15. package/templates/app/.cursor/rules/project-structure.mdc +69 -0
  16. package/templates/app/.cursor/rules/typescript.mdc +57 -0
  17. package/templates/app/.cursor/rules/vue.mdc +86 -0
  18. package/templates/app/.editorconfig.tpl +23 -0
  19. package/templates/app/.eslintignore +13 -0
  20. package/templates/app/.eslintrc.js +9 -0
  21. package/templates/app/.gitignore.tpl +55 -0
  22. package/templates/app/.husky/commit-msg +6 -0
  23. package/templates/app/.husky/pre-commit +5 -0
  24. package/templates/app/.lintstagedrc.tpl +5 -0
  25. package/templates/app/.npmrc.tpl +2 -0
  26. package/templates/app/.prettierignore +13 -0
  27. package/templates/app/.prettierrc.js +4 -0
  28. package/templates/app/.stylelintignore +6 -0
  29. package/templates/app/.stylelintrc.js +16 -0
  30. package/templates/app/.winrc.ts.tpl +95 -0
  31. package/templates/app/README.md +244 -0
  32. package/templates/app/commitlint.config.js +3 -0
  33. package/templates/app/f2elint.config.js +6 -0
  34. package/templates/app/package.json.tpl +34 -0
  35. package/templates/app/plugin.ts.tpl +23 -0
  36. package/templates/app/src/app.js +55 -0
  37. package/templates/app/src/assets/fonts/demo.css +412 -0
  38. package/templates/app/src/assets/fonts/demo_fontclass.html +42 -0
  39. package/templates/app/src/assets/fonts/demo_symbol.html +69 -0
  40. package/templates/app/src/assets/fonts/demo_unicode.html +77 -0
  41. package/templates/app/src/assets/fonts/iconfont.css +20 -0
  42. package/templates/app/src/assets/fonts/iconfont.eot +0 -0
  43. package/templates/app/src/assets/fonts/iconfont.js +96 -0
  44. package/templates/app/src/assets/fonts/iconfont.svg +36 -0
  45. package/templates/app/src/assets/fonts/iconfont.ttf +0 -0
  46. package/templates/app/src/assets/fonts/iconfont.woff +0 -0
  47. package/templates/app/src/assets/img/logo.png +0 -0
  48. package/templates/app/src/assets/js/.gitkeep +0 -0
  49. package/templates/app/src/assets/style/app.less +5 -0
  50. package/templates/app/src/assets/style/main.less +39 -0
  51. package/templates/app/src/assets/style/variable.less +53 -0
  52. package/templates/app/src/constant.js +5 -0
  53. package/templates/app/src/global.less +1 -0
  54. package/templates/app/src/icons/cat.svg +1 -0
  55. package/templates/app/src/icons/dog.svg +1 -0
  56. package/templates/app/src/layouts/index.vue +15 -0
  57. package/templates/app/src/pages/docs.vue +5 -0
  58. package/templates/app/src/pages/hello/index.vue +88 -0
  59. package/templates/app/src/pages/hello/style.less +41 -0
  60. package/templates/app/src/pages/index.vue +9 -0
  61. package/templates/app/src/services/RESTFULURL.js +3 -0
  62. package/templates/app/src/services/autoMatchBaseUrl.js +18 -0
  63. package/templates/app/src/services/index.js +11 -0
  64. package/templates/app/src/services/request.js +178 -0
  65. package/templates/app/tsconfig.json.tpl +3 -0
  66. package/templates/app/typings.d.ts +1 -0
  67. package/templates/pc/.cursor/rules/clean-code.mdc +55 -0
  68. package/templates/pc/.cursor/rules/general.mdc +51 -0
  69. package/templates/pc/.cursor/rules/git-conventional-commit-messages.mdc +127 -0
  70. package/templates/pc/.cursor/rules/gitflow.mdc +111 -0
  71. package/templates/pc/.cursor/rules/project-structure.mdc +69 -0
  72. package/templates/pc/.cursor/rules/typescript.mdc +57 -0
  73. package/templates/pc/.cursor/rules/vue.mdc +86 -0
  74. package/templates/pc/.editorconfig.tpl +23 -0
  75. package/templates/pc/.eslintignore +13 -0
  76. package/templates/pc/.eslintrc.js +9 -0
  77. package/templates/pc/.gitignore.tpl +54 -0
  78. package/templates/pc/.husky/commit-msg +6 -0
  79. package/templates/pc/.husky/pre-commit +5 -0
  80. package/templates/pc/.lintstagedrc.tpl +5 -0
  81. package/templates/pc/.npmrc.tpl +2 -0
  82. package/templates/pc/.prettierignore +13 -0
  83. package/templates/pc/.prettierrc.js +4 -0
  84. package/templates/pc/.stylelintignore +6 -0
  85. package/templates/pc/.stylelintrc.js +16 -0
  86. package/templates/pc/.winrc.ts.tpl +74 -0
  87. package/templates/pc/README.md +255 -0
  88. package/templates/pc/commitlint.config.js +3 -0
  89. package/templates/pc/f2elint.config.js +6 -0
  90. package/templates/pc/package.json.tpl +33 -0
  91. package/templates/pc/plugin.ts.tpl +23 -0
  92. package/templates/pc/src/app.js +55 -0
  93. package/templates/pc/src/assets/fonts/demo.css +412 -0
  94. package/templates/pc/src/assets/fonts/demo_fontclass.html +42 -0
  95. package/templates/pc/src/assets/fonts/demo_symbol.html +69 -0
  96. package/templates/pc/src/assets/fonts/demo_unicode.html +77 -0
  97. package/templates/pc/src/assets/fonts/iconfont.css +20 -0
  98. package/templates/pc/src/assets/fonts/iconfont.eot +0 -0
  99. package/templates/pc/src/assets/fonts/iconfont.js +96 -0
  100. package/templates/pc/src/assets/fonts/iconfont.svg +36 -0
  101. package/templates/pc/src/assets/fonts/iconfont.ttf +0 -0
  102. package/templates/pc/src/assets/fonts/iconfont.woff +0 -0
  103. package/templates/pc/src/assets/img/logo.png +0 -0
  104. package/templates/pc/src/assets/js/.gitkeep +0 -0
  105. package/templates/pc/src/assets/style/app.less +5 -0
  106. package/templates/pc/src/assets/style/main.less +39 -0
  107. package/templates/pc/src/assets/style/variable.less +53 -0
  108. package/templates/pc/src/constant.js +5 -0
  109. package/templates/pc/src/global.less +1 -0
  110. package/templates/pc/src/icons/cat.svg +1 -0
  111. package/templates/pc/src/icons/dog.svg +1 -0
  112. package/templates/pc/src/layouts/index.vue +16 -0
  113. package/templates/pc/src/pages/docs.vue +5 -0
  114. package/templates/pc/src/pages/hello/index.vue +88 -0
  115. package/templates/pc/src/pages/hello/style.less +41 -0
  116. package/templates/pc/src/pages/index.vue +9 -0
  117. package/templates/pc/src/services/RESTFULURL.js +3 -0
  118. package/templates/pc/src/services/autoMatchBaseUrl.js +18 -0
  119. package/templates/pc/src/services/index.js +11 -0
  120. package/templates/pc/src/services/request.js +178 -0
  121. package/templates/pc/tsconfig.json.tpl +3 -0
  122. package/templates/pc/typings.d.ts +1 -0
  123. package/templates/plugin/.fatherrc.ts +5 -0
  124. package/templates/plugin/.gitignore.tpl +2 -0
  125. package/templates/plugin/.npmrc.tpl +2 -0
  126. package/templates/plugin/README.md.tpl +29 -0
  127. package/templates/plugin/package.json.tpl +26 -0
  128. package/templates/plugin/src/index.ts.tpl +5 -0
  129. package/templates/plugin/tsconfig.json +19 -0
  130. package/templates/sample/.cursor/rules/clean-code.mdc +55 -0
  131. package/templates/sample/.cursor/rules/general.mdc +51 -0
  132. package/templates/sample/.cursor/rules/git-conventional-commit-messages.mdc +127 -0
  133. package/templates/sample/.cursor/rules/gitflow.mdc +111 -0
  134. package/templates/sample/.cursor/rules/project-structure.mdc +69 -0
  135. package/templates/sample/.cursor/rules/typescript.mdc +57 -0
  136. package/templates/sample/.cursor/rules/vue.mdc +86 -0
  137. package/templates/sample/.editorconfig.tpl +23 -0
  138. package/templates/sample/.gitignore.tpl +19 -0
  139. package/templates/sample/.npmrc.tpl +2 -0
  140. package/templates/sample/.winrc.ts.tpl +7 -0
  141. package/templates/sample/package.json.tpl +21 -0
  142. package/templates/sample/plugin.ts.tpl +7 -0
  143. package/templates/sample/src/assets/img/logo.png +0 -0
  144. package/templates/sample/src/layouts/index.vue +8 -0
  145. package/templates/sample/src/pages/docs.vue +5 -0
  146. package/templates/sample/src/pages/hello/index.vue +77 -0
  147. package/templates/sample/src/pages/hello/style.less +41 -0
  148. package/templates/sample/src/pages/index.vue +9 -0
  149. package/templates/sample/tsconfig.json.tpl +3 -0
  150. package/templates/sample/typings.d.ts +1 -0
@@ -0,0 +1,13 @@
1
+ **/*.svg
2
+ output.js
3
+ src/assets/
4
+ dist/**
5
+ public/**
6
+ src/services/RESTFULURL.js
7
+ src/icons
8
+ src/.win
9
+ src/.win-production
10
+ .npmrc
11
+ .yarnrc
12
+ node_modules
13
+
@@ -0,0 +1,4 @@
1
+ module.exports = {
2
+ ...require('@winner-fed/prettier-config-win'),
3
+ plugins: ['prettier-plugin-organize-imports', 'prettier-plugin-packagejson']
4
+ }
@@ -0,0 +1,6 @@
1
+ node_modules/
2
+ config/
3
+ dist/
4
+ src/assets/fonts/
5
+ public/
6
+
@@ -0,0 +1,16 @@
1
+ // https://stylelint.io/
2
+ // https://stylelint.docschina.org/ 中文网站,注意版本是否和官网一致
3
+ module.exports = {
4
+ extends: ['@winner-fed/stylelint-config-win', 'stylelint-config-prettier'],
5
+ // Less 语法检测
6
+ customSyntax: 'postcss-less',
7
+ overrides: [
8
+ {
9
+ files: ['*.html', '**/*.html', '*.htm', '**/*.htm', '*.vue', '**/*.vue'],
10
+ customSyntax: 'postcss-html'
11
+ }
12
+ ],
13
+ rules: {
14
+ 'font-family-no-missing-generic-family-keyword': 'off'
15
+ }
16
+ };
@@ -0,0 +1,74 @@
1
+ // https://winjs-dev.github.io/winjs-docs/config/config.html
2
+ import { defineConfig } from '@winner-fed/winjs';
3
+
4
+ export default defineConfig({
5
+ npmClient: '{{{ npmClient }}}',
6
+ plugins: ['@winner-fed/plugin-request'],
7
+ /**
8
+ * @name request 配置,可以配置错误处理
9
+ * @description 它基于 axios 和 VueHookPlus 的 useRequest 提供了一套统一的网络请求和错误处理方案。
10
+ * @doc https://winjs-dev.github.io/winjs-docs/plugins/request.html
11
+ */
12
+ request: {},
13
+ /**
14
+ * @name appConfig 配置
15
+ * @description 可以配置前端工程运行的配置文件 `config.local.js` 里内容。
16
+ * @doc https://winjs-dev.github.io/winjs-docs/config/config.html#appconfig
17
+ */
18
+ appConfig: {
19
+ // 本地调试环境
20
+ development: {
21
+ API_HOME: 'https://api.github.com/',
22
+ API_UPLOAD: 'https://api.github.com/upload'
23
+ },
24
+ // 测试环境
25
+ test: {
26
+ API_HOME: 'https://test.github.com/',
27
+ API_UPLOAD: 'https://test.github.com/upload'
28
+ },
29
+ // 生产环境
30
+ production: {
31
+ API_HOME: 'https://production.github.com/',
32
+ API_UPLOAD: 'https://production.github.com/upload'
33
+ }
34
+ },
35
+ /**
36
+ * @name icons 配置
37
+ * @description svg icon 的相关配置
38
+ * @doc https://winjs-dev.github.io/winjs-docs/config/config.html#icons
39
+ */
40
+ icons: {},
41
+ /**
42
+ * @name banner 配置
43
+ * @description 为构建的静态资源(JS、CSS 文件)的头部或尾部注入内容的能力。
44
+ * @doc https://winjs-dev.github.io/winjs-docs/config/config.html#banner
45
+ */
46
+ banner: true,
47
+ targets: { chrome: 51, firefox: 54, safari: 10, edge: 15 },
48
+ jsMinifier: 'terser',
49
+ cssMinifier: 'cssnano',
50
+ /**
51
+ * @name <less> less-loader 里的配置
52
+ * @description 全局注入变量及 mixins
53
+ */
54
+ lessLoader: {
55
+ modifyVars: {
56
+ // 或者可以通过 less 文件覆盖(文件路径为绝对路径)
57
+ 'hack': `true; @import "@/assets/style/variable.less";@import "@winner-fed/magicless/magicless.less";`
58
+ }
59
+ },
60
+ title: '{{{ projectName }}}',
61
+ mountElementId: '{{{ appContainerName }}}',
62
+ mfsu: {
63
+ shared: {
64
+ vue: {
65
+ singleton: true,
66
+ eager: true
67
+ }
68
+ }
69
+ },
70
+ // 开发使用内联CSS,生产使用构建的CSS文件
71
+ styleLoader: process.env.NODE_ENV === 'production' ? false : {},
72
+ // 开发使用 cheap-source-map
73
+ devtool: process.env.NODE_ENV === 'development' ? 'cheap-source-map' : false
74
+ });
@@ -0,0 +1,255 @@
1
+ # WinJS PC Web 模板
2
+
3
+ 一个基于 WinJS 框架的现代化 PC 端 Web 应用模板,提供完整的开发工具链和最佳实践配置。
4
+
5
+ ## 📋 项目简介
6
+
7
+ 本模板专为 PC 端 Web 应用开发而设计,集成了现代前端开发的最佳实践,包括代码规范、构建优化、开发体验等方面的完整解决方案。
8
+
9
+ ## 🚀 技术栈
10
+
11
+ ### 核心框架
12
+
13
+ - **Vue 3.2.x** - 渐进式 JavaScript 框架
14
+ - **Vue Router 4.x** - 官方路由管理器
15
+ - **WinJS** - 企业级前端开发框架
16
+
17
+ ### 开发工具
18
+
19
+ - **TypeScript 5.x** - 类型安全的 JavaScript 超集
20
+ - **Vite** - 下一代前端构建工具
21
+ - **Less** - CSS 预处理器
22
+
23
+ ### 代码质量
24
+
25
+ - **ESLint** - JavaScript/TypeScript 代码检查
26
+ - **Prettier** - 代码格式化工具
27
+ - **Stylelint** - CSS/Less 样式检查
28
+ - **F2ELint** - 前端代码规范工具
29
+ - **Husky** - Git hooks 管理
30
+ - **Lint-staged** - 暂存文件检查
31
+
32
+ ### 工程化
33
+
34
+ - **Cross-env** - 跨平台环境变量设置
35
+ - **Commitlint** - Git 提交信息规范检查
36
+
37
+ ## ✨ 功能特性
38
+
39
+ - 🎯 **开箱即用** - 预配置完整的开发环境
40
+ - 🔧 **工程化完备** - 集成代码规范、构建优化、部署流程
41
+ - 📱 **响应式设计** - 适配不同屏幕尺寸
42
+ - 🌐 **网络请求** - 基于 axios 的统一请求封装
43
+ - 🎨 **样式方案** - Less + CSS Modules 支持
44
+ - 📦 **模块联邦** - 支持微前端架构
45
+ - 🔍 **开发调试** - 完善的 Source Map 和热更新
46
+ - 🚀 **构建优化** - 代码分割、压缩、缓存策略
47
+
48
+ ## 🛠️ 快速开始
49
+
50
+ ### 环境要求
51
+
52
+ - Node.js >= 16.0.0
53
+ - npm >= 8.0.0 或 yarn >= 1.22.0
54
+
55
+ ### 安装依赖
56
+
57
+ ```bash
58
+ # 使用 npm
59
+ npm install
60
+
61
+ # 使用 yarn
62
+ yarn install
63
+ ```
64
+
65
+ ### 开发调试
66
+
67
+ ```bash
68
+ # 启动开发服务器
69
+ npm run dev
70
+
71
+ # 或者
72
+ npm start
73
+ ```
74
+
75
+ 访问 http://localhost:8000 查看应用
76
+
77
+ ### 构建部署
78
+
79
+ ```bash
80
+ # 构建生产版本
81
+ npm run build
82
+
83
+ # 预览构建结果
84
+ npm run preview
85
+ ```
86
+
87
+ ## 📁 项目结构
88
+
89
+ ```
90
+ ├── src/ # 源代码目录
91
+ │ ├── assets/ # 静态资源
92
+ │ ├── icons/ # SVG 图标
93
+ │ ├── layouts/ # 布局组件
94
+ │ ├── pages/ # 页面组件
95
+ │ │ ├── hello/ # 示例页面
96
+ │ │ ├── index.vue # 首页
97
+ │ │ └── docs.vue # 文档页面
98
+ │ ├── services/ # 服务层
99
+ │ ├── app.js # 应用配置
100
+ │ ├── constant.js # 常量定义
101
+ │ └── global.less # 全局样式
102
+ ├── .winrc.ts # WinJS 配置文件
103
+ ├── package.json # 项目依赖配置
104
+ ├── tsconfig.json # TypeScript 配置
105
+ ├── .eslintrc.js # ESLint 配置
106
+ ├── .prettierrc.js # Prettier 配置
107
+ ├── .stylelintrc.js # Stylelint 配置
108
+ └── README.md # 项目说明文档
109
+ ```
110
+
111
+ ## 🔧 开发指南
112
+
113
+ ### 代码规范
114
+
115
+ 项目集成了完整的代码规范工具链:
116
+
117
+ ```bash
118
+ # 代码检查
119
+ npm run lint
120
+
121
+ # 代码格式化
122
+ npm run format
123
+
124
+ # F2ELint 扫描
125
+ npm run f2elint-scan
126
+
127
+ # F2ELint 修复
128
+ npm run f2elint-fix
129
+ ```
130
+
131
+ ### 环境配置
132
+
133
+ 在 `.winrc.ts` 中配置不同环境的 API 地址:
134
+
135
+ ```typescript
136
+ appConfig: {
137
+ development: {
138
+ API_HOME: 'https://api.github.com/',
139
+ API_UPLOAD: 'https://api.github.com/upload'
140
+ },
141
+ test: {
142
+ API_HOME: 'https://test.github.com/',
143
+ API_UPLOAD: 'https://test.github.com/upload'
144
+ },
145
+ production: {
146
+ API_HOME: 'https://production.github.com/',
147
+ API_UPLOAD: 'https://production.github.com/upload'
148
+ }
149
+ }
150
+ ```
151
+
152
+ ### 网络请求
153
+
154
+ 使用统一的请求封装,支持拦截器配置:
155
+
156
+ ```javascript
157
+ // 在 app.js 中配置请求拦截器
158
+ export const request = {
159
+ timeout: TIMEOUT,
160
+ requestInterceptors: [
161
+ [
162
+ (config) => {
163
+ // 请求前处理
164
+ return httpRequest.success(config);
165
+ },
166
+ (error) => {
167
+ // 请求错误处理
168
+ return httpRequest.error(error);
169
+ }
170
+ ]
171
+ ],
172
+ responseInterceptors: [
173
+ [
174
+ (response) => {
175
+ // 响应成功处理
176
+ return httpResponse.success(response);
177
+ },
178
+ (error) => {
179
+ // 响应错误处理
180
+ return httpResponse.error(error);
181
+ }
182
+ ]
183
+ ]
184
+ };
185
+ ```
186
+
187
+ ### 样式开发
188
+
189
+ - 支持 Less 预处理器
190
+ - 集成 MagicLess 工具库
191
+ - 支持全局变量和 mixins
192
+
193
+ ```less
194
+ // 在 .winrc.ts 中配置 Less
195
+ lessLoader: {
196
+ modifyVars: {
197
+ 'hack': `true; @import "@/assets/style/variable.less";@import "@winner-fed/magicless/magicless.less";`
198
+ }
199
+ }
200
+ ```
201
+
202
+ ## 📦 构建配置
203
+
204
+ ### 浏览器兼容性
205
+
206
+ ```javascript
207
+ targets: {
208
+ chrome: 51,
209
+ firefox: 54,
210
+ safari: 10,
211
+ edge: 15
212
+ }
213
+ ```
214
+
215
+ ### 构建优化
216
+
217
+ - **代码压缩**: 使用 Terser 压缩 JavaScript,cssnano 压缩 CSS
218
+ - **模块联邦**: 支持微前端架构
219
+ - **Source Map**: 开发环境使用 cheap-source-map
220
+ - **样式处理**: 开发环境内联 CSS,生产环境提取 CSS 文件
221
+
222
+ ## 🔍 调试与测试
223
+
224
+ ### 开发调试
225
+
226
+ - 热更新支持
227
+ - Source Map 调试
228
+ - 详细的错误信息
229
+
230
+ ### 代码质量检查
231
+
232
+ 项目配置了多层代码质量保障:
233
+
234
+ 1. **提交前检查**: 通过 Husky 和 lint-staged 在提交前自动检查代码
235
+ 2. **实时检查**: 编辑器集成 ESLint、Prettier、Stylelint
236
+ 3. **CI/CD 集成**: 支持持续集成环境的代码检查
237
+
238
+ ## 📚 相关文档
239
+
240
+ - [WinJS 官方文档](https://winjs-dev.github.io/winjs-docs/)
241
+ - [Vue 3 官方文档](https://vuejs.org/)
242
+ - [Vue Router 4 文档](https://router.vuejs.org/)
243
+ - [TypeScript 文档](https://www.typescriptlang.org/)
244
+
245
+ ## 🆘 问题反馈
246
+
247
+ 如果您在使用过程中遇到问题,请通过以下方式反馈:
248
+
249
+ 1. 提交 Issue
250
+ 2. 联系维护团队
251
+ 3. 查阅官方文档
252
+
253
+ ---
254
+
255
+ **Happy Coding! 🎉**
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ extends: ['@winner-fed/commitlint-config-win/hs']
3
+ };
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ enableESLint: true,
3
+ enableStylelint: true,
4
+ enableMarkdownlint: false,
5
+ enablePrettier: false
6
+ };
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "{{{ projectName }}}",
3
+ "version": "1.0.0",
4
+ "buildVersion": "V202101-00-000",
5
+ "private": true,
6
+ "author": "{{{ author }}}",
7
+ "scripts": {
8
+ "dev": "win dev",
9
+ "build": "cross-env WIN_APP_ENV=production win build",
10
+ "lint": "win lint",
11
+ "f2elint-scan": "f2elint scan --include src",
12
+ "f2elint-fix": "f2elint fix --include src",
13
+ "format": "prettier --write \"src/**/*.{js,jsx,json,ts,tsx,css,less,scss,vue,html,md}\" \"package.json\"",
14
+ "postinstall": "win setup",
15
+ "prepare": "husky install",
16
+ "setup": "win setup",
17
+ "start": "npm run dev",
18
+ "preview": "win preview"
19
+ },
20
+ "dependencies": {
21
+ "@winner-fed/cloud-utils": "^2.0.1",
22
+ "@winner-fed/magicless": "*",
23
+ "@winner-fed/winjs": "{{{ version }}}"
24
+ },
25
+ "devDependencies": {
26
+ "@winner-fed/plugin-request": "^1.0.1",
27
+ "@winner-fed/f2elint": "^3.0.0",
28
+ "cross-env": "^7.0.3",
29
+ "husky": "8.0.3",
30
+ "lint-staged": "13.2.3",
31
+ "typescript": "^5.0.3"
32
+ }
33
+ }
@@ -0,0 +1,23 @@
1
+ import type { IApi } from '@winner-fed/winjs';
2
+
3
+ export default (api: IApi) => {
4
+ api.modifyHTML(($) => {
5
+ return $;
6
+ });
7
+
8
+ // meta 添加缓存参数
9
+ api.addHTMLMetas(() => [
10
+ {
11
+ 'http-equiv': 'Cache-Control',
12
+ 'content': 'no-store, no-cache, must-revalidate'
13
+ },
14
+ {
15
+ 'http-equiv': 'Pragma',
16
+ 'content': 'no-cache'
17
+ },
18
+ {
19
+ 'http-equiv': 'Expires',
20
+ 'content': '0'
21
+ }
22
+ ]);
23
+ };
@@ -0,0 +1,55 @@
1
+ import { TIMEOUT } from './constant';
2
+ import { httpRequest, httpResponse } from './services/request';
3
+
4
+ /**
5
+ * @name request 配置,可以配置错误处理
6
+ * 它基于 axios 和 VueHookPlus 的 useRequest 提供了一套统一的网络请求和错误处理方案。
7
+ * @doc https://winjs-dev.github.io/winjs-docs/plugins/request.html
8
+ */
9
+ export const request = {
10
+ timeout: TIMEOUT,
11
+ requestInterceptors: [
12
+ // 一个二元组,第一个元素是 request 拦截器,第二个元素是错误处理
13
+ [
14
+ (config) => {
15
+ console.log('requestInterceptors 1', config);
16
+ return httpRequest.success(config);
17
+ },
18
+ (error) => {
19
+ console.log('error', error);
20
+ return httpRequest.error(error);
21
+ }
22
+ ]
23
+ ],
24
+ responseInterceptors: [
25
+ [
26
+ (response) => {
27
+ console.log('responseInterceptors 1', response);
28
+ return httpResponse.success(response);
29
+ },
30
+ (error) => {
31
+ console.log('responseInterceptors 2', error);
32
+ return httpResponse.error(error);
33
+ }
34
+ ]
35
+ ]
36
+ };
37
+
38
+ export function onRouterCreated({ router }) {
39
+ console.log('onRouterCreated', router);
40
+ }
41
+
42
+ export function onAppCreated({ app }) {
43
+ console.log('onAppCreated', app);
44
+ }
45
+
46
+ export function onMounted({ app, router }) {
47
+ console.log('onMounted', app, router);
48
+ }
49
+
50
+ export const router = {
51
+ // @ts-ignore
52
+ scrollBehavior(to, from) {
53
+ console.log('scrollBehavior', to, from);
54
+ }
55
+ };