@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,86 @@
1
+ ---
2
+ description: Vue.js best practices and patterns for modern web applications
3
+ globs: **/*.vue, **/*.ts, components/**/*
4
+ ---
5
+
6
+ # Vue.js Best Practices
7
+
8
+ ## Component Structure
9
+ - Use Composition API over Options API
10
+ - Keep components small and focused
11
+ - Use proper TypeScript integration
12
+ - Implement proper props validation
13
+ - Use proper emit declarations
14
+ - Keep template logic minimal
15
+
16
+ ## Composition API
17
+ - Use proper ref and reactive
18
+ - Implement proper lifecycle hooks
19
+ - Use composables for reusable logic
20
+ - Keep setup function clean
21
+ - Use proper computed properties
22
+ - Implement proper watchers
23
+
24
+ ## State Management
25
+ - Use Pinia for state management
26
+ - Keep stores modular
27
+ - Use proper state composition
28
+ - Implement proper actions
29
+ - Use proper getters
30
+ - Handle async state properly
31
+
32
+ ## Performance
33
+ - Use proper component lazy loading
34
+ - Implement proper caching
35
+ - Use proper computed properties
36
+ - Avoid unnecessary watchers
37
+ - Use proper v-show vs v-if
38
+ - Implement proper key management
39
+
40
+ ## Routing
41
+ - Use Vue Router properly
42
+ - Implement proper navigation guards
43
+ - Use proper route meta fields
44
+ - Handle route params properly
45
+ - Implement proper lazy loading
46
+ - Use proper navigation methods
47
+
48
+ ## Forms
49
+ - Use v-model properly
50
+ - Implement proper validation
51
+ - Handle form submission properly
52
+ - Show proper loading states
53
+ - Use proper error handling
54
+ - Implement proper form reset
55
+
56
+ ## TypeScript Integration
57
+ - Use proper component type definitions
58
+ - Implement proper prop types
59
+ - Use proper emit declarations
60
+ - Handle proper type inference
61
+ - Use proper composable types
62
+ - Implement proper store types
63
+
64
+ ## Testing
65
+ - Write proper unit tests
66
+ - Implement proper component tests
67
+ - Use Vue Test Utils properly
68
+ - Test composables properly
69
+ - Implement proper mocking
70
+ - Test async operations
71
+
72
+ ## Best Practices
73
+ - Follow Vue style guide
74
+ - Use proper naming conventions
75
+ - Keep components organized
76
+ - Implement proper error handling
77
+ - Use proper event handling
78
+ - Document complex logic
79
+
80
+ ## Build and Tooling
81
+ - Use Vite for development
82
+ - Configure proper build setup
83
+ - Use proper environment variables
84
+ - Implement proper code splitting
85
+ - Use proper asset handling
86
+ - Configure proper optimization
@@ -0,0 +1,23 @@
1
+ # http://editorconfig.org
2
+ root = true
3
+
4
+ [*]
5
+ charset=utf-8
6
+ end_of_line=lf
7
+ insert_final_newline=true
8
+ trim_trailing_whitespace=true
9
+ indent_style=space
10
+ indent_size=2
11
+
12
+ [{.eslintrc,.babelrc,.stylelintrc,*.json}]
13
+ indent_style=space
14
+ indent_size=2
15
+
16
+ [*.less]
17
+ indent_style=space
18
+ indent_size=2
19
+
20
+ [*.{js,jsx,ts,tsx,vue}]
21
+ indent_style=space
22
+ indent_size=2
23
+
@@ -0,0 +1,13 @@
1
+ node_modules/
2
+ config/
3
+ public/
4
+ src/assets/
5
+ /src/.win
6
+ /src/.win-production
7
+ /src/.win-test
8
+ /.win
9
+ /.win-production
10
+ /.win-test
11
+ /dist
12
+ /dist-zip
13
+
@@ -0,0 +1,9 @@
1
+ // http://eslint.org/docs/user-guide/configuring
2
+ // http://eslint.cn/docs/user-guide/configuring 中文,注意版本是否和官网一致
3
+ module.exports = {
4
+ extends: [
5
+ '@winner-fed/eslint-config-win',
6
+ '@winner-fed/eslint-config-win/vue3',
7
+ './.eslintrc-auto-import.json'
8
+ ]
9
+ };
@@ -0,0 +1,55 @@
1
+ /node_modules
2
+ /.env.local
3
+ /.winrc.local.ts
4
+ /config/config.local.ts
5
+ /src/.win
6
+ /src/.win-production
7
+ /src/.win-test
8
+ /src/.huipro
9
+ /.win
10
+ /.win-production
11
+ /.win-test
12
+ /.huipro
13
+ /dist
14
+ /dist-zip
15
+ /.mfsu
16
+ .swc
17
+ components.d.ts
18
+ auto-imports.d.ts
19
+ f2elint-report.json
20
+
21
+ .DS_Store
22
+ # Log files
23
+ npm-debug.log*
24
+ yarn-debug.log*
25
+ yarn-error.log*
26
+
27
+ # Editor directories and files
28
+ .idea
29
+ .vscode
30
+ *.suo
31
+ *.ntvs*
32
+ *.njsproj
33
+ *.sln
34
+ *.sw*
35
+
36
+ # Optional npm cache directory
37
+ .npm
38
+
39
+ # Optional eslint cache
40
+ .eslintcache
41
+ .eslintrc-auto-import.json
42
+
43
+ # Optional REPL history
44
+ .node_repl_history
45
+
46
+ # Output of 'npm pack'
47
+ *.tgz
48
+
49
+ .project
50
+ .happypack
51
+ .history
52
+
53
+ /package
54
+ /docker/html
55
+
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env sh
2
+ . "$(dirname -- "$0")/_/husky.sh"
3
+
4
+ # 以下选择一个即可
5
+ npx --no-install win verify-commit-hs $1
6
+ #npx f2elint commit-msg-scan
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env sh
2
+ . "$(dirname -- "$0")/_/husky.sh"
3
+
4
+ npx --no-install lint-staged --quiet
5
+ npx f2elint commit-file-scan
@@ -0,0 +1,5 @@
1
+ {
2
+ "*.{md,json}": ["prettier --cache --write"],
3
+ "*.{vue,js,jsx,css,less,scss}": ["win lint --fix", "prettier --cache --write"],
4
+ "*.ts?(x)": ["win lint --fix", "prettier --cache --parser=typescript --write"]
5
+ }
@@ -0,0 +1,2 @@
1
+ registry={{{ registry }}}
2
+ {{{ extraNpmrc }}}
@@ -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,95 @@
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
+ history: {
7
+ type: 'hash'
8
+ },
9
+ plugins: ['@winner-fed/plugin-request', '@winner-fed/plugin-wconsole'],
10
+ /**
11
+ * @name request 配置,可以配置错误处理
12
+ * @description 它基于 axios 和 VueHookPlus 的 useRequest 提供了一套统一的网络请求和错误处理方案。
13
+ * @doc https://winjs-dev.github.io/winjs-docs/plugins/request.html
14
+ */
15
+ request: {},
16
+ /**
17
+ * @name wconsole 配置
18
+ * @description 移动端调试工具
19
+ * @doc https://winjs-dev.github.io/winjs-docs/plugins/wconsole.html
20
+ */
21
+ wconsole: {
22
+ vconsole: {}
23
+ },
24
+ /**
25
+ * @name appConfig 配置
26
+ * @description 可以配置前端工程运行的配置文件 `config.local.js` 里内容。
27
+ * @doc https://winjs-dev.github.io/winjs-docs/config/config.html#appconfig
28
+ */
29
+ appConfig: {
30
+ // 本地调试环境
31
+ development: {
32
+ API_HOME: 'https://api.github.com/',
33
+ API_UPLOAD: 'https://api.github.com/upload',
34
+ // vconsole 开关
35
+ IS_OPEN_VCONSOLE: true
36
+ },
37
+ // 测试环境
38
+ test: {
39
+ API_HOME: 'https://test.github.com/',
40
+ API_UPLOAD: 'https://test.github.com/upload',
41
+ // vconsole 开关
42
+ IS_OPEN_VCONSOLE: true
43
+ },
44
+ // 生产环境
45
+ production: {
46
+ API_HOME: 'https://production.github.com/',
47
+ API_UPLOAD: 'https://production.github.com/upload',
48
+ // vconsole 开关
49
+ IS_OPEN_VCONSOLE: false
50
+ }
51
+ },
52
+ /**
53
+ * @name icons 配置
54
+ * @description svg icon 的相关配置
55
+ * @doc https://winjs-dev.github.io/winjs-docs/config/config.html#icons
56
+ */
57
+ icons: {},
58
+ /**
59
+ * @name 开启 REM 适配能力
60
+ * @description 一键开启 REM 适配能力,能够根据屏幕大小来动态调整字体大小,让网页在不同大小的屏幕上都能够自适应显示。
61
+ * @doc https://winjs-dev.github.io/winjs-docs/config/config.html#converttorem
62
+ */
63
+ convertToRem: {},
64
+ /**
65
+ * @name banner 配置
66
+ * @description 为构建的静态资源(JS、CSS 文件)的头部或尾部注入内容的能力。
67
+ * @doc https://winjs-dev.github.io/winjs-docs/config/config.html#banner
68
+ */
69
+ banner: true,
70
+ targets: { ios: 10, android: 6, chrome: 80 },
71
+ /**
72
+ * @name <less> less-loader 里的配置
73
+ * @description 全局注入变量及 mixins
74
+ */
75
+ lessLoader: {
76
+ modifyVars: {
77
+ // 或者可以通过 less 文件覆盖(文件路径为绝对路径)
78
+ 'hack': `true; @import "@/assets/style/variable.less";@import "@winner-fed/magicless/magicless.less";`
79
+ }
80
+ },
81
+ title: '{{{ projectName }}}',
82
+ mountElementId: '{{{ appContainerName }}}',
83
+ mfsu: {
84
+ shared: {
85
+ vue: {
86
+ singleton: true,
87
+ eager: true
88
+ }
89
+ }
90
+ },
91
+ // 开发使用内联CSS,生产使用构建的CSS文件
92
+ styleLoader: process.env.NODE_ENV === 'production' ? false : {},
93
+ // 开发使用 cheap-source-map
94
+ devtool: process.env.NODE_ENV === 'development' ? 'cheap-source-map' : false
95
+ });
@@ -0,0 +1,244 @@
1
+ # WinJS App 模板
2
+
3
+ > 基于 WinJS 框架的现代化 H5 应用开发模板,提供完整的开发工具链和最佳实践。
4
+
5
+ ## 📋 项目简介
6
+
7
+ WinJS App 模板是一个开箱即用的 H5 应用开发脚手架,集成了现代前端开发的最佳实践和工具链。该模板专为移动端 H5 应用设计,提供了完整的开发、构建、部署解决方案。
8
+
9
+ ### ✨ 特性
10
+
11
+ - 🚀 **现代化技术栈**:基于 Vue 3.2+ 和 Vue Router 4.x
12
+ - 📱 **移动端优化**:内置 REM 适配和移动端调试工具
13
+ - 🛠️ **完整工具链**:集成 ESLint、Prettier、StyleLint 等代码质量工具
14
+ - 🔧 **插件化架构**:支持请求拦截、移动端调试等插件
15
+ - 📦 **模块联邦**:支持微前端架构和模块共享
16
+ - 🎨 **样式解决方案**:支持 Less 预处理器和全局样式注入
17
+ - 🔄 **热更新**:开发环境支持快速热更新
18
+ - 📊 **性能优化**:内置构建优化和缓存策略
19
+
20
+ ## 🛠️ 技术栈
21
+
22
+ ### 核心框架
23
+
24
+ - **Vue 3.2+** - 渐进式 JavaScript 框架
25
+ - **Vue Router 4.x** - Vue.js 官方路由管理器
26
+ - **TypeScript 5.0+** - JavaScript 的超集,提供静态类型检查
27
+
28
+ ### 构建工具
29
+
30
+ - **WinJS** - 基于 Webpack、Rsbuild、Vite 多构建工具的现代化开发元框架
31
+ - **Webpack** - 模块打包器
32
+ - **Babel** - JavaScript 编译器
33
+
34
+ ### 样式处理
35
+
36
+ - **Less** - CSS 预处理器
37
+ - **PostCSS** - CSS 后处理器
38
+ - **MagicLess** - 样式工具库
39
+
40
+ ### 代码质量
41
+
42
+ - **ESLint** - JavaScript 代码检查工具
43
+ - **Prettier** - 代码格式化工具
44
+ - **StyleLint** - CSS 代码检查工具
45
+ - **F2ELint** - 前端代码规范工具
46
+
47
+ ### 开发工具
48
+
49
+ - **Husky** - Git hooks 工具
50
+ - **lint-staged** - 暂存文件检查工具
51
+ - **commitlint** - Git 提交信息规范检查
52
+
53
+ ## 🚀 快速开始
54
+
55
+ ### 环境要求
56
+
57
+ - Node.js >= 16.0.0
58
+ - npm >= 8.0.0 或 yarn >= 1.22.0
59
+
60
+ ### 安装依赖
61
+
62
+ ```bash
63
+ # 使用 npm
64
+ npm install
65
+
66
+ # 使用 yarn
67
+ yarn install
68
+ ```
69
+
70
+ ### 开发命令
71
+
72
+ ```bash
73
+ # 启动开发服务器
74
+ npm run dev
75
+
76
+ # 构建生产版本
77
+ npm run build
78
+
79
+ # 预览构建结果
80
+ npm run preview
81
+
82
+ # 代码检查
83
+ npm run lint
84
+
85
+ # 代码格式化
86
+ npm run format
87
+
88
+ # F2ELint 扫描
89
+ npm run f2elint-scan
90
+
91
+ # F2ELint 修复
92
+ npm run f2elint-fix
93
+ ```
94
+
95
+ ## 📁 项目结构
96
+
97
+ ```
98
+ ├── src/ # 源代码目录
99
+ │ ├── assets/ # 静态资源
100
+ │ │ ├── fonts/ # 字体文件
101
+ │ │ ├── img/ # 图片资源
102
+ │ │ └── style/ # 样式文件
103
+ │ ├── components/ # 公共组件
104
+ │ ├── icons/ # SVG 图标
105
+ │ ├── layouts/ # 布局组件
106
+ │ ├── pages/ # 页面组件
107
+ │ ├── services/ # 网络请求服务
108
+ │ ├── utils/ # 工具函数
109
+ │ ├── app.js # 应用配置文件
110
+ │ ├── constant.js # 常量定义
111
+ │ └── global.less # 全局样式
112
+ ├── public/ # 公共静态资源
113
+ ├── .winrc.ts # WinJS 配置文件
114
+ ├── package.json # 项目依赖配置
115
+ ├── tsconfig.json # TypeScript 配置
116
+ └── README.md # 项目说明文档
117
+ ```
118
+
119
+ ## ⚙️ 配置说明
120
+
121
+ ### WinJS 配置 (.winrc.ts)
122
+
123
+ 项目使用 `.winrc.ts` 文件进行配置,主要配置项包括:
124
+
125
+ - **路由配置**:支持 hash 和 history 模式
126
+ - **插件配置**:请求插件、移动端调试插件等
127
+ - **环境配置**:开发、测试、生产环境的 API 地址配置
128
+ - **样式配置**:Less 变量注入、REM 适配等
129
+ - **构建配置**:模块联邦、源码映射等
130
+
131
+ ### 环境配置
132
+
133
+ 项目支持多环境配置:
134
+
135
+ - **development**:本地开发环境
136
+ - **test**:测试环境
137
+ - **production**:生产环境
138
+
139
+ 每个环境可以配置不同的 API 地址、调试工具开关等。
140
+
141
+ ## 🔌 插件系统
142
+
143
+ ### 内置插件
144
+
145
+ 1. **@winner-fed/plugin-request**
146
+
147
+ - 基于 axios 的网络请求解决方案
148
+ - 支持请求/响应拦截器
149
+ - 统一错误处理机制
150
+
151
+ 2. **@winner-fed/plugin-wconsole**
152
+
153
+ - 移动端调试工具
154
+ - 支持 vConsole 集成
155
+ - 可配置开启/关闭
156
+
157
+ ## 📱 移动端适配
158
+
159
+ ### REM 适配
160
+
161
+ 项目内置 REM 适配方案,自动根据屏幕尺寸调整字体大小,确保在不同设备上的显示效果一致。
162
+
163
+ ### 兼容性
164
+
165
+ - iOS >= 10
166
+ - Android >= 6
167
+ - Chrome >= 80
168
+
169
+ ## 🎨 样式规范
170
+
171
+ ### Less 预处理器
172
+
173
+ - 支持 Less 语法和功能
174
+ - 全局变量和 mixins 注入
175
+ - 集成 MagicLess 工具库
176
+
177
+ ### 样式组织
178
+
179
+ - 全局样式:`src/global.less`
180
+ - 组件样式:与组件文件同目录
181
+ - 变量文件:`src/assets/style/variable.less`
182
+
183
+ ## 📝 开发规范
184
+
185
+ ### 代码规范
186
+
187
+ - 遵循 ESLint 规则
188
+ - 使用 Prettier 进行代码格式化
189
+ - StyleLint 检查 CSS 代码质量
190
+
191
+ ### Git 提交规范
192
+
193
+ 项目使用 Conventional Commits 规范:
194
+
195
+ ```
196
+ <type>(<scope>): <subject>
197
+
198
+ [optional body]
199
+
200
+ [optional footer]
201
+ ```
202
+
203
+ 类型包括:
204
+
205
+ - `feat`: 新功能
206
+ - `fix`: 修复 bug
207
+ - `docs`: 文档更新
208
+ - `style`: 代码格式调整
209
+ - `refactor`: 代码重构
210
+ - `test`: 测试相关
211
+ - `chore`: 构建过程或辅助工具变动
212
+
213
+ ### 组件开发规范
214
+
215
+ - 组件名使用大驼峰命名
216
+ - 每个组件包含 `.vue`、`.less`、`index.ts` 文件
217
+ - 组件应具有良好的可复用性和可维护性
218
+
219
+ ## 🔧 常见问题
220
+
221
+ ### 1. 如何添加新页面?
222
+
223
+ 在 `src/pages/` 目录下创建新的 `.vue` 文件,路由会自动生成。
224
+
225
+ ### 2. 如何配置 API 地址?
226
+
227
+ 在 `.winrc.ts` 文件的 `appConfig` 部分配置不同环境的 API 地址。
228
+
229
+ ### 3. 如何添加全局样式?
230
+
231
+ 在 `src/global.less` 文件中添加全局样式,或在 `src/assets/style/` 目录下创建样式文件。
232
+
233
+ ### 4. 如何使用 SVG 图标?
234
+
235
+ 将 SVG 文件放在 `src/icons/` 目录下,通过配置自动生成图标组件。
236
+
237
+ ## 📚 相关文档
238
+
239
+ - [WinJS 官方文档](https://winjs-dev.github.io/winjs-docs/)
240
+ - [Vue 3 官方文档](https://vuejs.org/)
241
+ - [Vue Router 4 文档](https://router.vuejs.org/)
242
+ - [TypeScript 文档](https://www.typescriptlang.org/)
243
+
244
+ **注意**:本模板持续更新中,建议定期查看最新版本以获取新特性和修复。
@@ -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: true
6
+ };
@@ -0,0 +1,34 @@
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/plugin-wconsole": "^1.0.0",
28
+ "@winner-fed/f2elint": "^3.0.0",
29
+ "cross-env": "^7.0.3",
30
+ "husky": "8.0.3",
31
+ "lint-staged": "13.2.3",
32
+ "typescript": "^5.0.3"
33
+ }
34
+ }
@@ -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
+ };