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