pass url when setup preferences

This commit is contained in:
unstop
2016-12-12 11:35:36 +08:00
parent 015d64ea63
commit a6b5cb5f5d
3 changed files with 7 additions and 2 deletions

View File

@@ -17,6 +17,7 @@
@property (nonatomic, strong) QSHWebView *webView;
- (instancetype)initWithIdentifier:(NSString *)identifier
url:(NSString *)url
toolbarImage:(NSImage *)image
toolbarLabel:(NSString *)label
height:(NSInteger)height

View File

@@ -11,6 +11,7 @@
@interface QSHPreferencesViewController ()
@property (nonatomic) NSString *identifier;
@property (nonatomic) NSString *url;
@property (nonatomic) NSImage *toolbarItemImage;
@property (nonatomic) NSString *toolbarItemLabel;
@property (nonatomic) NSInteger height;
@@ -24,6 +25,7 @@
@synthesize identifier = _identifier;
- (instancetype)initWithIdentifier:(NSString *)identifier
url:(NSString *)url
toolbarImage:(NSImage *)image
toolbarLabel:(NSString *)label
height:(NSInteger)height
@@ -32,6 +34,7 @@
self = [super initWithNibName:@"QSHPreferencesViewController" bundle:nil];
if (self) {
_identifier = identifier;
_url = url;
_toolbarItemImage = image;
_toolbarItemLabel = label;
_height = height;
@@ -59,8 +62,8 @@
[self _createViews];
NSString *url = [[NSURL URLWithString:kPreferencesDirectory relativeToURL:[[NSBundle mainBundle] resourceURL]] absoluteString];
url = [url stringByAppendingString:[NSString stringWithFormat:@"%@.html", self.identifier]];
NSString *url = [[NSURL URLWithString:kRootPath relativeToURL:[[NSBundle mainBundle] resourceURL]] absoluteString];
url = [url stringByAppendingString:_url];
[QSHWebViewDelegate initWebviewWithBridge:_webView url:[NSURL URLWithString:url] webDelegate:_delegate isMain:NO];
}

View File

@@ -407,6 +407,7 @@ static const NSInteger kPreferencesDefaultHeight = 192;
NSInteger height = preferences[@"height"] ? [preferences[@"height"] integerValue]: kPreferencesDefaultHeight;
QSHPreferencesViewController *vc = [[QSHPreferencesViewController alloc]
initWithIdentifier:preferences[@"identifier"]
url:preferences[@"url"]
toolbarImage:[NSImage imageNamed:preferences[@"icon"]]
toolbarLabel:preferences[@"label"]
height:height