Skip to content

Commit 194dee7

Browse files
committed
修改跳转地图工作空间逻辑;默认游客工作空间;调整符号库/编辑逻辑
1 parent cce2852 commit 194dee7

17 files changed

Lines changed: 287 additions & 250 deletions

File tree

‎App.js‎

Lines changed: 20 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { scaleSize, AudioAnalyst, Toast } from './src/utils'
1212
import { ConstPath } from './src/constants'
1313
import NavigationService from './src/containers/NavigationService'
1414

15-
import { SpeechManager, Utility, Environment, OnlineService } from 'imobile_for_reactnative'
15+
import { SpeechManager, Utility, OnlineService, SMap, WorkspaceType } from 'imobile_for_reactnative'
1616

1717
const { persistor, store } = ConfigStore()
1818

@@ -57,6 +57,7 @@ class AppRoot extends Component {
5757
await this.initDirectories()
5858
// await this.initEnvironment()
5959
await this.initSpeechManager()
60+
await this.initCustomerWorkspace()
6061
}).bind(this)()
6162
}
6263

@@ -87,6 +88,7 @@ class AppRoot extends Component {
8788
let isCreate = false, absolutePath = ''
8889
for (let i = 0; i < paths.length; i++) {
8990
let path = ConstPath[paths[i]]
91+
if (typeof path !== 'string') continue
9092
absolutePath = await Utility.appendingHomeDirectory(path)
9193
isCreate = await Utility.createDirectory(absolutePath)
9294
}
@@ -98,25 +100,6 @@ class AppRoot extends Component {
98100
}
99101
}
100102

101-
// 初始化环境
102-
initEnvironment = async () => {
103-
try {
104-
let licensePath = await Utility.appendingHomeDirectory(ConstPath.LicensePath)
105-
let en = new Environment()
106-
let isSet = await en.setLicensePath(licensePath)
107-
if (!isSet) {
108-
Toast.show('许可文件设置失败')
109-
return
110-
}
111-
let isInit = await en.initialization()
112-
if (!isInit) {
113-
Toast.show('环境初始化失败')
114-
}
115-
} catch (e) {
116-
Toast.show('环境初始化失败')
117-
}
118-
}
119-
120103
// 初始化录音
121104
initSpeechManager = async () => {
122105
try {
@@ -127,6 +110,23 @@ class AppRoot extends Component {
127110
}
128111
}
129112

113+
// 初始化游客工作空间
114+
initCustomerWorkspace = async () => {
115+
try {
116+
const customerPath = ConstPath.CustomerPath + ConstPath.RelativePath.CustomerWorkspace
117+
let exist = await Utility.fileIsExistInHomeDirectory(customerPath)
118+
!exist && Utility.appendingHomeDirectory(customerPath).then(path => {
119+
SMap.saveWorkspace({
120+
caption: 'Customer',
121+
type: WorkspaceType.SMWU,
122+
server: path,
123+
})
124+
})
125+
} catch (e) {
126+
Toast.show('游客工作空间初始化失败')
127+
}
128+
}
129+
130130
render() {
131131
return (
132132
<View style={{ flex: 1 }}>
@@ -141,27 +141,6 @@ class AppRoot extends Component {
141141
})
142142
}}
143143
/>
144-
{/*<AudioDialog*/}
145-
{/*ref={ref => GLOBAL.AudioDialog = ref}*/}
146-
{/*data={{*/}
147-
{/*layer: this.props.editLayer,*/}
148-
{/*}}*/}
149-
{/*/>*/}
150-
{/*{*/}
151-
{/*(*/}
152-
{/*!this.props.nav.routes ||*/}
153-
{/*this.props.nav.routes && this.props.nav.routes[this.props.nav.index].routeName !== 'MapView'*/}
154-
{/*) &&*/}
155-
{/*<PanAudioButton*/}
156-
{/*onPress={() => {*/}
157-
{/*if (this.props.nav.routes && this.props.nav.routes[this.props.nav.index].routeName === 'MapView') {*/}
158-
{/*GLOBAL.AudioDialog.setVisible(true, 'top')*/}
159-
{/*} else {*/}
160-
{/*GLOBAL.AudioDialog.setVisible(true)*/}
161-
{/*}*/}
162-
{/*}}*/}
163-
{/*ref={ref => GLOBAL.PanAudioButton = ref}/>*/}
164-
{/*}*/}
165144
</View>
166145
)
167146
}
1.66 MB
Binary file not shown.

‎android/app/src/main/java/com/supermap/itablet/MainActivity.java‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ private void initEnvironment() {
4141
}
4242

4343
private void initDefaultData() {
44+
// 拷贝默认的工作空间
45+
String customerWs = SDCARD + "/iTablet/User/Customer/";
46+
String customerWsName = "Customer.smwu";
47+
if (!Utils.fileIsExit(customerWs + customerWsName)) {
48+
Utils.copyAssetFileToSDcard(this, customerWs, customerWsName);
49+
}
50+
// 拷贝默认数据
4451
String localPath = SDCARD + "/iTablet/data/local/";
4552
String defaultZipData = "defaultData.zip";
4653
Utils.copyAssetFileToSDcard(this, localPath, defaultZipData);

‎android/gradlew‎

100644100755
File mode changed.

‎ios/iTablet/AppDelegate.m‎

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,40 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
5151
self.window.rootViewController = _nav;
5252
[self.window makeKeyAndVisible];
5353
54-
[Environment setLicensePath:[NSHomeDirectory() stringByAppendingFormat:@"/Library/Caches/%@",@""]];
55-
NSString *srclic = [[NSBundle mainBundle] pathForResource:@"Trial_License" ofType:@"slm"];
56-
NSString* deslic = [NSHomeDirectory() stringByAppendingFormat:@"/Library/Caches/%@",@"Trial_License.slm"];
57-
if(![[NSFileManager defaultManager] fileExistsAtPath:deslic isDirectory:nil]){
58-
if(![[NSFileManager defaultManager] copyItemAtPath:srclic toPath:deslic error:nil])
59-
NSLog(@"拷贝数据失败");
60-
}
54+
[self initEnvironment];
55+
[self initDefaultData];
56+
6157
self.allowRotation = NO;
6258
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(doSampleCodeNotification:) name:@"RNOpenVC" object:nil];
6359
return YES;
6460
}
61+
62+
#pragma mark - 初始化license
63+
- (void)initEnvironment {
64+
[Environment setLicensePath:[NSHomeDirectory() stringByAppendingFormat:@"/Library/Caches/%@",@""]];
65+
NSString *srclic = [[NSBundle mainBundle] pathForResource:@"Trial_License" ofType:@"slm"];
66+
if (srclic) {
67+
NSString* deslic = [NSHomeDirectory() stringByAppendingFormat:@"/Library/Caches/%@",@"Trial_License.slm"];
68+
if(![[NSFileManager defaultManager] fileExistsAtPath:deslic isDirectory:nil]){
69+
if(![[NSFileManager defaultManager] copyItemAtPath:srclic toPath:deslic error:nil])
70+
NSLog(@"拷贝数据失败");
71+
}
72+
}
73+
}
74+
75+
#pragma mark - 初始化默认数据
76+
- (void)initDefaultData {
77+
// 初始化游客工作空间
78+
NSString *srclic = [[NSBundle mainBundle] pathForResource:@"Customer" ofType:@"smwu"];
79+
if (srclic) {
80+
NSString* deslic = [NSHomeDirectory() stringByAppendingFormat:@"/Documents/iTablet/user/Customer/%@",@"Customer.smwu"];
81+
if(![[NSFileManager defaultManager] fileExistsAtPath:deslic isDirectory:nil]){
82+
if(![[NSFileManager defaultManager] copyItemAtPath:srclic toPath:deslic error:nil])
83+
NSLog(@"拷贝数据失败");
84+
}
85+
}
86+
}
87+
6588
-(void)doSampleCodeNotification:(NSNotification *)notification
6689
{
6790
NSLog(@"成功收到===>通知");

‎src/constants/ConstModule.js‎

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import NavigationService from '../containers/NavigationService'
22
import constants from '../containers/workspace/constants'
33
import ConstOnline from './ConstOnline'
4-
import { Utility, SMap, WorkspaceType } from 'imobile_for_reactnative'
4+
import { Utility } from 'imobile_for_reactnative'
55
import { ConstPath } from '../constants'
66
import { Platform } from 'react-native'
77

8-
let count = 0
9-
108
export default [
119
{
1210
key: '地图制图',
@@ -16,7 +14,7 @@ export default [
1614
action: () => {
1715
NavigationService.navigate('MapView', {
1816
operationType: constants.MAP_EDIT,
19-
...ConstOnline['TD'],
17+
wsData: ConstOnline['TD'],
2018
})
2119
},
2220
},
@@ -52,16 +50,10 @@ export default [
5250
baseImage: require('../assets/home/icon_rightbottom_vip.png'),
5351
moduleImage: require('../assets/home/icon_navigation.png'),
5452
action: () => {
55-
Utility.appendingHomeDirectory(ConstPath.CustomerPath).then(path => {
56-
SMap.saveWorkspace({
57-
caption: 'Customer',
58-
type: WorkspaceType.SMWU,
59-
// version: 1.0,
60-
server: path,
61-
user: '321',
62-
password: '123',
63-
})
64-
})
53+
// NavigationService.navigate('MapView', { // 若未登录,则打开游客工作空间
54+
// wsData: ConstOnline['Baidu'],
55+
// isExample: false,
56+
// })
6557
},
6658
},
6759
{
@@ -75,23 +67,28 @@ export default [
7567
title: '外业采集',
7668
baseImage: require('../assets/home/icon_rightbottom_vip.png'),
7769
moduleImage: require('../assets/home/icon_collection.png'),
78-
action: async () => {
79-
// NavigationService.navigate('MapView', ConstOnline['Baidu'])
80-
// let path = ConstPath.LocalDataPath + 'beijing_new/beijing.smwu'
81-
let path = ConstPath.LocalDataPath + 'IndoorNavigationData/beijing.smwu'
82-
let filePath = await Utility.appendingHomeDirectory(path)
83-
let exist = await Utility.fileIsExistInHomeDirectory(path)
84-
if (exist && count % 2 === 0) {
85-
// NavigationService.navigate('MapView', { type: '', path: path, isExample: true })
70+
action: async user => {
71+
const customerPath =
72+
ConstPath.CustomerPath + ConstPath.RelativePath.CustomerWorkspace
73+
let wsPath = await Utility.appendingHomeDirectory(customerPath)
74+
let exist = await Utility.fileIsExistInHomeDirectory(customerPath)
75+
if (exist && !user.userName) {
8676
NavigationService.navigate('MapView', {
87-
path: filePath,
88-
type: 'LOCAL',
77+
// 若未登录,则打开游客工作空间
78+
wsData: [
79+
{
80+
DSParams: { server: wsPath },
81+
type: 'Workspace',
82+
},
83+
ConstOnline['Baidu'],
84+
],
85+
mapName: ConstOnline['Baidu'].mapName,
8986
isExample: false,
9087
})
9188
} else {
92-
NavigationService.navigate('MapView', ConstOnline['Baidu'])
89+
// TODO 打开对应user的工作空间
90+
NavigationService.navigate('MapView', { wsData: ConstOnline['Baidu'] })
9391
}
94-
count++
9592
},
9693
},
9794
{

0 commit comments

Comments
 (0)