├── .eslintignore ├── .eslintrc.js ├── .gitignore ├── .husky └── pre-commit ├── .prettierignore ├── .prettierrc.js ├── .vscode └── settings.json ├── LICENSE ├── README.md ├── index.html ├── package.json ├── pnpm-lock.yaml ├── src ├── App.vue ├── api │ └── index.ts ├── component │ └── readme.md ├── constants │ └── readme.md ├── env.d.ts ├── main.ts ├── manifest.json ├── pages.json ├── pages │ └── index │ │ └── index.vue ├── shime-uni.d.ts ├── static │ └── logo.png ├── types │ └── index.d.ts ├── uni.scss └── utils │ └── index.ts ├── tsconfig.json └── vite.config.ts /.eslintignore: -------------------------------------------------------------------------------- 1 | **/node_modules/* 2 | **/build/* 3 | **/dist/* 4 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | env: { 3 | browser: true, 4 | es2021: true, 5 | node: true 6 | }, 7 | extends: [ 8 | "eslint:recommended", 9 | "plugin:vue/vue3-essential", 10 | "plugin:@typescript-eslint/recommended", 11 | "plugin:prettier/recommended" 12 | ], 13 | overrides: [], 14 | parser: "vue-eslint-parser", 15 | parserOptions: { 16 | ecmaVersion: "latest", 17 | parser: "@typescript-eslint/parser", 18 | sourceType: "module" 19 | }, 20 | plugins: ["vue", "@typescript-eslint"], 21 | rules: { 22 | "vue/multi-word-component-names": "off" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | 9 | # Diagnostic reports (https://nodejs.org/api/report.html) 10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 11 | 12 | # Runtime data 13 | pids 14 | *.pid 15 | *.seed 16 | *.pid.lock 17 | 18 | # Directory for instrumented libs generated by jscoverage/JSCover 19 | lib-cov 20 | 21 | # Coverage directory used by tools like istanbul 22 | coverage 23 | *.lcov 24 | 25 | # nyc test coverage 26 | .nyc_output 27 | 28 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 29 | .grunt 30 | 31 | # Bower dependency directory (https://bower.io/) 32 | bower_components 33 | 34 | # node-waf configuration 35 | .lock-wscript 36 | 37 | # Compiled binary addons (https://nodejs.org/api/addons.html) 38 | build/Release 39 | 40 | # Dependency directories 41 | node_modules/ 42 | jspm_packages/ 43 | 44 | # TypeScript v1 declaration files 45 | typings/ 46 | 47 | # TypeScript cache 48 | *.tsbuildinfo 49 | 50 | # Optional npm cache directory 51 | .npm 52 | 53 | # Optional eslint cache 54 | .eslintcache 55 | 56 | # Microbundle cache 57 | .rpt2_cache/ 58 | .rts2_cache_cjs/ 59 | .rts2_cache_es/ 60 | .rts2_cache_umd/ 61 | 62 | # Optional REPL history 63 | .node_repl_history 64 | 65 | # Output of 'npm pack' 66 | *.tgz 67 | 68 | # Yarn Integrity file 69 | .yarn-integrity 70 | 71 | # dotenv environment variables file 72 | .env 73 | .env.test 74 | 75 | # parcel-bundler cache (https://parceljs.org/) 76 | .cache 77 | 78 | # Next.js build output 79 | .next 80 | 81 | # Nuxt.js build / generate output 82 | .nuxt 83 | dist 84 | 85 | # Gatsby files 86 | .cache/ 87 | # Comment in the public line in if your project uses Gatsby and *not* Next.js 88 | # https://nextjs.org/blog/next-9-1#public-directory-support 89 | # public 90 | 91 | # vuepress build output 92 | .vuepress/dist 93 | 94 | # Serverless directories 95 | .serverless/ 96 | 97 | # FuseBox cache 98 | .fusebox/ 99 | 100 | # DynamoDB Local files 101 | .dynamodb/ 102 | 103 | # TernJS port file 104 | .tern-port 105 | -------------------------------------------------------------------------------- /.husky/pre-commit: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | . "$(dirname -- "$0")/_/husky.sh" 3 | 4 | pnpm format 5 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | dist 2 | node_modules 3 | -------------------------------------------------------------------------------- /.prettierrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | // 一行的字符数,如果超过会进行换行,默认为80 3 | printWidth: 100, 4 | // 一个tab代表几个空格数,默认为2 5 | tabWidth: 2, 6 | // 是否使用tab进行缩进,默认为false,表示用空格进行缩减 7 | useTabs: false, 8 | // 字符串是否使用单引号,默认为false,使用双引号 9 | singleQuote: false, 10 | // 行位是否使用分号,默认为true 11 | semi: false, 12 | // 是否使用尾逗号,有三个可选值"" 13 | trailingComma: "none", 14 | // 对象大括号直接是否有空格,默认为true,效果:{ foo: bar } 15 | bracketSpacing: true 16 | } 17 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "typescript.tsdk": "node_modules/typescript/lib", 3 | "editor.codeActionsOnSave": { 4 | "source.fixAll": true, 5 | "source.fixAll.eslint": true 6 | }, 7 | // 保存的时候自动格式化 8 | "editor.formatOnSave": true, 9 | // 默认格式化工具选择prettier 10 | "editor.defaultFormatter": "esbenp.prettier-vscode" 11 | } 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 sabar 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # uniapp_vue3_demo 2 | 3 | 一个关于 uniapp+vue3+vite+typescript 架构模板 4 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "uni-preset-vue", 3 | "version": "0.0.0", 4 | "scripts": { 5 | "dev:app": "uni -p app", 6 | "dev:app-android": "uni -p app-android", 7 | "dev:app-ios": "uni -p app-ios", 8 | "dev:custom": "uni -p", 9 | "dev:h5": "uni", 10 | "dev:h5:ssr": "uni --ssr", 11 | "dev:mp-alipay": "uni -p mp-alipay", 12 | "dev:mp-baidu": "uni -p mp-baidu", 13 | "dev:mp-jd": "uni -p mp-jd", 14 | "dev:mp-kuaishou": "uni -p mp-kuaishou", 15 | "dev:mp-lark": "uni -p mp-lark", 16 | "dev:mp-qq": "uni -p mp-qq", 17 | "dev:mp-toutiao": "uni -p mp-toutiao", 18 | "dev:mp-weixin": "uni -p mp-weixin", 19 | "dev:quickapp-webview": "uni -p quickapp-webview", 20 | "dev:quickapp-webview-huawei": "uni -p quickapp-webview-huawei", 21 | "dev:quickapp-webview-union": "uni -p quickapp-webview-union", 22 | "build:app": "uni build -p app", 23 | "build:app-android": "uni build -p app-android", 24 | "build:app-ios": "uni build -p app-ios", 25 | "build:custom": "uni build -p", 26 | "build:h5": "uni build", 27 | "build:h5:ssr": "uni build --ssr", 28 | "build:mp-alipay": "uni build -p mp-alipay", 29 | "build:mp-baidu": "uni build -p mp-baidu", 30 | "build:mp-jd": "uni build -p mp-jd", 31 | "build:mp-kuaishou": "uni build -p mp-kuaishou", 32 | "build:mp-lark": "uni build -p mp-lark", 33 | "build:mp-qq": "uni build -p mp-qq", 34 | "build:mp-toutiao": "uni build -p mp-toutiao", 35 | "build:mp-weixin": "uni build -p mp-weixin", 36 | "build:quickapp-webview": "uni build -p quickapp-webview", 37 | "build:quickapp-webview-huawei": "uni build -p quickapp-webview-huawei", 38 | "build:quickapp-webview-union": "uni build -p quickapp-webview-union", 39 | "type-check": "vue-tsc --noEmit", 40 | "lint": "eslint . --ext .vue,.js,.ts,.jsx,.tsx --fix", 41 | "format": "prettier --write . && pnpm lint --fix", 42 | "postinstall": "husky install" 43 | }, 44 | "dependencies": { 45 | "@dcloudio/uni-app": "3.0.0-alpha-3070720230316001", 46 | "@dcloudio/uni-app-plus": "3.0.0-alpha-3070720230316001", 47 | "@dcloudio/uni-components": "3.0.0-alpha-3070720230316001", 48 | "@dcloudio/uni-h5": "3.0.0-alpha-3070720230316001", 49 | "@dcloudio/uni-mp-alipay": "3.0.0-alpha-3070720230316001", 50 | "@dcloudio/uni-mp-baidu": "3.0.0-alpha-3070720230316001", 51 | "@dcloudio/uni-mp-jd": "3.0.0-alpha-3070720230316001", 52 | "@dcloudio/uni-mp-kuaishou": "3.0.0-alpha-3070720230316001", 53 | "@dcloudio/uni-mp-lark": "3.0.0-alpha-3070720230316001", 54 | "@dcloudio/uni-mp-qq": "3.0.0-alpha-3070720230316001", 55 | "@dcloudio/uni-mp-toutiao": "3.0.0-alpha-3070720230316001", 56 | "@dcloudio/uni-mp-weixin": "3.0.0-alpha-3070720230316001", 57 | "@dcloudio/uni-quickapp-webview": "3.0.0-alpha-3070720230316001", 58 | "vue": "^3.2.45", 59 | "vue-i18n": "^9.1.9" 60 | }, 61 | "devDependencies": { 62 | "@dcloudio/types": "^3.3.2", 63 | "@dcloudio/uni-automator": "3.0.0-alpha-3070720230316001", 64 | "@dcloudio/uni-cli-shared": "3.0.0-alpha-3070720230316001", 65 | "@dcloudio/uni-stacktracey": "3.0.0-alpha-3070720230316001", 66 | "@dcloudio/vite-plugin-uni": "3.0.0-alpha-3070720230316001", 67 | "@typescript-eslint/eslint-plugin": "^5.57.1", 68 | "@typescript-eslint/parser": "^5.57.1", 69 | "@vue/tsconfig": "^0.1.3", 70 | "eslint": "^8.37.0", 71 | "eslint-config-prettier": "^8.8.0", 72 | "eslint-plugin-prettier": "^4.2.1", 73 | "eslint-plugin-vue": "^9.10.0", 74 | "husky": "^8.0.3", 75 | "prettier": "^2.8.7", 76 | "typescript": "^4.9.4", 77 | "vite": "4.0.4", 78 | "vue-tsc": "^1.0.24" 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/App.vue: -------------------------------------------------------------------------------- 1 | 13 | 14 | -------------------------------------------------------------------------------- /src/api/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qiu-tian01/uniapp_vue3_demo/ac5e5a07c432d2d2bafe07384a934fdd6f558651/src/api/index.ts -------------------------------------------------------------------------------- /src/component/readme.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qiu-tian01/uniapp_vue3_demo/ac5e5a07c432d2d2bafe07384a934fdd6f558651/src/component/readme.md -------------------------------------------------------------------------------- /src/constants/readme.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qiu-tian01/uniapp_vue3_demo/ac5e5a07c432d2d2bafe07384a934fdd6f558651/src/constants/readme.md -------------------------------------------------------------------------------- /src/env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | declare module "*.vue" { 4 | import { DefineComponent } from "vue" 5 | // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types 6 | const component: DefineComponent<{}, {}, any> 7 | export default component 8 | } 9 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import { createSSRApp } from "vue" 2 | import App from "./App.vue" 3 | export function createApp() { 4 | const app = createSSRApp(App) 5 | return { 6 | app 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /src/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "", 3 | "appid": "", 4 | "description": "", 5 | "versionName": "1.0.0", 6 | "versionCode": "100", 7 | "transformPx": false, 8 | /* 5+App特有相关 */ 9 | "app-plus": { 10 | "usingComponents": true, 11 | "nvueStyleCompiler": "uni-app", 12 | "compilerVersion": 3, 13 | "splashscreen": { 14 | "alwaysShowBeforeRender": true, 15 | "waiting": true, 16 | "autoclose": true, 17 | "delay": 0 18 | }, 19 | /* 模块配置 */ 20 | "modules": {}, 21 | /* 应用发布信息 */ 22 | "distribute": { 23 | /* android打包配置 */ 24 | "android": { 25 | "permissions": [ 26 | "", 27 | "", 28 | "", 29 | "", 30 | "", 31 | "", 32 | "", 33 | "", 34 | "", 35 | "", 36 | "", 37 | "", 38 | "", 39 | "", 40 | "" 41 | ] 42 | }, 43 | /* ios打包配置 */ 44 | "ios": {}, 45 | /* SDK配置 */ 46 | "sdkConfigs": {} 47 | } 48 | }, 49 | /* 快应用特有相关 */ 50 | "quickapp": {}, 51 | /* 小程序特有相关 */ 52 | "mp-weixin": { 53 | "appid": "", 54 | "setting": { 55 | "urlCheck": false 56 | }, 57 | "usingComponents": true 58 | }, 59 | "mp-alipay": { 60 | "usingComponents": true 61 | }, 62 | "mp-baidu": { 63 | "usingComponents": true 64 | }, 65 | "mp-toutiao": { 66 | "usingComponents": true 67 | }, 68 | "uniStatistics": { 69 | "enable": false 70 | }, 71 | "vueVersion": "3" 72 | } 73 | -------------------------------------------------------------------------------- /src/pages.json: -------------------------------------------------------------------------------- 1 | { 2 | "pages": [ 3 | //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages 4 | { 5 | "path": "pages/index/index", 6 | "style": { 7 | "navigationBarTitleText": "uni-app" 8 | } 9 | } 10 | ], 11 | "globalStyle": { 12 | "navigationBarTextStyle": "black", 13 | "navigationBarTitleText": "uni-app", 14 | "navigationBarBackgroundColor": "#F8F8F8", 15 | "backgroundColor": "#F8F8F8" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/pages/index/index.vue: -------------------------------------------------------------------------------- 1 | 9 | 10 | 14 | 15 | 42 | -------------------------------------------------------------------------------- /src/shime-uni.d.ts: -------------------------------------------------------------------------------- 1 | export {} 2 | 3 | declare module "vue" { 4 | type Hooks = App.AppInstance & Page.PageInstance 5 | type ComponentCustomOptions = Hooks 6 | } 7 | -------------------------------------------------------------------------------- /src/static/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qiu-tian01/uniapp_vue3_demo/ac5e5a07c432d2d2bafe07384a934fdd6f558651/src/static/logo.png -------------------------------------------------------------------------------- /src/types/index.d.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qiu-tian01/uniapp_vue3_demo/ac5e5a07c432d2d2bafe07384a934fdd6f558651/src/types/index.d.ts -------------------------------------------------------------------------------- /src/uni.scss: -------------------------------------------------------------------------------- 1 | /** 2 | * 这里是uni-app内置的常用样式变量 3 | * 4 | * uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量 5 | * 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App 6 | * 7 | */ 8 | 9 | /** 10 | * 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能 11 | * 12 | * 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件 13 | */ 14 | 15 | /* 颜色变量 */ 16 | 17 | /* 行为相关颜色 */ 18 | $uni-color-primary: #007aff; 19 | $uni-color-success: #4cd964; 20 | $uni-color-warning: #f0ad4e; 21 | $uni-color-error: #dd524d; 22 | 23 | /* 文字基本颜色 */ 24 | $uni-text-color: #333; // 基本色 25 | $uni-text-color-inverse: #fff; // 反色 26 | $uni-text-color-grey: #999; // 辅助灰色,如加载更多的提示信息 27 | $uni-text-color-placeholder: #808080; 28 | $uni-text-color-disable: #c0c0c0; 29 | 30 | /* 背景颜色 */ 31 | $uni-bg-color: #fff; 32 | $uni-bg-color-grey: #f8f8f8; 33 | $uni-bg-color-hover: #f1f1f1; // 点击状态颜色 34 | $uni-bg-color-mask: rgba(0, 0, 0, 0.4); // 遮罩颜色 35 | 36 | /* 边框颜色 */ 37 | $uni-border-color: #c8c7cc; 38 | 39 | /* 尺寸变量 */ 40 | 41 | /* 文字尺寸 */ 42 | $uni-font-size-sm: 12px; 43 | $uni-font-size-base: 14px; 44 | $uni-font-size-lg: 16; 45 | 46 | /* 图片尺寸 */ 47 | $uni-img-size-sm: 20px; 48 | $uni-img-size-base: 26px; 49 | $uni-img-size-lg: 40px; 50 | 51 | /* Border Radius */ 52 | $uni-border-radius-sm: 2px; 53 | $uni-border-radius-base: 3px; 54 | $uni-border-radius-lg: 6px; 55 | $uni-border-radius-circle: 50%; 56 | 57 | /* 水平间距 */ 58 | $uni-spacing-row-sm: 5px; 59 | $uni-spacing-row-base: 10px; 60 | $uni-spacing-row-lg: 15px; 61 | 62 | /* 垂直间距 */ 63 | $uni-spacing-col-sm: 4px; 64 | $uni-spacing-col-base: 8px; 65 | $uni-spacing-col-lg: 12px; 66 | 67 | /* 透明度 */ 68 | $uni-opacity-disabled: 0.3; // 组件禁用态的透明度 69 | 70 | /* 文章场景相关 */ 71 | $uni-color-title: #2c405a; // 文章标题颜色 72 | $uni-font-size-title: 20px; 73 | $uni-color-subtitle: #555; // 二级标题颜色 74 | $uni-font-size-subtitle: 18px; 75 | $uni-color-paragraph: #3f536e; // 文章段落颜色 76 | $uni-font-size-paragraph: 15px; 77 | -------------------------------------------------------------------------------- /src/utils/index.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qiu-tian01/uniapp_vue3_demo/ac5e5a07c432d2d2bafe07384a934fdd6f558651/src/utils/index.ts -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@vue/tsconfig/tsconfig.json", 3 | "compilerOptions": { 4 | "sourceMap": true, 5 | "baseUrl": ".", 6 | "paths": { 7 | "@/*": ["./src/*"] 8 | }, 9 | "lib": ["esnext", "dom"], 10 | "types": ["@dcloudio/types"] 11 | }, 12 | "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"] 13 | } 14 | -------------------------------------------------------------------------------- /vite.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from "vite" 2 | import uni from "@dcloudio/vite-plugin-uni" 3 | 4 | // https://vitejs.dev/config/ 5 | export default defineConfig({ 6 | plugins: [uni()] 7 | }) 8 | --------------------------------------------------------------------------------