mirror of
https://gitee.com/shuto/cordova-plugin-file-opener2.git
synced 2025-01-31 12:02:49 +08:00
Merge pull request #26 from Gillardo/master
Added support for Windows. WP8 file location change
This commit is contained in:
commit
01c0900696
@ -46,4 +46,12 @@
|
||||
</config-file>
|
||||
<source-file src="src/wp8/FileOpener2.cs" />
|
||||
</platform>
|
||||
|
||||
|
||||
<!-- windows -->
|
||||
<platform name="windows">
|
||||
<js-module src="src/windows/fileOpener2Proxy.js" name="fileOpener2Proxy">
|
||||
<merges target="" />
|
||||
</js-module>
|
||||
</platform>
|
||||
</plugin>
|
||||
|
26
src/windows/fileOpener2Proxy.js
Normal file
26
src/windows/fileOpener2Proxy.js
Normal file
@ -0,0 +1,26 @@
|
||||
|
||||
var cordova = require('cordova'),
|
||||
fileOpener2 = require('./FileOpener2');
|
||||
|
||||
module.exports = {
|
||||
|
||||
open: function (successCallback, errorCallback, args) {
|
||||
Windows.Storage.StorageFile.getFileFromPathAsync(args[0]).then(function (file) {
|
||||
var options = new Windows.System.LauncherOptions();
|
||||
options.displayApplicationPicker = true;
|
||||
|
||||
Windows.System.Launcher.launchFileAsync(file, options).then(function (success) {
|
||||
if (success) {
|
||||
successCallback();
|
||||
} else {
|
||||
errorCallback();
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
require("cordova/exec/proxy").add("FileOpener2", module.exports);
|
||||
|
@ -17,16 +17,13 @@ namespace WPCordovaClassLib.Cordova.Commands
|
||||
public async void open(string options)
|
||||
{
|
||||
string[] args = JSON.JsonHelper.Deserialize<string[]>(options);
|
||||
var fileName = System.IO.Path.GetFileName(args[0]);
|
||||
|
||||
string aliasCurrentCommandCallbackId = args[2];
|
||||
|
||||
try
|
||||
{
|
||||
// Access isolated storage.
|
||||
StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;
|
||||
|
||||
// Access the file.
|
||||
StorageFile file = await local.GetFileAsync(fileName);
|
||||
// Get the file.
|
||||
StorageFile file = await Windows.Storage.StorageFile.GetFileFromPathAsync(args[0]);
|
||||
|
||||
// Launch the bug query file.
|
||||
await Windows.System.Launcher.LaunchFileAsync(file);
|
||||
|
Loading…
Reference in New Issue
Block a user