Skip to content

Commit

Permalink
feat: support private link
Browse files Browse the repository at this point in the history
  • Loading branch information
liaojiawei committed May 11, 2024
1 parent d3b961d commit e4851f3
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 4 deletions.
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
registry=https://registry.npmmirror.com/
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8.2.1
10 changes: 7 additions & 3 deletions app/components/services/oss2.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,20 +111,24 @@ angular.module('web').factory('ossSvs2', [

function getClient3(opt) {
const options = prepaireOptions(opt);
const privateLink = localStorage.getItem(Const.PRIVATE_LINK);
const isPrivateLink = privateLink !== null;
const final = {
accessKeyId: options.accessKeyId,
accessKeySecret: options.secretAccessKey,
bucket: opt.bucket,
endpoint: options.endpoint,
endpoint: isPrivateLink ? privateLink : options.endpoint,
region: opt.region,
timeout: options.httpOptions.timeout,
cname: options.cname,
isRequestPay: options.isRequestPayer
cname: isPrivateLink ? false : options.cname,
isRequestPay: options.isRequestPayer,
sldEnable: isPrivateLink
};

if (Object.prototype.hasOwnProperty.call(options, 'securityToken')) {
final.stsToken = options.securityToken;
}
console.log("client3 options", final);

const client = new AliOSS(final);

Expand Down
1 change: 1 addition & 0 deletions app/const.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ angular.module('web').factory('Const', [
AUTH_HIS: 'auth-his',
AUTH_KEEP: 'auth-keep',
KEY_REMEMBER: 'auth-remember',
PRIVATE_LINK: "private-link",
KEEP_ME_LOGGED_IN: 'keep-me-logged-in',
SHOW_HIS: 'show-his',
SHOW_REQUEST_PAY: 'show-request-pay',
Expand Down
22 changes: 21 additions & 1 deletion app/main/auth/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
</label>
<div class="col-sm-8" style="padding: 0">
<div
ng-class="{'col-sm-9':eptplType=='default','col-sm-4':eptplType=='customize'||eptplType=='cname'}"
ng-class="{'col-sm-9':eptplType=='default','col-sm-4':eptplType=='customize'||eptplType=='cname'||eptplType=='privateLink'}"
>
<select
class="form-control"
Expand All @@ -86,6 +86,7 @@
</option>
<option value="customize">{{'customize'|translate}}</option>
<option value="cname">cname</option>
<option value="privateLink">私网连接</option>
</select>
</div>
<div
Expand Down Expand Up @@ -145,6 +146,25 @@
placeholder="http(s)://"
/>
</div>
<!--// 私网连接 -->
<div
style="display: flex; justify-content: space-around"
class="col-sm-8"
style="padding-left: 0"
ng-if="eptplType=='privateLink'"
ng-class="{'has-error':!form1.privateLink.$valid}"
>
<input
type="text"
required
ng-model="item.privateLink"
ng-pattern="/^http(s)?\:\/\//"
class="form-control"
id="privateLink"
name="privateLink"
placeholder="http(s)://"
/>
</div>
</div>
</div>
<div
Expand Down
6 changes: 6 additions & 0 deletions app/main/auth/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,12 @@ angular.module('web').controller('loginCtrl', [
if (!form1.$valid) { return; }

localStorage.setItem(KEY_REMEMBER, $scope.flags.remember);
const isPrivateLink = $scope.eptplType === "privateLink";
if (isPrivateLink) {
localStorage.setItem(Const.PRIVATE_LINK, $scope.privateLink);
} else {
localStorage.removeItem(Const.PRIVATE_LINK);
}
// osspath 默认给一个 '',防止出现 osspath 为 undefined, 导致后续逻辑报错情况
// 可通过 delete $scope.item.osspath 复现后续错误逻辑
$scope.item.osspath = $scope.item.osspath || '';
Expand Down
1 change: 1 addition & 0 deletions app/main/files/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,7 @@ angular
);

var info = ossSvs2.parseOSSPath(addr);
console.log("info", info);

if (info.key) {
var lastGan = info.key.lastIndexOf('/');
Expand Down

0 comments on commit e4851f3

Please sign in to comment.