import Vue from 'nativescript-vue' import App from './components/App' import * as Sqlite from 'nativescript-sqlite'; import RadListView from 'nativescript-ui-listview/vue'; let initDb = function (db) { db.execSQL('create table answer_sheet(' + ' `sheetName` text, `questionaireId` int, ' + ' `status` int, `startTime` int, `endTime` int, ' + ' `locationLong` NUMERIC, `locationLat` NUMERIC, ' + ' `answerJson` text, `dataUploaded` int, ' + ' `hasAudio` int, `audioUploaded` int, ' + ' `userName` text)', function (error) { if (error) { console.error('create table answer_sheet failed', error); } else { console.log('create table answer_sheet success') } }); db.execSQL('create table questionaire (`questionaireId` int, `version` int, `status` int, `contentJson` text )', function (error) { if (error) { console.error('create table questionaire failed', error); } else { console.log('create table questionaire success') } }); db.execSQL('create table version_info (`version_no` float, `description` text)', function (error) { if (error) { console.error('create table version_info failed', error); } else { console.log('create table version_info success') } }) } let updateDb = function (db) { } function getConnectionType() { const connectivityModule = require("@nativescript/core/connectivity"); const myConnectionType = connectivityModule.getConnectionType(); switch (myConnectionType) { case connectivityModule.connectionType.none: // Denotes no Internet connection. console.log('connection type', "No connection"); return 'None'; break; case connectivityModule.connectionType.wifi: // Denotes a WiFi connection. console.log('connection type', "WiFi connection"); return 'WiFi'; break; case connectivityModule.connectionType.mobile: // Denotes a mobile connection, i.e. cellular network or WAN. console.log('connection type', "Mobile connection"); return 'Mobile'; break; case connectivityModule.connectionType.ethernet: // Denotes a ethernet connection. console.log('connection type', "Ethernet connection"); return 'Ethernet'; break; case connectivityModule.connectionType.bluetooth: // Denotes a bluetooth connection. console.log('connection type', "Bluetooth connection"); return 'Bluetooth'; break; default: return 'unknown'; break; } } Vue.use(RadListView); if (TNS_ENV !== 'production') { Vue.use(VueDevtools) } // Prints Vue logs when --env.production is *NOT* set while building Vue.config.silent = (TNS_ENV === 'production') // Vue.prototype.$baseUrl = 'http://127.0.0.1:8080/api'; // Vue.prototype.$baseUrl = 'http://192.168.1.4:8080/api'; Vue.prototype.$baseUrl = 'http://api.scxbzw.com/api'; console.log('audio path', knownFolders.documents().getFolder('audio').path); let dbname = 'my.db'; let dbExist = Sqlite.exists(dbname); console.log('exist db?', Sqlite.exists(dbname)); new Sqlite(dbname).then(database => { Vue.prototype.$db = database; console.log("db.isOpen()? ", database.isOpen() ? "Yes" : "No"); if (!dbExist) { console.log('init db...'); initDb(database); } }); new Vue({ render: h => h('frame', [h(App)]) }).$start()