af-mobile-client-vue3 1.0.98 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,154 @@
1
+ // 导入proj控件
2
+ import * as proj from 'ol/proj'
3
+
4
+ function forEachPoint(func) {
5
+ return function (input, opt_output, opt_dimension) {
6
+ const len = input.length
7
+
8
+ const dimension = opt_dimension || 2
9
+ let output
10
+
11
+ if (opt_output) {
12
+ output = opt_output
13
+ }
14
+ else {
15
+ if (dimension !== 2) {
16
+ output = input.slice()
17
+ }
18
+ else {
19
+ output = [len]
20
+ }
21
+ }
22
+ for (let offset = 0; offset < len; offset += dimension) {
23
+ func(input, output, offset)
24
+ }
25
+ return output
26
+ }
27
+ }
28
+
29
+ const gcj02 = {}
30
+ const PI = Math.PI
31
+ const AXIS = 6378245.0
32
+ // eslint-disable-next-line no-loss-of-precision
33
+ const OFFSET = 0.00669342162296594323 // (a^2 - b^2) / a^2
34
+
35
+ function delta(wgLon, wgLat) {
36
+ let dLat = transformLat(wgLon - 105.0, wgLat - 35.0)
37
+ let dLon = transformLon(wgLon - 105.0, wgLat - 35.0)
38
+ const radLat = (wgLat / 180.0) * PI
39
+ let magic = Math.sin(radLat)
40
+ magic = 1 - OFFSET * magic * magic
41
+ const sqrtMagic = Math.sqrt(magic)
42
+ dLat = (dLat * 180.0) / (((AXIS * (1 - OFFSET)) / (magic * sqrtMagic)) * PI)
43
+ dLon = (dLon * 180.0) / ((AXIS / sqrtMagic) * Math.cos(radLat) * PI)
44
+ return [dLon, dLat]
45
+ }
46
+
47
+ function outOfChina(lon, lat) {
48
+ if (lon < 72.004 || lon > 137.8347) {
49
+ return true
50
+ }
51
+ return lat < 0.8293 || lat > 55.8271
52
+ }
53
+
54
+ function transformLat(x, y) {
55
+ let ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * Math.sqrt(Math.abs(x))
56
+ ret += ((20.0 * Math.sin(6.0 * x * PI) + 20.0 * Math.sin(2.0 * x * PI)) * 2.0) / 3.0
57
+ ret += ((20.0 * Math.sin(y * PI) + 40.0 * Math.sin((y / 3.0) * PI)) * 2.0) / 3.0
58
+ ret += ((160.0 * Math.sin((y / 12.0) * PI) + 320 * Math.sin((y * PI) / 30.0)) * 2.0) / 3.0
59
+ return ret
60
+ }
61
+
62
+ function transformLon(x, y) {
63
+ let ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * Math.sqrt(Math.abs(x))
64
+ ret += ((20.0 * Math.sin(6.0 * x * PI) + 20.0 * Math.sin(2.0 * x * PI)) * 2.0) / 3.0
65
+ ret += ((20.0 * Math.sin(x * PI) + 40.0 * Math.sin((x / 3.0) * PI)) * 2.0) / 3.0
66
+ ret += ((150.0 * Math.sin((x / 12.0) * PI) + 300.0 * Math.sin((x / 30.0) * PI)) * 2.0) / 3.0
67
+ return ret
68
+ }
69
+
70
+ gcj02.toWGS84 = forEachPoint((input, output, offset) => {
71
+ let lng = input[offset]
72
+ let lat = input[offset + 1]
73
+ if (!outOfChina(lng, lat)) {
74
+ const deltaD = delta(lng, lat)
75
+ lng = lng - deltaD[0] // 改回减法
76
+ lat = lat - deltaD[1] // 改回减法
77
+ }
78
+ output[offset] = lng
79
+ output[offset + 1] = lat
80
+ })
81
+
82
+ gcj02.fromWGS84 = forEachPoint((input, output, offset) => {
83
+ let lng = input[offset]
84
+ let lat = input[offset + 1]
85
+ if (!outOfChina(lng, lat)) {
86
+ const deltaD = delta(lng, lat)
87
+ lng = lng + deltaD[0] // 改回加法
88
+ lat = lat + deltaD[1] // 改回加法
89
+ }
90
+ output[offset] = lng
91
+ output[offset + 1] = lat
92
+ })
93
+
94
+ const sphericalMercator = {}
95
+ const RADIUS = 6378137
96
+ const MAX_LATITUDE = 85.0511287798
97
+ const RAD_PER_DEG = Math.PI / 180
98
+
99
+ sphericalMercator.forward = forEachPoint((input, output, offset) => {
100
+ const lat = Math.max(Math.min(MAX_LATITUDE, input[offset + 1]), -MAX_LATITUDE)
101
+ const sin = Math.sin(lat * RAD_PER_DEG)
102
+ output[offset] = RADIUS * input[offset] * RAD_PER_DEG
103
+ output[offset + 1] = (RADIUS * Math.log((1 + sin) / (1 - sin))) / 2
104
+ })
105
+
106
+ sphericalMercator.inverse = forEachPoint((input, output, offset) => {
107
+ output[offset] = input[offset] / RADIUS / RAD_PER_DEG
108
+ output[offset + 1] = (2 * Math.atan(Math.exp(input[offset + 1] / RADIUS)) - Math.PI / 2) / RAD_PER_DEG
109
+ })
110
+
111
+ const projzh = {}
112
+
113
+ projzh.ll2gmerc = function (input, opt_output, opt_dimension) {
114
+ const output = gcj02.toWGS84(input, opt_output, opt_dimension) // 改用 toWGS84
115
+ return projzh.ll2smerc(output, output, opt_dimension)
116
+ }
117
+
118
+ projzh.gmerc2ll = function (input, opt_output, opt_dimension) {
119
+ const output = projzh.smerc2ll(input, input, opt_dimension)
120
+ return gcj02.fromWGS84(output, opt_output, opt_dimension) // 改用 fromWGS84
121
+ }
122
+
123
+ // smerc2gmerc 需要修改
124
+
125
+ projzh.smerc2gmerc = function (input, opt_output, opt_dimension) {
126
+ let output = projzh.smerc2ll(input, input, opt_dimension)
127
+ output = gcj02.toWGS84(output, output, opt_dimension) // 这里应该用 toWGS84
128
+ return projzh.ll2smerc(output, output, opt_dimension)
129
+ }
130
+
131
+ // gmerc2smerc 需要修改
132
+
133
+ projzh.gmerc2smerc = function (input, opt_output, opt_dimension) {
134
+ let output = projzh.smerc2ll(input, input, opt_dimension)
135
+ output = gcj02.fromWGS84(output, output, opt_dimension) // 这里应该用 fromWGS84
136
+ return projzh.ll2smerc(output, output, opt_dimension)
137
+ }
138
+
139
+ projzh.ll2smerc = sphericalMercator.forward
140
+ projzh.smerc2ll = sphericalMercator.inverse
141
+
142
+ // 定义WGS84转GCJ02的投影
143
+ const extent = [-20037508.342789244, -20037508.342789244, 20037508.342789244, 20037508.342789244]
144
+ export const wgs84ToGcj02Projection = new proj.Projection({
145
+ code: 'WGS84-TO-GCJ02',
146
+ extent,
147
+ units: 'm',
148
+ })
149
+
150
+ // 添加投影和转换方法
151
+ proj.addProjection(wgs84ToGcj02Projection)
152
+ // 注意这里转换方法的顺序与原来相反
153
+ proj.addCoordinateTransforms('EPSG:4326', wgs84ToGcj02Projection, projzh.ll2gmerc, projzh.gmerc2ll)
154
+ proj.addCoordinateTransforms('EPSG:3857', wgs84ToGcj02Projection, projzh.smerc2gmerc, projzh.gmerc2smerc)
@@ -0,0 +1,8 @@
1
+ import { post } from '@af-mobile-client-vue3/services/restTools'
2
+
3
+ export function getUserPermissions(userid: string) {
4
+ return post(`/af-system/search`, {
5
+ source: 'this.getRights().where(row.getType()==$function$ && row.getPath($name$).indexOf($功能权限$) != -1)',
6
+ userid,
7
+ })
8
+ }
@@ -24,7 +24,11 @@ const list = ref([
24
24
  },
25
25
  {
26
26
  name: 'XForm 表单',
27
- to: '/Component/XFormView/1/debug',
27
+ to: '/Component/XFormView/1/debug?configName=hiddenTroubleFollowForm&serviceName=af-linepatrol&mode=新增',
28
+ },
29
+ {
30
+ name: 'XFormGroup 表单组',
31
+ to: '/Component/XFormGroupView',
28
32
  },
29
33
  {
30
34
  name: '操作卡手机端',
@@ -46,6 +50,10 @@ const list = ref([
46
50
  name: 'XFormAppraise 表单',
47
51
  to: '/Component/XFormAppraiseView/2/debug',
48
52
  },
53
+ {
54
+ name: 'XOlmap 地图组件',
55
+ to: '/Component/XOlMapView',
56
+ },
49
57
  ])
50
58
 
51
59
  function cleanConfigCache() {
@@ -3,12 +3,25 @@ import type { UserInfo } from '@af-mobile-client-vue3/stores/modules/user'
3
3
  import type { FormInstance } from 'vant'
4
4
  import { LoginStateEnum, useFormRules, useLoginState } from '@af-mobile-client-vue3/hooks/useLogin'
5
5
  import GetAppDataService from '@af-mobile-client-vue3/plugins/AppData'
6
+ import { getUserPermissions } from '@af-mobile-client-vue3/services/api/search'
6
7
  import { useSettingStore } from '@af-mobile-client-vue3/stores/modules/setting'
7
8
  import { useUserStore } from '@af-mobile-client-vue3/stores/modules/user'
8
9
  import { indexedDB } from '@af-mobile-client-vue3/utils/indexedDB'
9
10
  import { funcToRouter, loadRoutes } from '@af-mobile-client-vue3/utils/routerUtil'
10
11
  import { isWechat } from '@af-mobile-client-vue3/utils/wechatUtil'
11
- import { closeToast, showDialog, showFailToast, Switch, Button as VanButton, Col as VanCol, Field as VanField, Form as VanForm, Icon as VanIcon, Loading as VanLoading, Row as VanRow } from 'vant'
12
+ import {
13
+ closeToast,
14
+ showDialog,
15
+ showFailToast,
16
+ Switch,
17
+ Button as VanButton,
18
+ Col as VanCol,
19
+ Field as VanField,
20
+ Form as VanForm,
21
+ Icon as VanIcon,
22
+ Loading as VanLoading,
23
+ Row as VanRow,
24
+ } from 'vant'
12
25
  import { computed, inject, onBeforeMount, onMounted, reactive, ref, unref } from 'vue'
13
26
  import { useRoute, useRouter } from 'vue-router'
14
27
  import 'vant/lib/switch/index.css'
@@ -41,13 +54,12 @@ onBeforeMount(async () => {
41
54
  try {
42
55
  wxloading.value = true
43
56
  if (route.query.code && route.query.state) {
44
- const res: any = await userState.loginUnified({
57
+ const data = await userState.loginUnified({
45
58
  unifiedCode: `${route.query.code}`,
46
59
  tenantName: `${route.query.state}`,
47
60
  loginMode: 'wechat',
48
61
  resourceName: setting.getSetting()?.routerName || '智慧手机',
49
62
  })
50
- const data = res
51
63
  login.f = data
52
64
  await Promise.all([GetAppDataService.load()])
53
65
  const loginInfo = {
@@ -157,7 +169,11 @@ function afterGeneral(result) {
157
169
  rolestr: result.rolestr,
158
170
  }
159
171
  userState.setUserInfo(user)
160
- userState.setPermissions([{ id: 'queryForm', operation: ['add', 'edit'] }])
172
+ // 如果result中没有返回 权限 需要主动获取权限列表
173
+ if (!result.permissions) {
174
+ result.permissions = getUserPermissions(result.id)
175
+ }
176
+ userState.setPermissions(result.permissions)
161
177
  userState.setRoles([{ id: 'admin', operation: ['add', 'edit', 'delete'] }])
162
178
  // 加载路由
163
179
  loadRoutes(funcToRouter(user.functions))
package/vite.config.ts CHANGED
@@ -1,123 +1,130 @@
1
- import type { ConfigEnv, UserConfig } from 'vite'
2
- import path from 'node:path'
3
- import process from 'node:process'
4
- import autoprefixer from 'autoprefixer'
5
- import viewport from 'postcss-mobile-forever'
6
- import { loadEnv } from 'vite'
7
- import { createVitePlugins } from './build/vite'
8
-
9
- // import fs from 'fs'
10
- export default ({ mode }: ConfigEnv): UserConfig => {
11
- const root = process.cwd()
12
- const env = loadEnv(mode, root)
13
-
14
- const appProxys = {}
15
-
16
- const v4Server = 'http://aote-office.8866.org:31567'
17
- const v3Server = 'http://aote-office.8866.org:31567'
18
- const OSSServerDev = 'http://192.168.50.67:30351'
19
- // const OSSServerProd = 'http://192.168.50.67:31351'
20
-
21
- return {
22
- base: env.VITE_APP_PUBLIC_PATH,
23
- plugins: [
24
- createVitePlugins(),
25
- ],
26
-
27
- server: {
28
- host: true,
29
- port: 7190,
30
- // https: {
31
- // key: fs.readFileSync('certs/127.0.0.1+2-key.pem'),
32
- // cert: fs.readFileSync('certs/127.0.0.1+2.pem')
33
- // },
34
- proxy: Object.assign({
35
- '/api/af-system/resource': {
36
- target: v4Server,
37
- ws: false,
38
- changeOrigin: true,
39
- },
40
- '/api/invoice': {
41
- target: 'http://219.153.176.6:8400/',
42
- rewrite: (path: string) => path.replace(/^\/api\//, '/'),
43
- ws: false,
44
- changeOrigin: true,
45
- },
46
- '/api/af-system/entity/t_files': {
47
- target: v3Server,
48
- ws: false,
49
- changeOrigin: true,
50
- },
51
- '/resource': {
52
- // pathRewrite: { '^/resource': '/' },
53
- target: v4Server,
54
- changeOrigin: true,
55
- },
56
- // '/api/af-auth/login': {
57
- // target: 'http://127.0.0.1:9200/',
58
- // rewrite: (path: string) => path.replace(/^\/api\/af-auth\//, '/'),
59
- // ws: false,
60
- // changeOrigin: true,
61
- // },
62
- '/api': {
63
- // v3用
64
- // rewrite: (path: string) => path.replace(/^\/api\/af-system\//, '/rs/'),
65
- target: v4Server,
66
- ws: false,
67
- changeOrigin: true,
68
- },
69
- '/oss': {
70
- target: OSSServerDev,
71
- rewrite: (path: string) => path.replace(/^\/oss\//, '/'),
72
- changeOrigin: true,
73
- },
74
- }, appProxys),
75
- },
76
-
77
- resolve: {
78
- alias: {
79
- '~@': path.join(__dirname, './src'),
80
- '@': path.join(__dirname, './src'),
81
- '~': path.join(__dirname, './src/assets'),
82
- '@af-mobile-client-vue3': path.join(__dirname, './src'),
83
- },
84
- },
85
-
86
- css: {
87
- // postcss 官网:www.postcss.com.cn/
88
- postcss: {
89
- plugins: [
90
- // 自动获取浏览器的流行度和能够支持的属性,并为 CSS 规则添加前缀
91
- autoprefixer(),
92
- viewport({
93
- appSelector: '#system-app',
94
- viewportWidth: 375,
95
- maxDisplayWidth: 800,
96
- appContainingBlock: 'auto',
97
- necessarySelectorWhenAuto: '.app-wrapper',
98
- rootContainingBlockSelectorList: ['van-tabbar', 'van-popup'],
99
- }),
100
- ],
101
- },
102
- },
103
-
104
- build: {
105
- chunkSizeWarningLimit: 2048,
106
- rollupOptions: {
107
- output: {
108
- // 打包时分割资源
109
- chunkFileNames: 'static/js/[name]-[hash].js',
110
- entryFileNames: 'static/js/[name]-[hash].js',
111
- assetFileNames: 'static/[ext]/[name]-[hash].[ext]',
112
- manualChunks(id) {
113
- if (id.includes('node_modules'))
114
- return 'third' // 代码分割为第三方包
115
-
116
- if (id.includes('views'))
117
- return 'views' // 代码分割为业务视图
118
- },
119
- },
120
- },
121
- },
122
- }
123
- }
1
+ import type { ConfigEnv, UserConfig } from 'vite'
2
+ import path from 'node:path'
3
+ import process from 'node:process'
4
+ import autoprefixer from 'autoprefixer'
5
+ import viewport from 'postcss-mobile-forever'
6
+ import { loadEnv } from 'vite'
7
+ import { createVitePlugins } from './build/vite'
8
+
9
+ // import fs from 'fs'
10
+ export default ({ mode }: ConfigEnv): UserConfig => {
11
+ const root = process.cwd()
12
+ const env = loadEnv(mode, root)
13
+
14
+ const appProxys = {}
15
+
16
+ const v4Server = 'http://aote-office.8866.org:31567'
17
+ const v3Server = 'http://aote-office.8866.org:31567'
18
+ const OSSServerDev = 'http://192.168.50.67:30351'
19
+ const geoserver = 'http://39.104.49.8:30372'
20
+ // const OSSServerProd = 'http://192.168.50.67:31351'
21
+
22
+ return {
23
+ base: env.VITE_APP_PUBLIC_PATH,
24
+ plugins: [
25
+ createVitePlugins(),
26
+ ],
27
+
28
+ server: {
29
+ host: true,
30
+ port: 7190,
31
+ // https: {
32
+ // key: fs.readFileSync('certs/127.0.0.1+2-key.pem'),
33
+ // cert: fs.readFileSync('certs/127.0.0.1+2.pem')
34
+ // },
35
+ proxy: Object.assign({
36
+ '/api/af-system/resource': {
37
+ target: v4Server,
38
+ ws: false,
39
+ changeOrigin: true,
40
+ },
41
+ '/api/invoice': {
42
+ target: 'http://219.153.176.6:8400/',
43
+ rewrite: (path: string) => path.replace(/^\/api\//, '/'),
44
+ ws: false,
45
+ changeOrigin: true,
46
+ },
47
+ '/api/af-system/entity/t_files': {
48
+ target: v3Server,
49
+ ws: false,
50
+ changeOrigin: true,
51
+ },
52
+ '/resource': {
53
+ // pathRewrite: { '^/resource': '/' },
54
+ target: v4Server,
55
+ changeOrigin: true,
56
+ },
57
+ // '/api/af-auth/login': {
58
+ // target: 'http://127.0.0.1:9200/',
59
+ // rewrite: (path: string) => path.replace(/^\/api\/af-auth\//, '/'),
60
+ // ws: false,
61
+ // changeOrigin: true,
62
+ // },
63
+ // geoserver 转发
64
+ '/linepatrol/geoserver': {
65
+ target: geoserver,
66
+ changeOrigin: true,
67
+ rewrite: path => path.replace(/^\/linepatrol\/geoserver/, '/geoserver'),
68
+ },
69
+ '/api': {
70
+ // v3用
71
+ // rewrite: (path: string) => path.replace(/^\/api\/af-system\//, '/rs/'),
72
+ target: v4Server,
73
+ ws: false,
74
+ changeOrigin: true,
75
+ },
76
+ '/oss': {
77
+ target: OSSServerDev,
78
+ rewrite: (path: string) => path.replace(/^\/oss\//, '/'),
79
+ changeOrigin: true,
80
+ },
81
+ }, appProxys),
82
+ },
83
+
84
+ resolve: {
85
+ alias: {
86
+ '~@': path.join(__dirname, './src'),
87
+ '@': path.join(__dirname, './src'),
88
+ '~': path.join(__dirname, './src/assets'),
89
+ '@af-mobile-client-vue3': path.join(__dirname, './src'),
90
+ },
91
+ },
92
+
93
+ css: {
94
+ // postcss 官网:www.postcss.com.cn/
95
+ postcss: {
96
+ plugins: [
97
+ // 自动获取浏览器的流行度和能够支持的属性,并为 CSS 规则添加前缀
98
+ autoprefixer(),
99
+ viewport({
100
+ appSelector: '#system-app',
101
+ viewportWidth: 375,
102
+ maxDisplayWidth: 800,
103
+ appContainingBlock: 'auto',
104
+ necessarySelectorWhenAuto: '.app-wrapper',
105
+ rootContainingBlockSelectorList: ['van-tabbar', 'van-popup'],
106
+ }),
107
+ ],
108
+ },
109
+ },
110
+
111
+ build: {
112
+ chunkSizeWarningLimit: 2048,
113
+ rollupOptions: {
114
+ output: {
115
+ // 打包时分割资源
116
+ chunkFileNames: 'static/js/[name]-[hash].js',
117
+ entryFileNames: 'static/js/[name]-[hash].js',
118
+ assetFileNames: 'static/[ext]/[name]-[hash].[ext]',
119
+ manualChunks(id) {
120
+ if (id.includes('node_modules'))
121
+ return 'third' // 代码分割为第三方包
122
+
123
+ if (id.includes('views'))
124
+ return 'views' // 代码分割为业务视图
125
+ },
126
+ },
127
+ },
128
+ },
129
+ }
130
+ }