Kaynağa Gözat

初始化项目

黎海 1 ay önce
işleme
16c50a7d37

+ 10 - 0
babel.config.js

@@ -0,0 +1,10 @@
1
+// babel-preset-taro 更多选项和默认值:
2
+// https://github.com/NervJS/taro/blob/next/packages/babel-preset-taro/README.md
3
+module.exports = {
4
+  presets: [
5
+    ['taro', {
6
+      framework: 'react',
7
+      ts: false
8
+    }]
9
+  ]
10
+}

+ 9 - 0
config/dev.js

@@ -0,0 +1,9 @@
1
+module.exports = {
2
+  env: {
3
+    NODE_ENV: '"development"'
4
+  },
5
+  defineConstants: {
6
+  },
7
+  mini: {},
8
+  h5: {}
9
+}

+ 79 - 0
config/index.js

@@ -0,0 +1,79 @@
1
+const config = {
2
+  projectName: 'fish_app',
3
+  date: '2024-11-13',
4
+  designWidth: 750,
5
+  deviceRatio: {
6
+    640: 2.34 / 2,
7
+    750: 1,
8
+    828: 1.81 / 2
9
+  },
10
+  sourceRoot: 'src',
11
+  outputRoot: 'dist',
12
+  plugins: [],
13
+  defineConstants: {
14
+  },
15
+  copy: {
16
+    patterns: [
17
+    ],
18
+    options: {
19
+    }
20
+  },
21
+  framework: 'react',
22
+  compiler: 'webpack4',
23
+  mini: {
24
+    postcss: {
25
+      pxtransform: {
26
+        enable: true,
27
+        config: {
28
+
29
+        }
30
+      },
31
+      url: {
32
+        enable: true,
33
+        config: {
34
+          limit: 1024 // 设定转换尺寸上限
35
+        }
36
+      },
37
+      cssModules: {
38
+        enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
39
+        config: {
40
+          namingPattern: 'module', // 转换模式,取值为 global/module
41
+          generateScopedName: '[name]__[local]___[hash:base64:5]'
42
+        }
43
+      }
44
+    }
45
+  },
46
+  h5: {
47
+    publicPath: '/',
48
+    staticDirectory: 'static',
49
+    postcss: {
50
+      autoprefixer: {
51
+        enable: true,
52
+        config: {
53
+        }
54
+      },
55
+      cssModules: {
56
+        enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
57
+        config: {
58
+          namingPattern: 'module', // 转换模式,取值为 global/module
59
+          generateScopedName: '[name]__[local]___[hash:base64:5]'
60
+        }
61
+      }
62
+    }
63
+  },
64
+  rn: {
65
+    appName: 'taroDemo',
66
+    postcss: {
67
+      cssModules: {
68
+        enable: false, // 默认为 false,如需使用 css modules 功能,则设为 true
69
+      }
70
+    }
71
+  }
72
+}
73
+
74
+module.exports = function (merge) {
75
+  if (process.env.NODE_ENV === 'development') {
76
+    return merge({}, config, require('./dev'))
77
+  }
78
+  return merge({}, config, require('./prod'))
79
+}

+ 37 - 0
config/prod.js

@@ -0,0 +1,37 @@
1
+module.exports = {
2
+  env: {
3
+    NODE_ENV: '"production"'
4
+  },
5
+  defineConstants: {
6
+  },
7
+  mini: {},
8
+  h5: {
9
+    /**
10
+     * WebpackChain 插件配置
11
+     * @docs https://github.com/neutrinojs/webpack-chain
12
+     */
13
+    // webpackChain (chain) {
14
+    //   /**
15
+    //    * 如果 h5 端编译后体积过大,可以使用 webpack-bundle-analyzer 插件对打包体积进行分析。
16
+    //    * @docs https://github.com/webpack-contrib/webpack-bundle-analyzer
17
+    //    */
18
+    //   chain.plugin('analyzer')
19
+    //     .use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin, [])
20
+
21
+    //   /**
22
+    //    * 如果 h5 端首屏加载时间过长,可以使用 prerender-spa-plugin 插件预加载首页。
23
+    //    * @docs https://github.com/chrisvfritz/prerender-spa-plugin
24
+    //    */
25
+    //   const path = require('path')
26
+    //   const Prerender = require('prerender-spa-plugin')
27
+    //   const staticDir = path.join(__dirname, '..', 'dist')
28
+    //   chain
29
+    //     .plugin('prerender')
30
+    //     .use(new Prerender({
31
+    //       staticDir,
32
+    //       routes: [ '/pages/index/index' ],
33
+    //       postProcess: (context) => ({ ...context, outputPath: path.join(staticDir, 'index.html') })
34
+    //     }))
35
+    // }
36
+  }
37
+}

+ 76 - 0
package.json

@@ -0,0 +1,76 @@
1
+{
2
+  "name": "fish_app",
3
+  "version": "1.0.0",
4
+  "private": true,
5
+  "description": "yushi",
6
+  "templateInfo": {
7
+    "name": "default",
8
+    "typescript": false,
9
+    "css": "less"
10
+  },
11
+  "scripts": {
12
+    "build:weapp": "taro build --type weapp",
13
+    "build:swan": "taro build --type swan",
14
+    "build:alipay": "taro build --type alipay",
15
+    "build:tt": "taro build --type tt",
16
+    "build:h5": "taro build --type h5",
17
+    "build:rn": "taro build --type rn",
18
+    "build:qq": "taro build --type qq",
19
+    "build:jd": "taro build --type jd",
20
+    "build:quickapp": "taro build --type quickapp",
21
+    "dev:weapp": "npm run build:weapp -- --watch",
22
+    "dev:swan": "npm run build:swan -- --watch",
23
+    "dev:alipay": "npm run build:alipay -- --watch",
24
+    "dev:tt": "npm run build:tt -- --watch",
25
+    "dev:h5": "npm run build:h5 -- --watch",
26
+    "dev:rn": "npm run build:rn -- --watch",
27
+    "dev:qq": "npm run build:qq -- --watch",
28
+    "dev:jd": "npm run build:jd -- --watch",
29
+    "dev:quickapp": "npm run build:quickapp -- --watch"
30
+  },
31
+  "browserslist": [
32
+    "last 3 versions",
33
+    "Android >= 4.1",
34
+    "ios >= 8"
35
+  ],
36
+  "author": "",
37
+  "dependencies": {
38
+    "@babel/runtime": "^7.7.7",
39
+    "@tarojs/components": "3.5.7",
40
+    "@tarojs/helper": "3.5.7",
41
+    "@tarojs/plugin-framework-react": "3.5.7",
42
+    "@tarojs/plugin-platform-alipay": "3.5.7",
43
+    "@tarojs/plugin-platform-jd": "3.5.7",
44
+    "@tarojs/plugin-platform-qq": "3.5.7",
45
+    "@tarojs/plugin-platform-swan": "3.5.7",
46
+    "@tarojs/plugin-platform-tt": "3.5.7",
47
+    "@tarojs/plugin-platform-weapp": "3.5.7",
48
+    "@tarojs/react": "3.5.7",
49
+    "@tarojs/router": "3.5.7",
50
+    "@tarojs/runtime": "3.5.7",
51
+    "@tarojs/shared": "3.5.7",
52
+    "@tarojs/taro": "3.5.7",
53
+    "@tarojs/taro-h5": "3.5.7",
54
+    "react": "^18.0.0",
55
+    "react-dom": "^18.0.0",
56
+    "taro-ui": "^3.3.0"
57
+  },
58
+  "devDependencies": {
59
+    "@babel/core": "^7.8.0",
60
+    "@pmmmwh/react-refresh-webpack-plugin": "^0.5.5",
61
+    "@tarojs/cli": "3.5.7",
62
+    "@tarojs/mini-runner": "3.5.7",
63
+    "@tarojs/webpack-runner": "3.5.7",
64
+    "@types/react": "^18.0.0",
65
+    "@types/webpack-env": "^1.13.6",
66
+    "babel-preset-taro": "3.5.7",
67
+    "eslint": "^8.12.0",
68
+    "eslint-config-taro": "3.5.7",
69
+    "eslint-plugin-import": "^2.12.0",
70
+    "eslint-plugin-react": "^7.8.2",
71
+    "eslint-plugin-react-hooks": "^4.2.0",
72
+    "react-refresh": "^0.11.0",
73
+    "stylelint": "^14.4.0",
74
+    "webpack": "4.46.0"
75
+  }
76
+}

+ 29 - 0
project.config.json

@@ -0,0 +1,29 @@
1
+{
2
+  "miniprogramRoot": "dist/weapp/",
3
+  "projectname": "鱼市",
4
+  "description": "鱼市",
5
+  "appid": "wxcf756553cfb65cb8",
6
+  "setting": {
7
+      "urlCheck": true,
8
+      "es6": false,
9
+      "postcss": false,
10
+      "minified": false,
11
+      "babelSetting": {
12
+          "ignore": [],
13
+          "disablePlugins": [],
14
+          "outputPath": ""
15
+      }
16
+  },
17
+  "compileType": "miniprogram",
18
+  "libVersion": "2.26.0",
19
+  "srcMiniprogramRoot": "dist/",
20
+  "packOptions": {
21
+      "ignore": [],
22
+      "include": []
23
+  },
24
+  "condition": {},
25
+  "editorSetting": {
26
+      "tabIndent": "insertSpaces",
27
+      "tabSize": 2
28
+  }
29
+}

+ 9 - 0
project.tt.json

@@ -0,0 +1,9 @@
1
+{
2
+  "miniprogramRoot": "./",
3
+  "projectname": "fish_app",
4
+  "appid": "testAppId",
5
+  "setting": {
6
+    "es6": false,
7
+    "minified": false
8
+  }
9
+}

+ 6 - 0
src/api/config.js

@@ -0,0 +1,6 @@
1
+// 配置请求对象
2
+// 本地调试 dev 开发阶段
3
+// export const baseUrl = "https://test-openai.fyshark.com";//测试
4
+export const baseUrl = "https://openai.fyshark.com";//正式
5
+
6
+

+ 47 - 0
src/api/request.js

@@ -0,0 +1,47 @@
1
+import Taro from '@tarojs/taro';
2
+import ttappid from '../../project.tt.json'//抖音
3
+import wxappid from '../../project.config.json'//微信
4
+import { baseUrl } from './config';
5
+
6
+
7
+export default (options = {
8
+  method: 'GET',
9
+  data: {}
10
+}) => {
11
+
12
+  // 必传参数
13
+  const request_data = {
14
+    session_key: Taro.getStorageSync('session_key') || ''//缓存取值
15
+  };
16
+  if (process.env.TARO_ENV === 'weapp') {
17
+    request_data['appid'] = wxappid.appid
18
+  } else if (process.env.TARO_ENV === 'tt') {
19
+    request_data['appid'] = ttappid.appid
20
+  }
21
+  return Taro.request({
22
+    url: baseUrl + options.url,
23
+    data: {
24
+      ...request_data,
25
+      ...options.data,
26
+    },
27
+    header: {
28
+      'Content-Type': 'application/json',
29
+      'accept': 'application/json'
30
+    },
31
+    method: options.method.toUpperCase(),
32
+  }).then(res => {
33
+    const {
34
+      code,
35
+      data
36
+    } = res;
37
+    if (code == 200) {
38
+      return data;
39
+    } else {
40
+      Taro.showToast({
41
+        title: `${res.msg}~`,
42
+        icon: 'none',
43
+        mask: true,
44
+      });
45
+    }
46
+  });
47
+};

+ 49 - 0
src/app.config.js

@@ -0,0 +1,49 @@
1
+
2
+import Taro from '@tarojs/taro'
3
+export default defineAppConfig({
4
+  pages: [
5
+    'pages/index/index',
6
+    'pages/member/index',
7
+    "pages/mine/index",
8
+  ],
9
+  subpackages: [
10
+  ],
11
+  navigateToMiniProgramAppIdList: [
12
+    "ttf31985a46c214faf"
13
+  ],
14
+  window: {
15
+    backgroundTextStyle: 'light',
16
+    navigationBarBackgroundColor: '#FFFFFF',
17
+    navigationBarTitleText: '鱼市',
18
+    navigationBarTextStyle: 'black',
19
+    backgroundColor: "#FFFFFF"
20
+  },
21
+  tabBar: {
22
+    color: "#C6C6C6",
23
+    selectedColor: "#0F84EC",
24
+    borderStyle: "black",
25
+    backgroundColor: "#FFFFFF",
26
+    list: [
27
+      {
28
+        pagePath: "pages/index/index",
29
+        iconPath: "images/nav/play.png",
30
+        selectedIconPath: "images/nav/play_pin.png",
31
+        text: "首页"
32
+      },
33
+      {
34
+        pagePath: "pages/member/index",
35
+        iconPath: "images/nav/like.png",
36
+        selectedIconPath: "images/nav/like_pin.png",
37
+        text: "会员"
38
+
39
+      },
40
+
41
+      {
42
+        pagePath: "pages/mine/index",
43
+        iconPath: "images/nav/my.png",
44
+        selectedIconPath: "images/nav/my_pin.png",
45
+        text: "我的"
46
+      }
47
+    ]
48
+  },
49
+})

+ 19 - 0
src/app.js

@@ -0,0 +1,19 @@
1
+import { Component } from 'react'
2
+import './app.less'
3
+import 'taro-ui/dist/style/index.scss'
4
+
5
+class App extends Component {
6
+
7
+  componentDidMount () {}
8
+
9
+  componentDidShow () {}
10
+
11
+  componentDidHide () {}
12
+
13
+  render () {
14
+    // this.props.children 是将要会渲染的页面
15
+    return this.props.children
16
+  }
17
+}
18
+
19
+export default App

+ 3 - 0
src/app.less

@@ -0,0 +1,3 @@
1
+body {
2
+  background-color: #F9F9F9;
3
+}

BIN
src/images/app-icon.png


BIN
src/images/nav/like.png


BIN
src/images/nav/like_pin.png


BIN
src/images/nav/my.png


BIN
src/images/nav/my_pin.png


BIN
src/images/nav/play.png


BIN
src/images/nav/play_pin.png


BIN
src/images/nav/task.png


BIN
src/images/nav/task_pin.png


+ 17 - 0
src/index.html

@@ -0,0 +1,17 @@
1
+<!DOCTYPE html>
2
+<html>
3
+<head>
4
+  <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
5
+  <meta content="width=device-width,initial-scale=1,user-scalable=no" name="viewport">
6
+  <meta name="apple-mobile-web-app-capable" content="yes">
7
+  <meta name="apple-touch-fullscreen" content="yes">
8
+  <meta name="format-detection" content="telephone=no,address=no">
9
+  <meta name="apple-mobile-web-app-status-bar-style" content="white">
10
+  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" >
11
+  <title>fish_app</title>
12
+  <script><%= htmlWebpackPlugin.options.script %></script>
13
+</head>
14
+<body>
15
+  <div id="app"></div>
16
+</body>
17
+</html>

+ 4 - 0
src/pages/index/index.config.js

@@ -0,0 +1,4 @@
1
+export default definePageConfig({
2
+
3
+  navigationStyle: 'custom'
4
+})

+ 51 - 0
src/pages/index/index.jsx

@@ -0,0 +1,51 @@
1
+import { Component } from 'react'
2
+import { View, Image, Button, Input } from '@tarojs/components'
3
+import { AtIcon } from 'taro-ui'
4
+import './index.less'
5
+
6
+export default class Index extends Component {
7
+  state = {
8
+    value: ''
9
+  }
10
+
11
+  handleChange (value) {
12
+    this.setState({ value })
13
+  }
14
+
15
+  componentWillMount () { }
16
+
17
+  componentDidMount () { }
18
+
19
+  componentWillUnmount () { }
20
+
21
+  componentDidShow () { }
22
+
23
+  componentDidHide () { }
24
+
25
+  render () {
26
+    return (
27
+      <View className='index'>
28
+        <View className='header'>
29
+          <View className='header-content'>
30
+            <Image className='header-img' src='https://video-img.fyshark.com/1731495433480WechatIMG674.jpg' />
31
+          </View>
32
+          <View className='search-wrap'>
33
+            <View className='search-bar'>
34
+              <AtIcon className='search-icon' value='search' size='24' color='#ACACAC'></AtIcon>
35
+              <Input
36
+                type='text'
37
+                className='search-input'
38
+                placeholder='夏季男士T恤'
39
+                value={this.state.value}
40
+                onInput={this.handleChange.bind(this)}
41
+              />
42
+              <View className='search-button'>
43
+                搜索
44
+              </View>
45
+            </View>
46
+          </View>
47
+        </View>
48
+      </View>
49
+    )
50
+  }
51
+}

+ 53 - 0
src/pages/index/index.less

@@ -0,0 +1,53 @@
1
+.index {
2
+  .header {
3
+    width: 100%;
4
+    height: 500px;
5
+    background-color: #FDF652;
6
+    padding-top: 70px;
7
+
8
+    .header-content {
9
+      width: 100%;
10
+      display: flex;
11
+      justify-content: center;
12
+
13
+      .header-img {
14
+        width: 100px;
15
+        height: 50px;
16
+        object-fit: cover;
17
+      }
18
+    }
19
+
20
+    .search-wrap {
21
+      margin-top: 20px;
22
+      display: flex;
23
+      align-items: center;
24
+      justify-content: center;
25
+
26
+      .search-bar {
27
+        width: 90%;
28
+        display: flex;
29
+        align-items: center;
30
+        background-color: #FFFFFF; // 黄色背景
31
+        border-radius: 50px;
32
+        padding: 10px;
33
+        .search-icon {
34
+          margin: 0 20px;
35
+        }
36
+  
37
+        .search-input {
38
+          flex: 1;
39
+          border: none;
40
+          outline: none;
41
+          background-color: transparent;
42
+        }
43
+  
44
+        .search-button {
45
+          border: 1px solid #7D807E;
46
+          border-radius: 50px;
47
+          padding: 5px 20px;
48
+        }
49
+      }
50
+
51
+    }
52
+  }
53
+}

+ 3 - 0
src/pages/member/index.config.js

@@ -0,0 +1,3 @@
1
+export default definePageConfig({
2
+  navigationBarTitleText: '会员'
3
+})

+ 24 - 0
src/pages/member/index.jsx

@@ -0,0 +1,24 @@
1
+import { Component } from 'react'
2
+import { View, Text } from '@tarojs/components'
3
+import './index.less'
4
+
5
+export default class Index extends Component {
6
+
7
+  componentWillMount () { }
8
+
9
+  componentDidMount () { }
10
+
11
+  componentWillUnmount () { }
12
+
13
+  componentDidShow () { }
14
+
15
+  componentDidHide () { }
16
+
17
+  render () {
18
+    return (
19
+      <View className='index'>
20
+        <Text>会员</Text>
21
+      </View>
22
+    )
23
+  }
24
+}

+ 0 - 0
src/pages/member/index.less


+ 3 - 0
src/pages/mine/index.config.js

@@ -0,0 +1,3 @@
1
+export default definePageConfig({
2
+  navigationBarTitleText: '我的'
3
+})

+ 24 - 0
src/pages/mine/index.jsx

@@ -0,0 +1,24 @@
1
+import { Component } from 'react'
2
+import { View, Text } from '@tarojs/components'
3
+import './index.less'
4
+
5
+export default class Index extends Component {
6
+
7
+  componentWillMount () { }
8
+
9
+  componentDidMount () { }
10
+
11
+  componentWillUnmount () { }
12
+
13
+  componentDidShow () { }
14
+
15
+  componentDidHide () { }
16
+
17
+  render () {
18
+    return (
19
+      <View className='index'>
20
+        <Text>我的</Text>
21
+      </View>
22
+    )
23
+  }
24
+}

+ 0 - 0
src/pages/mine/index.less


+ 19 - 0
src/service/index.js

@@ -0,0 +1,19 @@
1
+//接口集成
2
+import Request from '../api/request';
3
+
4
+//接口请求
5
+export const login = data =>
6
+  Request({
7
+    url: '/api/login',
8
+    method: 'POST',
9
+    data,
10
+  });
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+

+ 19 - 0
types/global.d.ts

@@ -0,0 +1,19 @@
1
+/// <reference types="@tarojs/taro" />
2
+
3
+declare module '*.png';
4
+declare module '*.gif';
5
+declare module '*.jpg';
6
+declare module '*.jpeg';
7
+declare module '*.svg';
8
+declare module '*.css';
9
+declare module '*.less';
10
+declare module '*.scss';
11
+declare module '*.sass';
12
+declare module '*.styl';
13
+
14
+declare namespace NodeJS {
15
+  interface ProcessEnv {
16
+    TARO_ENV: 'weapp' | 'swan' | 'alipay' | 'h5' | 'rn' | 'tt' | 'quickapp' | 'qq' | 'jd'
17
+  }
18
+}
19
+