diff --git a/.eslintrc.cjs b/.eslintrc.cjs new file mode 100644 index 0000000..a8d4a47 --- /dev/null +++ b/.eslintrc.cjs @@ -0,0 +1,38 @@ +/* eslint-env node */ +require('@rushstack/eslint-patch/modern-module-resolution') + +module.exports = { + root: true, + extends: [ + 'plugin:vue/vue3-essential', + 'eslint:recommended', + '@vue/eslint-config-typescript', + '@vue/eslint-config-prettier', + ], + // 小程序全局变量 + globals: { + uni: true, + wx: true, + WechatMiniprogram: true, + getCurrentPages: true, + }, + parserOptions: { + ecmaVersion: 'latest', + }, + rules: { + 'prettier/prettier': [ + 'warn', + { + singleQuote: true, + semi: false, + printWidth: 80, + trailingComma: 'all', + endOfLine: 'auto', + }, + ], + 'vue/multi-word-component-names': ['off'], + 'vue/no-setup-props-destructure': ['off'], + 'vue/no-deprecated-html-element-is': ['off'], + '@typescript-eslint/no-unused-vars': ['off'], + }, +} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..62500e0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +.DS_Store +*.local diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100644 index 0000000..a5a29d9 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +pnpm lint-staged diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..25fb32d --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,7 @@ +{ + "singleQuote": true, + "semi": false, + "printWidth": 80, + "trailingComma": "all", + "endOfLine": "auto" +} diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..919f4d0 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,12 @@ +{ + // 推荐的扩展插件 + "recommendations": [ + "mrmaoddxxaa.create-uniapp-view", // 创建 uni-app 页面 + "uni-helper.uni-helper-vscode", // uni-app 代码提示 + "evils.uniapp-vscode", // uni-app 文档 + "vue.volar", // vue3 语法支持 + "vue.vscode-typescript-vue-plugin", // vue3 ts 插件 + "dbaeumer.vscode-eslint", // eslint + "esbenp.prettier-vscode" // prettier + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..8f8688f --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,13 @@ +{ + // 在保存时格式化文件 + "editor.formatOnSave": true, + // 文件格式化配置 + "[json]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + // 配置语言的文件关联 + "files.associations": { + "pages.json": "jsonc", // pages.json 可以写注释 + "manifest.json": "jsonc" // manifest.json 可以写注释 + } +} diff --git a/index.html b/index.html new file mode 100644 index 0000000..b2860a9 --- /dev/null +++ b/index.html @@ -0,0 +1,25 @@ + + + + + + + + + + + + +
+ +
+ + + + diff --git a/package.json b/package.json new file mode 100644 index 0000000..eff3388 --- /dev/null +++ b/package.json @@ -0,0 +1,85 @@ +{ + "name": "uni-app-xiaotuxian", + "version": "0.0.0", + "scripts": { + "dev:app": "uni -p app", + "dev:app-android": "uni -p app-android", + "dev:app-ios": "uni -p app-ios", + "dev:custom": "uni -p", + "dev:h5": "uni", + "dev:h5:ssr": "uni --ssr", + "dev:mp-alipay": "uni -p mp-alipay", + "dev:mp-baidu": "uni -p mp-baidu", + "dev:mp-kuaishou": "uni -p mp-kuaishou", + "dev:mp-lark": "uni -p mp-lark", + "dev:mp-qq": "uni -p mp-qq", + "dev:mp-toutiao": "uni -p mp-toutiao", + "dev:mp-weixin": "uni -p mp-weixin", + "dev:quickapp-webview": "uni -p quickapp-webview", + "dev:quickapp-webview-huawei": "uni -p quickapp-webview-huawei", + "dev:quickapp-webview-union": "uni -p quickapp-webview-union", + "build:app": "uni build -p app", + "build:app-android": "uni build -p app-android", + "build:app-ios": "uni build -p app-ios", + "build:custom": "uni build -p", + "build:h5": "uni build", + "build:h5:ssr": "uni build --ssr", + "build:mp-alipay": "uni build -p mp-alipay", + "build:mp-baidu": "uni build -p mp-baidu", + "build:mp-kuaishou": "uni build -p mp-kuaishou", + "build:mp-lark": "uni build -p mp-lark", + "build:mp-qq": "uni build -p mp-qq", + "build:mp-toutiao": "uni build -p mp-toutiao", + "build:mp-weixin": "uni build -p mp-weixin", + "build:quickapp-webview": "uni build -p quickapp-webview", + "build:quickapp-webview-huawei": "uni build -p quickapp-webview-huawei", + "build:quickapp-webview-union": "uni build -p quickapp-webview-union", + "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore", + "prepare": "husky install", + "lint-staged": "lint-staged" + }, + "lint-staged": { + "*.{js,ts,vue}": [ + "eslint --fix" + ] + }, + "dependencies": { + "@dcloudio/uni-app": "3.0.0-alpha-3061020221121002", + "@dcloudio/uni-app-plus": "3.0.0-alpha-3061020221121002", + "@dcloudio/uni-components": "3.0.0-alpha-3061020221121002", + "@dcloudio/uni-h5": "3.0.0-alpha-3061020221121002", + "@dcloudio/uni-mp-alipay": "3.0.0-alpha-3061020221121002", + "@dcloudio/uni-mp-baidu": "3.0.0-alpha-3061020221121002", + "@dcloudio/uni-mp-kuaishou": "3.0.0-alpha-3061020221121002", + "@dcloudio/uni-mp-lark": "3.0.0-alpha-3061020221121002", + "@dcloudio/uni-mp-qq": "3.0.0-alpha-3061020221121002", + "@dcloudio/uni-mp-toutiao": "3.0.0-alpha-3061020221121002", + "@dcloudio/uni-mp-weixin": "3.0.0-alpha-3061020221121002", + "@dcloudio/uni-quickapp-webview": "3.0.0-alpha-3061020221121002", + "vue": "^3.2.41", + "vue-i18n": "^9.1.9" + }, + "devDependencies": { + "@dcloudio/types": "^3.0.16", + "@dcloudio/uni-automator": "3.0.0-alpha-3061020221121002", + "@dcloudio/uni-cli-shared": "3.0.0-alpha-3061020221121002", + "@dcloudio/uni-stacktracey": "3.0.0-alpha-3061020221121002", + "@dcloudio/vite-plugin-uni": "3.0.0-alpha-3061020221121002", + "@rushstack/eslint-patch": "^1.1.4", + "@types/node": "^18.11.9", + "@types/wechat-miniprogram": "^3.4.1", + "@uni-helper/uni-app-types": "^0.1.8", + "@vitejs/plugin-vue": "^3.0.3", + "@vue/eslint-config-prettier": "^7.0.0", + "@vue/eslint-config-typescript": "^11.0.0", + "@vue/tsconfig": "^0.1.3", + "eslint": "^8.22.0", + "eslint-plugin-vue": "^9.3.0", + "husky": "^8.0.0", + "lint-staged": "^13.0.3", + "prettier": "^2.7.1", + "sass": "^1.56.1", + "typescript": "^4.9.3", + "vite": "^3.1.8" + } +} diff --git a/src/App.vue b/src/App.vue new file mode 100644 index 0000000..5178ede --- /dev/null +++ b/src/App.vue @@ -0,0 +1,51 @@ + + + diff --git a/src/env.d.ts b/src/env.d.ts new file mode 100644 index 0000000..d27eb5a --- /dev/null +++ b/src/env.d.ts @@ -0,0 +1,8 @@ +/// + +declare module '*.vue' { + import { DefineComponent } from 'vue' + // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types + const component: DefineComponent<{}, {}, any> + export default component +} diff --git a/src/main.ts b/src/main.ts new file mode 100644 index 0000000..4b5dc40 --- /dev/null +++ b/src/main.ts @@ -0,0 +1,10 @@ +import { createSSRApp } from 'vue' + +import App from './App.vue' +export function createApp() { + const app = createSSRApp(App) + + return { + app, + } +} diff --git a/src/manifest.json b/src/manifest.json new file mode 100644 index 0000000..230fd95 --- /dev/null +++ b/src/manifest.json @@ -0,0 +1,72 @@ +{ + "name": "uni-app-xiaotuxian", + "appid": "", + "description": "", + "versionName": "1.0.0", + "versionCode": "100", + "transformPx": false, + /* 5+App特有相关 */ + "app-plus": { + "usingComponents": true, + "nvueStyleCompiler": "uni-app", + "compilerVersion": 3, + "splashscreen": { + "alwaysShowBeforeRender": true, + "waiting": true, + "autoclose": true, + "delay": 0 + }, + /* 模块配置 */ + "modules": {}, + /* 应用发布信息 */ + "distribute": { + /* android打包配置 */ + "android": { + "permissions": [ + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "" + ] + }, + /* ios打包配置 */ + "ios": {}, + /* SDK配置 */ + "sdkConfigs": {} + } + }, + /* 快应用特有相关 */ + "quickapp": {}, + /* 小程序特有相关 */ + "mp-weixin": { + "appid": "", + "setting": { + "urlCheck": false + }, + "usingComponents": true + }, + "mp-alipay": { + "usingComponents": true + }, + "mp-baidu": { + "usingComponents": true + }, + "mp-toutiao": { + "usingComponents": true + }, + "uniStatistics": { + "enable": false + }, + "vueVersion": "3" +} diff --git a/src/pages.json b/src/pages.json new file mode 100644 index 0000000..40c6652 --- /dev/null +++ b/src/pages.json @@ -0,0 +1,68 @@ +{ + "pages": [ + //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages + { + "path": "pages/index/index", + "style": { + "navigationBarTitleText": "首页" + } + }, + { + "path": "pages/my/my", + "style": { + "navigationBarTitleText": "我的" + } + }, + { + "path": "pages/cart/cart", + "style": { + "navigationBarTitleText": "购物车" + } + }, + { + "path": "pages/category/category", + "style": { + "navigationBarTitleText": "分类" + } + } + ], + "globalStyle": { + "navigationBarTextStyle": "black", + "navigationBarTitleText": "", + "navigationBarBackgroundColor": "#F8F8F8", + "backgroundColor": "#F8F8F8" + }, + // 设置 TabBar + "tabBar": { + "color": "#333", + "selectedColor": "#27ba9b", + "backgroundColor": "#fff", + "borderStyle": "white", + "list": [ + { + "text": "首页", + "pagePath": "pages/index/index", + "iconPath": "static/tabs/home_default.png", + "selectedIconPath": "static/tabs/home_selected.png" + }, + { + "text": "分类", + "pagePath": "pages/category/category", + "iconPath": "static/tabs/category_default.png", + "selectedIconPath": "static/tabs/category_selected.png" + }, + { + "text": "购物车", + "pagePath": "pages/cart/cart", + "iconPath": "static/tabs/cart_default.png", + "selectedIconPath": "static/tabs/cart_selected.png" + }, + { + "text": "我的", + "pagePath": "pages/my/my", + "iconPath": "static/tabs/user_default.png", + "selectedIconPath": "static/tabs/user_selected.png" + } + ] + } +} diff --git a/src/pages/cart/cart.vue b/src/pages/cart/cart.vue new file mode 100644 index 0000000..34d937d --- /dev/null +++ b/src/pages/cart/cart.vue @@ -0,0 +1,3 @@ + diff --git a/src/pages/category/category.vue b/src/pages/category/category.vue new file mode 100644 index 0000000..9f517c5 --- /dev/null +++ b/src/pages/category/category.vue @@ -0,0 +1,3 @@ + diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue new file mode 100644 index 0000000..556cdb6 --- /dev/null +++ b/src/pages/index/index.vue @@ -0,0 +1,3 @@ + diff --git a/src/pages/my/my.vue b/src/pages/my/my.vue new file mode 100644 index 0000000..7733742 --- /dev/null +++ b/src/pages/my/my.vue @@ -0,0 +1,3 @@ + diff --git a/src/static/images/blank.png b/src/static/images/blank.png new file mode 100644 index 0000000..a74df51 Binary files /dev/null and b/src/static/images/blank.png differ diff --git a/src/static/images/bubble.png b/src/static/images/bubble.png new file mode 100644 index 0000000..0fb55de Binary files /dev/null and b/src/static/images/bubble.png differ diff --git a/src/static/images/car.png b/src/static/images/car.png new file mode 100644 index 0000000..d60f23f Binary files /dev/null and b/src/static/images/car.png differ diff --git a/src/static/images/center_bg.png b/src/static/images/center_bg.png new file mode 100644 index 0000000..7b1acba Binary files /dev/null and b/src/static/images/center_bg.png differ diff --git a/src/static/images/locate.png b/src/static/images/locate.png new file mode 100644 index 0000000..03c67b1 Binary files /dev/null and b/src/static/images/locate.png differ diff --git a/src/static/images/logo.png b/src/static/images/logo.png new file mode 100644 index 0000000..447c3c5 Binary files /dev/null and b/src/static/images/logo.png differ diff --git a/src/static/images/logo_icon.png b/src/static/images/logo_icon.png new file mode 100644 index 0000000..a2768eb Binary files /dev/null and b/src/static/images/logo_icon.png differ diff --git a/src/static/images/navigator_bg.png b/src/static/images/navigator_bg.png new file mode 100644 index 0000000..32d0491 Binary files /dev/null and b/src/static/images/navigator_bg.png differ diff --git a/src/static/images/order_bg.png b/src/static/images/order_bg.png new file mode 100644 index 0000000..cc8ee57 Binary files /dev/null and b/src/static/images/order_bg.png differ diff --git a/src/static/images/rating_off.png b/src/static/images/rating_off.png new file mode 100644 index 0000000..284574b Binary files /dev/null and b/src/static/images/rating_off.png differ diff --git a/src/static/images/rating_on.png b/src/static/images/rating_on.png new file mode 100644 index 0000000..9c46cd5 Binary files /dev/null and b/src/static/images/rating_on.png differ diff --git a/src/static/images/remove.png b/src/static/images/remove.png new file mode 100644 index 0000000..97b35e3 Binary files /dev/null and b/src/static/images/remove.png differ diff --git a/src/static/images/stars.png b/src/static/images/stars.png new file mode 100644 index 0000000..0d06be1 Binary files /dev/null and b/src/static/images/stars.png differ diff --git a/src/static/tabs/cart_default.png b/src/static/tabs/cart_default.png new file mode 100644 index 0000000..22b466f Binary files /dev/null and b/src/static/tabs/cart_default.png differ diff --git a/src/static/tabs/cart_selected.png b/src/static/tabs/cart_selected.png new file mode 100644 index 0000000..5949eb4 Binary files /dev/null and b/src/static/tabs/cart_selected.png differ diff --git a/src/static/tabs/category_default.png b/src/static/tabs/category_default.png new file mode 100644 index 0000000..9e1bfdf Binary files /dev/null and b/src/static/tabs/category_default.png differ diff --git a/src/static/tabs/category_selected.png b/src/static/tabs/category_selected.png new file mode 100644 index 0000000..2f32af1 Binary files /dev/null and b/src/static/tabs/category_selected.png differ diff --git a/src/static/tabs/home_default.png b/src/static/tabs/home_default.png new file mode 100644 index 0000000..f2d8046 Binary files /dev/null and b/src/static/tabs/home_default.png differ diff --git a/src/static/tabs/home_selected.png b/src/static/tabs/home_selected.png new file mode 100644 index 0000000..82e787b Binary files /dev/null and b/src/static/tabs/home_selected.png differ diff --git a/src/static/tabs/user_default.png b/src/static/tabs/user_default.png new file mode 100644 index 0000000..c0f529e Binary files /dev/null and b/src/static/tabs/user_default.png differ diff --git a/src/static/tabs/user_selected.png b/src/static/tabs/user_selected.png new file mode 100644 index 0000000..d49a802 Binary files /dev/null and b/src/static/tabs/user_selected.png differ diff --git a/src/styles/fonts.scss b/src/styles/fonts.scss new file mode 100644 index 0000000..1268b24 --- /dev/null +++ b/src/styles/fonts.scss @@ -0,0 +1,140 @@ +@font-face {font-family: "erabbit"; + src: url('https://at.alicdn.com/t/font_2232762_u2xb7up9h5.woff?t=1614588039709') format('woff'), + url('https://at.alicdn.com/t/font_2232762_u2xb7up9h5.ttf?t=1614588039709') format('truetype'), /* chrome, firefox, opera, Safari, Android, iOS 4.2+ */ + url('https://at.alicdn.com/t/font_2232762_u2xb7up9h5.svg?t=1614588039709#erabbit') format('svg'); /* iOS 4.1- */ +} + +[class^="icon-"], [class*=" icon-"] { + font-family: "erabbit" !important; + font-style: normal; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +.icon-mail:before { + content: "\e644"; +} + +.icon-weixin:before { + content: "\e620"; +} + +.icon-phone:before { + content: "\e618"; +} + +.icon-camera-plus:before { + content: "\e636"; +} + +.icon-close:before { + content: "\e6e1"; +} + +.icon-help:before { + content: "\e617"; +} + +.icon-cart:before { + content: "\e6d1"; +} + +.icon-settings:before { + content: "\e6cf"; +} + +.icon-clock:before { + content: "\e609"; +} + +.icon-delete:before { + content: "\e6ce"; +} + +.icon-checked:before { + content: "\e6cc"; +} + +.icon-ring:before { + content: "\e6cd"; +} + +.icon-locate:before { + content: "\e6cb"; +} + +.icon-mark:before { + content: "\e6ca"; +} + +.icon-check:before { + content: "\e6c9"; +} + +.icon-handset:before { + content: "\e6c8"; +} + +.icon-gift:before { + content: "\e6c7"; +} + +.icon-currency:before { + content: "\e6c6"; +} + +.icon-comment:before { + content: "\e6c5"; +} + +.icon-caret:before { + content: "\e6c3"; +} + +.icon-right:before { + content: "\e6c2"; +} + +.icon-left:before { + content: "\e6c1"; +} + +.icon-down:before { + content: "\e6c0"; +} + +.icon-up:before { + content: "\e6bf"; +} + +.icon-sort:before { + content: "\e616"; +} + +.icon-clear:before { + content: "\e6be"; +} + +.icon-user:before { + content: "\e6bb"; +} + +.icon-scan:before { + content: "\e6bc"; +} + +.icon-search:before { + content: "\e632"; +} + +.icon-preview:before { + content: "\e61d"; +} + +.icon-heart:before { + content: "\e647"; +} + +.icon-filter:before { + content: "\e629"; +} diff --git a/src/uni.scss b/src/uni.scss new file mode 100644 index 0000000..d055110 --- /dev/null +++ b/src/uni.scss @@ -0,0 +1,76 @@ +/** + * 这里是uni-app内置的常用样式变量 + * + * uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量 + * 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App + * + */ + +/** + * 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能 + * + * 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件 + */ + +/* 颜色变量 */ + +/* 行为相关颜色 */ +$uni-color-primary: #007aff; +$uni-color-success: #4cd964; +$uni-color-warning: #f0ad4e; +$uni-color-error: #dd524d; + +/* 文字基本颜色 */ +$uni-text-color: #333; // 基本色 +$uni-text-color-inverse: #fff; // 反色 +$uni-text-color-grey: #999; // 辅助灰色,如加载更多的提示信息 +$uni-text-color-placeholder: #808080; +$uni-text-color-disable: #c0c0c0; + +/* 背景颜色 */ +$uni-bg-color: #fff; +$uni-bg-color-grey: #f8f8f8; +$uni-bg-color-hover: #f1f1f1; // 点击状态颜色 +$uni-bg-color-mask: rgba(0, 0, 0, 0.4); // 遮罩颜色 + +/* 边框颜色 */ +$uni-border-color: #c8c7cc; + +/* 尺寸变量 */ + +/* 文字尺寸 */ +$uni-font-size-sm: 12px; +$uni-font-size-base: 14px; +$uni-font-size-lg: 16; + +/* 图片尺寸 */ +$uni-img-size-sm: 20px; +$uni-img-size-base: 26px; +$uni-img-size-lg: 40px; + +/* Border Radius */ +$uni-border-radius-sm: 2px; +$uni-border-radius-base: 3px; +$uni-border-radius-lg: 6px; +$uni-border-radius-circle: 50%; + +/* 水平间距 */ +$uni-spacing-row-sm: 5px; +$uni-spacing-row-base: 10px; +$uni-spacing-row-lg: 15px; + +/* 垂直间距 */ +$uni-spacing-col-sm: 4px; +$uni-spacing-col-base: 8px; +$uni-spacing-col-lg: 12px; + +/* 透明度 */ +$uni-opacity-disabled: 0.3; // 组件禁用态的透明度 + +/* 文章场景相关 */ +$uni-color-title: #2c405a; // 文章标题颜色 +$uni-font-size-title: 20px; +$uni-color-subtitle: #555; // 二级标题颜色 +$uni-font-size-subtitle: 18px; +$uni-color-paragraph: #3f536e; // 文章段落颜色 +$uni-font-size-paragraph: 15px; diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..dd7128c --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,27 @@ +{ + "compilerOptions": { + "target": "esnext", + "useDefineForClassFields": true, + "module": "esnext", + "moduleResolution": "node", + "strict": true, + "jsx": "preserve", + "sourceMap": true, + "resolveJsonModule": true, + "esModuleInterop": true, + "lib": ["esnext", "dom"], + "types": [ + "@dcloudio/types", + "@types/wechat-miniprogram", + "@uni-helper/uni-app-types" + ], + "baseUrl": ".", + "paths": { + "@/*": ["src/*"] + } + }, + "vueCompilerOptions": { + "experimentalRuntimeMode": "runtime-uni-app" + }, + "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"] +} diff --git a/vite.config.ts b/vite.config.ts new file mode 100644 index 0000000..c369889 --- /dev/null +++ b/vite.config.ts @@ -0,0 +1,11 @@ +import { defineConfig } from 'vite' +import uni from '@dcloudio/vite-plugin-uni' + +// https://vitejs.dev/config/ +export default defineConfig({ + build: { + // 开发阶段启用源码映射:https://uniapp.dcloud.net.cn/tutorial/migration-to-vue3.html#需主动开启-sourcemap + sourcemap: process.env.NODE_ENV === 'development', + }, + plugins: [uni()], +})