Skip to content

Commit

Permalink
merged from origin
Browse files Browse the repository at this point in the history
  • Loading branch information
hiyuki committed Apr 30, 2024
2 parents 9c919da + e075d68 commit d44f13a
Show file tree
Hide file tree
Showing 25 changed files with 1,496 additions and 2 deletions.
9 changes: 9 additions & 0 deletions examples/mpx-api-proxy/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
15 changes: 15 additions & 0 deletions examples/mpx-api-proxy/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
root: true,
extends: ['@mpxjs'],
rules: {
// .mpx文件规则 https://mpx-ecology.github.io/eslint-plugin-mpx/rules/
},
overrides: [
{
files: ['**/*.js'],
rules: {
// .js文件规则 https://eslint.bootcss.com/docs/rules/
}
}
]
}
8 changes: 8 additions & 0 deletions examples/mpx-api-proxy/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.DS_Store
node_modules/
npm-debug.log
.idea/
deploy/
output/
dist/
.vscode/
13 changes: 13 additions & 0 deletions examples/mpx-api-proxy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# mpx-api-proxy

## Project setup

```javascript
// development
npm run serve // 小程序本地开发构建


// production
npm run build // 小程序生产环境构建

```
34 changes: 34 additions & 0 deletions examples/mpx-api-proxy/babel.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"presets": [
[
"@babel/preset-env",
{
"modules": false,
"shippedProposals": true
}
]
],
"plugins": [
[
"@babel/transform-runtime",
{
"corejs": 3,
"version": "^7.10.4"
}
],
"@mpxjs/babel-plugin-inject-page-events"
],
"sourceType": "unambiguous",
"env": {
"test": {
"presets": [
[
"@babel/env",
{
"shippedProposals": true
}
]
]
}
}
}
19 changes: 19 additions & 0 deletions examples/mpx-api-proxy/jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"target": "es5",
"module": "esnext",
"baseUrl": "./",
"moduleResolution": "node",
"paths": {
"@/*": [
"src/*"
]
},
"lib": [
"esnext",
"dom",
"dom.iterable",
"scripthost"
]
}
}
50 changes: 50 additions & 0 deletions examples/mpx-api-proxy/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"name": "mpx-api-proxy",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "mpx-cli-service serve --targets=web,wx,ali,tt",
"serve:wx": "mpx-cli-service serve --targets=wx",
"serve:web": "mpx-cli-service serve --targets=web",
"build": "mpx-cli-service build",
"lint": "eslint --ext .js,.ts,.mpx src/"
},
"dependencies": {
"@mpxjs/api-proxy": "^2.9.28",
"@mpxjs/core": "^2.9.0",
"@mpxjs/fetch": "^2.9.0",
"@mpxjs/pinia": "^2.9.0",
"@mpxjs/store": "^2.9.0",
"@mpxjs/utils": "^2.9.0",
"pinia": "^2.0.14",
"vue": "^2.7.0",
"vue-demi": "^0.14.6",
"vue-i18n": "^8.27.2",
"vue-i18n-bridge": "^9.2.2",
"vue-router": "^3.1.3"
},
"devDependencies": {
"@babel/core": "^7.10.4",
"@babel/plugin-transform-runtime": "^7.10.4",
"@babel/preset-env": "^7.10.4",
"@babel/runtime-corejs3": "^7.10.4",
"@mpxjs/babel-plugin-inject-page-events": "^2.9.0",
"@mpxjs/eslint-config": "^1.0.5",
"@mpxjs/mpx-cli-service": "^2.0.0",
"@mpxjs/size-report": "^2.9.0",
"@mpxjs/vue-cli-plugin-mpx": "^2.0.0",
"@mpxjs/vue-cli-plugin-mpx-eslint": "^2.0.0",
"@mpxjs/webpack-plugin": "^2.9.0",
"@vue/cli-service": "~5.0.0",
"autoprefixer": "^10.2.4",
"eslint": "^7.0.0",
"postcss": "^8.2.6",
"stylus": "^0.55.0",
"stylus-loader": "^6.1.0",
"webpack": "^5.43.0"
},
"browserslist": [
"ios >= 8",
"chrome >= 47"
]
}
5 changes: 5 additions & 0 deletions examples/mpx-api-proxy/postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
plugins: [
require('autoprefixer')({ remove: false })
]
}
15 changes: 15 additions & 0 deletions examples/mpx-api-proxy/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, viewport-fit=cover">
<meta name="format-detection" content="telephone=no">
<meta name="x5-cache" content="disable">
<title></title>
</head>
<body>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>
47 changes: 47 additions & 0 deletions examples/mpx-api-proxy/src/app.mpx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<script>
import { createApp } from '@mpxjs/core'

createApp({
onLaunch() {
}
})
</script>

<style>
/*此处编写全局样式*/
</style>

<script type="application/json">
{
"pages": [
"./pages/treeSharking",
"./pages/notTreeSharking"
],
"tabBar": {
"color": "#7A7E83",
"selectedColor": "#3cc51f",
"backgroundColor": "#ffffff",
"list": [
{
"pagePath": "pages/treeSharking",
"text": "组件"
},
{
"pagePath": "pages/notTreeSharking",
"text": "接口"
}
]
}
}
</script>

<!--也可以通过以下形式用js输出json,便于书写注释和使用条件编译-->

<!--<script name="json">-->
<!-- // 可以写注释,通过defs注入的常量做一些判断之类的操作-->
<!-- module.exports = {-->
<!-- pages: [-->
<!-- './pages/index'-->
<!-- ]-->
<!-- }-->
<!--</script>-->
22 changes: 22 additions & 0 deletions examples/mpx-api-proxy/src/pages/index.mpx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<template>
<view>
<view bindtap="treeSharking">treeSharing</view>
<view bindtap="notTreeSharking">notTreeSharing</view>
</view>
</template>

<script>
import { createPage } from '@mpxjs/core'
import { navigateTo } from '@mpxjs/api-proxy'

createPage({
methods: {
treeSharking() {
navigateTo({ url: './treeSharking' })
},
notTreeSharking() {
navigateTo({ url: './notTreeSharking' })
}
}
})
</script>
78 changes: 78 additions & 0 deletions examples/mpx-api-proxy/src/pages/notTreeSharking.mpx
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<template>
<view>
<view class="api-proxy-block">
<view class="title">getUserInfo</view>
<button bindtap="getUserInfo">getUserInfo</button>
</view>

<view class="api-proxy-block">
<view class="title">request</view>
<button bindtap="request">request</button>
</view>
<view class="api-proxy-block">
<view class="title">NavigationBar</view>
<button bindtap="setNavigationBarColor">setNavigationBarColor</button>
</view>
<view class="api-proxy-block">
<view class="title">route</view>
<button bindtap="navigateBackHandle">navigateBack</button>
</view>
</view>
</template>

<script>
import mpx, { createPage } from '@mpxjs/core'

import apiProxy from '@mpxjs/api-proxy'
mpx.use(apiProxy, { usePromise: true })
createPage({
methods: {
getUserInfo() {
mpx.getUserInfo({
success(res) {
console.log(res, '========getUserInfo: success')
},
fail(res) {
console.log(res, '========getUserInfo: fail')
}
})
},
request() {
mpx.request({
url: 'https://api.udache.com/gulfstream/passenger-center/v2/other/PGetTakeBusQrCodeDetail',
data: {
x: '1',
y: '2'
},
header: {
'content-type': 'application/json'
}
}).then((res) => {
console.log(res.data, 'request: success')
}).catch((err) => {
console.log(err, 'request: fail')
})
},
setNavigationBarColor() {
mpx.setNavigationBarColor({
frontColor: '#ffffff',
backgroundColor: '#000000'
}).then((res) => {
console.log(res, 'setNavigationBarColor: success')
}).catch((err) => {
console.log(err, 'setNavigationBarColor: fail')
})
},
navigateBackHandle() {
mpx.navigateBack()
}
}
})
</script>

<script type="application/json">
{
"usingComponents": {
}
}
</script>
Loading

0 comments on commit d44f13a

Please sign in to comment.