add locale request
parent
1907f1e967
commit
00977db512
|
|
@ -29,7 +29,7 @@ export default {
|
|||
success: true,
|
||||
data: {
|
||||
token: 'token_test',
|
||||
lang: 'zn_CN',
|
||||
lang: 'en_US',
|
||||
},
|
||||
},
|
||||
'POST /user/locale/update': {
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
202
package.json
202
package.json
|
|
@ -1,103 +1,103 @@
|
|||
{
|
||||
"name": "eva-notify",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"description": "A Wechat miniprogram project of EVA platform",
|
||||
"templateInfo": {
|
||||
"name": "default",
|
||||
"typescript": true,
|
||||
"css": "Sass",
|
||||
"framework": "React"
|
||||
},
|
||||
"scripts": {
|
||||
"build:weapp": "taro build --type weapp",
|
||||
"build:swan": "taro build --type swan",
|
||||
"build:alipay": "taro build --type alipay",
|
||||
"build:tt": "taro build --type tt",
|
||||
"build:h5": "taro build --type h5",
|
||||
"build:rn": "taro build --type rn",
|
||||
"build:qq": "taro build --type qq",
|
||||
"build:jd": "taro build --type jd",
|
||||
"build:quickapp": "taro build --type quickapp",
|
||||
"build:harmony-hybrid": "taro build --type harmony-hybrid",
|
||||
"dev:weapp": "npm run build:weapp -- --watch --mode dev",
|
||||
"dev:swan": "npm run build:swan -- --watch",
|
||||
"dev:alipay": "npm run build:alipay -- --watch",
|
||||
"dev:tt": "npm run build:tt -- --watch",
|
||||
"dev:h5": "npm run build:h5 -- --watch",
|
||||
"dev:rn": "npm run build:rn -- --watch",
|
||||
"dev:qq": "npm run build:qq -- --watch",
|
||||
"dev:jd": "npm run build:jd -- --watch",
|
||||
"dev:quickapp": "npm run build:quickapp -- --watch",
|
||||
"dev:harmony-hybrid": "npm run build:harmony-hybrid -- --watch",
|
||||
"test": "jest",
|
||||
"prepare": "husky install"
|
||||
},
|
||||
"browserslist": [
|
||||
"last 3 versions",
|
||||
"Android >= 4.1",
|
||||
"ios >= 8"
|
||||
],
|
||||
"author": "",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.21.5",
|
||||
"@tarojs/components": "3.6.24",
|
||||
"@tarojs/helper": "3.6.24",
|
||||
"@tarojs/plugin-framework-react": "3.6.24",
|
||||
"@tarojs/plugin-platform-alipay": "3.6.24",
|
||||
"@tarojs/plugin-platform-harmony-hybrid": "3.6.24",
|
||||
"@tarojs/plugin-platform-jd": "3.6.24",
|
||||
"@tarojs/plugin-platform-qq": "3.6.24",
|
||||
"@tarojs/plugin-platform-swan": "3.6.24",
|
||||
"@tarojs/plugin-platform-tt": "3.6.24",
|
||||
"@tarojs/plugin-platform-weapp": "3.6.24",
|
||||
"@tarojs/react": "3.6.24",
|
||||
"@tarojs/runtime": "3.6.24",
|
||||
"@tarojs/shared": "3.6.24",
|
||||
"@tarojs/taro": "3.6.24",
|
||||
"process": "^0.11.10",
|
||||
"react": "^18.0.0",
|
||||
"react-dom": "^18.0.0",
|
||||
"taro-ui": "^3.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.8.0",
|
||||
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.5",
|
||||
"@tarojs/cli": "3.6.24",
|
||||
"@tarojs/plugin-mock": "^0.0.9",
|
||||
"@tarojs/plugin-platform-h5": "^3.6.24",
|
||||
"@tarojs/taro-loader": "3.6.24",
|
||||
"@tarojs/test-utils-react": "^0.1.1",
|
||||
"@tarojs/webpack5-runner": "3.6.24",
|
||||
"@types/jest": "^29.3.1",
|
||||
"@types/node": "^18.15.11",
|
||||
"@types/react": "^18.0.0",
|
||||
"@types/sass": "^1.43.1",
|
||||
"@types/webpack-env": "^1.13.6",
|
||||
"@typescript-eslint/eslint-plugin": "^6.2.0",
|
||||
"@typescript-eslint/parser": "^6.2.0",
|
||||
"babel-preset-taro": "3.6.24",
|
||||
"eslint": "^8.12.0",
|
||||
"eslint-config-taro": "3.6.24",
|
||||
"eslint-plugin-import": "^2.12.0",
|
||||
"eslint-plugin-prettier": "^5.1.3",
|
||||
"eslint-plugin-react": "^7.8.2",
|
||||
"eslint-plugin-react-hooks": "^4.2.0",
|
||||
"husky": "^9.0.11",
|
||||
"jest": "^29.3.1",
|
||||
"jest-environment-jsdom": "^29.5.0",
|
||||
"lint-staged": "^15.2.2",
|
||||
"mockjs": "^1.1.0",
|
||||
"postcss": "^8.4.18",
|
||||
"react-refresh": "^0.11.0",
|
||||
"stylelint": "^14.4.0",
|
||||
"ts-node": "^10.9.1",
|
||||
"tsconfig-paths-webpack-plugin": "^4.1.0",
|
||||
"typescript": "^5.1.0",
|
||||
"webpack": "5.78.0"
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.ts": "prettier --write",
|
||||
"*.tsx": "prettier --write"
|
||||
}
|
||||
"name": "eva-notify",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"description": "A Wechat miniprogram project of EVA platform",
|
||||
"templateInfo": {
|
||||
"name": "default",
|
||||
"typescript": true,
|
||||
"css": "Sass",
|
||||
"framework": "React"
|
||||
},
|
||||
"scripts": {
|
||||
"build:weapp": "taro build --type weapp",
|
||||
"build:swan": "taro build --type swan",
|
||||
"build:alipay": "taro build --type alipay",
|
||||
"build:tt": "taro build --type tt",
|
||||
"build:h5": "taro build --type h5",
|
||||
"build:rn": "taro build --type rn",
|
||||
"build:qq": "taro build --type qq",
|
||||
"build:jd": "taro build --type jd",
|
||||
"build:quickapp": "taro build --type quickapp",
|
||||
"build:harmony-hybrid": "taro build --type harmony-hybrid",
|
||||
"dev:weapp": "npm run build:weapp -- --watch --mode dev",
|
||||
"dev:swan": "npm run build:swan -- --watch",
|
||||
"dev:alipay": "npm run build:alipay -- --watch",
|
||||
"dev:tt": "npm run build:tt -- --watch",
|
||||
"dev:h5": "npm run build:h5 -- --watch",
|
||||
"dev:rn": "npm run build:rn -- --watch",
|
||||
"dev:qq": "npm run build:qq -- --watch",
|
||||
"dev:jd": "npm run build:jd -- --watch",
|
||||
"dev:quickapp": "npm run build:quickapp -- --watch",
|
||||
"dev:harmony-hybrid": "npm run build:harmony-hybrid -- --watch",
|
||||
"test": "jest",
|
||||
"prepare": "husky install"
|
||||
},
|
||||
"browserslist": [
|
||||
"last 3 versions",
|
||||
"Android >= 4.1",
|
||||
"ios >= 8"
|
||||
],
|
||||
"author": "",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.21.5",
|
||||
"@tarojs/components": "3.6.24",
|
||||
"@tarojs/helper": "3.6.24",
|
||||
"@tarojs/plugin-framework-react": "3.6.24",
|
||||
"@tarojs/plugin-platform-alipay": "3.6.24",
|
||||
"@tarojs/plugin-platform-harmony-hybrid": "3.6.24",
|
||||
"@tarojs/plugin-platform-jd": "3.6.24",
|
||||
"@tarojs/plugin-platform-qq": "3.6.24",
|
||||
"@tarojs/plugin-platform-swan": "3.6.24",
|
||||
"@tarojs/plugin-platform-tt": "3.6.24",
|
||||
"@tarojs/plugin-platform-weapp": "3.6.24",
|
||||
"@tarojs/react": "3.6.24",
|
||||
"@tarojs/runtime": "3.6.24",
|
||||
"@tarojs/shared": "3.6.24",
|
||||
"@tarojs/taro": "3.6.24",
|
||||
"process": "^0.11.10",
|
||||
"react": "^18.0.0",
|
||||
"react-dom": "^18.0.0",
|
||||
"taro-ui": "^3.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.8.0",
|
||||
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.5",
|
||||
"@tarojs/cli": "3.6.24",
|
||||
"@tarojs/plugin-mock": "^0.0.9",
|
||||
"@tarojs/plugin-platform-h5": "3.6.24",
|
||||
"@tarojs/taro-loader": "3.6.24",
|
||||
"@tarojs/test-utils-react": "^0.1.1",
|
||||
"@tarojs/webpack5-runner": "3.6.24",
|
||||
"@types/jest": "^29.3.1",
|
||||
"@types/node": "^18.15.11",
|
||||
"@types/react": "^18.0.0",
|
||||
"@types/sass": "^1.43.1",
|
||||
"@types/webpack-env": "^1.13.6",
|
||||
"@typescript-eslint/eslint-plugin": "^6.2.0",
|
||||
"@typescript-eslint/parser": "^6.2.0",
|
||||
"babel-preset-taro": "3.6.24",
|
||||
"eslint": "^8.12.0",
|
||||
"eslint-config-taro": "3.6.24",
|
||||
"eslint-plugin-import": "^2.12.0",
|
||||
"eslint-plugin-prettier": "^5.1.3",
|
||||
"eslint-plugin-react": "^7.8.2",
|
||||
"eslint-plugin-react-hooks": "^4.2.0",
|
||||
"husky": "^9.0.11",
|
||||
"jest": "^29.3.1",
|
||||
"jest-environment-jsdom": "^29.5.0",
|
||||
"lint-staged": "^15.2.2",
|
||||
"mockjs": "^1.1.0",
|
||||
"postcss": "^8.4.18",
|
||||
"react-refresh": "^0.11.0",
|
||||
"stylelint": "^14.4.0",
|
||||
"ts-node": "^10.9.1",
|
||||
"tsconfig-paths-webpack-plugin": "^4.1.0",
|
||||
"typescript": "^5.1.0",
|
||||
"webpack": "5.78.0"
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.ts": "prettier --write",
|
||||
"*.tsx": "prettier --write"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
11
src/app.ts
11
src/app.ts
|
|
@ -1,11 +1,20 @@
|
|||
import { PropsWithChildren } from 'react';
|
||||
import { useLaunch } from '@tarojs/taro';
|
||||
import Taro, { useLaunch } from '@tarojs/taro';
|
||||
import { getUrl } from '@/service';
|
||||
import pt from '@/plain-text';
|
||||
import 'taro-ui/dist/style/index.scss';
|
||||
import './app.scss';
|
||||
|
||||
function App({ children }: PropsWithChildren<any>) {
|
||||
useLaunch(() => {
|
||||
console.log('App launched.');
|
||||
Taro.request({
|
||||
url: getUrl('/user/locale/get'),
|
||||
method: 'GET',
|
||||
}).then(res => {
|
||||
console.log(res.data);
|
||||
pt.setLang(res.data.data.lang);
|
||||
});
|
||||
});
|
||||
|
||||
// children 是将要会渲染的页面
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { AtList, AtListItem } from 'taro-ui';
|
||||
import { Component, ReactNode } from 'react';
|
||||
import { View, Picker, Image, Text } from '@tarojs/components';
|
||||
import { getUrl } from '@/service';
|
||||
import Taro from '@tarojs/taro';
|
||||
import type CustomTabBar from '@/custom-tab-bar';
|
||||
import PageFooter from '@/components/PageFooter/PageFooter';
|
||||
|
|
@ -35,7 +36,18 @@ export default class UserPage extends Component {
|
|||
this.setState({
|
||||
selectorChecked: this.state.selector[e.detail.value],
|
||||
});
|
||||
pt.setLang(this.showLangDict[this.state.selector[e.detail.value]]);
|
||||
let currentLang = this.showLangDict[this.state.selector[e.detail.value]];
|
||||
pt.setLang(currentLang);
|
||||
Taro.request({
|
||||
url: getUrl('/user/locale/update'),
|
||||
method: 'POST',
|
||||
data: {
|
||||
token: 'token_test',
|
||||
lang: currentLang,
|
||||
},
|
||||
}).then(res => {
|
||||
console.log(res.data);
|
||||
});
|
||||
Taro.reLaunch({
|
||||
url: '/pages/user/user',
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue