Skip to content

Commit

Permalink
阿里云OSS增加自定义域名
Browse files Browse the repository at this point in the history
  • Loading branch information
boatrainlsz committed Mar 30, 2022
1 parent 2f17ab9 commit f272d87
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<grid id="27dc6" binding="rootPanel" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="973" height="565"/>
<xy x="20" y="20" width="973" height="582"/>
</constraints>
<properties/>
<border type="none"/>
Expand Down Expand Up @@ -419,7 +419,7 @@
</grid>
</children>
</grid>
<grid id="eaf14" layout-manager="GridLayoutManager" row-count="12" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="eaf14" layout-manager="GridLayoutManager" row-count="14" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<tabbedpane title="Aliyun OSS"/>
Expand Down Expand Up @@ -461,7 +461,7 @@
</component>
<component id="571c4" class="javax.swing.JLabel">
<constraints>
<grid row="9" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="11" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Style suffix"/>
Expand Down Expand Up @@ -515,7 +515,7 @@
</component>
<component id="63ba9" class="javax.swing.JTextField" binding="textAliyunStyleSuffix">
<constraints>
<grid row="9" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<grid row="11" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
Expand All @@ -525,15 +525,15 @@
</component>
<component id="a86fc" class="javax.swing.JLabel">
<constraints>
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="8" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="New fileame"/>
</properties>
</component>
<component id="1932" class="javax.swing.JComboBox" binding="comboAliyunNewFilenameTemplate">
<constraints>
<grid row="6" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
<grid row="8" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<model>
Expand All @@ -549,23 +549,23 @@
</component>
<component id="27dfb" class="javax.swing.JTextField" binding="textAliyunNewFilenameCustomText">
<constraints>
<grid row="7" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<grid row="9" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties/>
</component>
<component id="5c110" class="javax.swing.JLabel">
<constraints>
<grid row="8" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="10" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="&lt;html&gt;&#10;&lt;b&gt;Variable&lt;/b&gt;&lt;br/&gt; &#10;- &lt;code&gt;${MDFile}&lt;/code&gt;: Current markdown file name, such as &quot;example&quot; &lt;br/&gt;&#10;- &lt;code&gt;${Suffix}&lt;/code&gt;: Current image file suffix, such as &quot;png&quot; &lt;br/&gt;&#10;- &lt;code&gt;${yyyyMMdd}&lt;/code&gt;: Current date, such as &quot;20200401&quot; &lt;br/&gt;&#10;- &lt;code&gt;${Timestamp}&lt;/code&gt;: Current time stamp, such as &quot;1585819668627&quot; &lt;br/&gt;&#10;- &lt;code&gt;${UUID}&lt;/code&gt;: Random 32-bit string, such as &quot;67b52ab3e50643e08b8cb980c2ecdaed&quot; &lt;br/&gt;&#10;&lt;/html&gt;" noi18n="true"/>
</properties>
</component>
<component id="aeca0" class="javax.swing.JLabel">
<constraints>
<grid row="10" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="12" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="&lt;html&gt;&#10;If you need to, you can create a picture style or transcode style, and fill it in here. &lt;br/&gt;&#10;&lt;b&gt;Reference website:&lt;/b&gt;&#10;&lt;a href=&quot;https://help.aliyun.com/document_detail/44686.html?spm=5176.8466032.help.dexternal.1649145023i8ze&quot;&gt;https://help.aliyun.com/document_detail/44686.html&lt;a/&gt;&#10;&lt;html&gt;"/>
Expand All @@ -591,7 +591,7 @@
<grid id="77be" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="11" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="13" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
Expand All @@ -611,6 +611,32 @@
</hspacer>
</children>
</grid>
<component id="aaedd" class="javax.swing.JLabel">
<constraints>
<grid row="7" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Endpoint"/>
</properties>
</component>
<component id="f1124" class="javax.swing.JTextField" binding="aliyunCustomDomain">
<constraints>
<grid row="6" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
<properties>
<text value=""/>
</properties>
</component>
<component id="f61b1" class="javax.swing.JLabel">
<constraints>
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Custom Domain"/>
</properties>
</component>
</children>
</grid>
<grid id="c9473" layout-manager="GridLayoutManager" row-count="10" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public class MISConfigurationInterfaceForm {
protected JTextField textAliyunNewFilenameCustomText;
protected JTextField textAliyunStyleSuffix;
protected JButton buttonTestAliyun;
protected JTextField aliyunCustomDomain;


// minio config
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class MISConfig {
var aliyunBucket: String = ""
var aliyunAccessKey: String = ""
var aliyunSecretKey: String = ""
var aliyunCustomDomain: String = ""
var aliyunEndpoint: String = "oss-cn-chengdu.aliyuncs.com"
var aliyunStyleSuffix: String? = "?x-oss-process=image/auto-orient,1/interlace,1/quality,q_50/format,jpg"
var aliyunNewFilenameTemplate: String = ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class MISConfigView : MISConfigurationInterfaceForm(), SearchableConfigurable, C
this.textAliyunAccessKey.text = it.aliyunAccessKey
this.textAliyunSecretKey.text = it.aliyunSecretKey
this.textAliyunEndpoint.text = it.aliyunEndpoint
this.aliyunCustomDomain.text = it.aliyunCustomDomain
this.comboAliyunNewFilenameTemplate.selectedItem = it.aliyunNewFilenameTemplate
this.textAliyunNewFilenameCustomText.text = it.aliyunNewFilenameCustomText
this.textAliyunStyleSuffix.text = it.aliyunStyleSuffix
Expand Down Expand Up @@ -175,7 +176,8 @@ class MISConfigView : MISConfigurationInterfaceForm(), SearchableConfigurable, C
this.comboAliyunNewFilenameTemplate,
this.textAliyunNewFilenameCustomText,
this.textAliyunStyleSuffix,
this.buttonTestAliyun
this.buttonTestAliyun,
this.aliyunCustomDomain
)
this.batchSetComponentEnabled(this.checkAliyunEnable.isSelected, *components)
this.checkAliyunEnable.addActionListener {
Expand Down Expand Up @@ -359,6 +361,7 @@ class MISConfigView : MISConfigurationInterfaceForm(), SearchableConfigurable, C
this.textAliyunAccessKey.text,
this.textAliyunSecretKey.text,
this.textAliyunEndpoint.text,
this.aliyunCustomDomain.text,
this.comboAliyunNewFilenameTemplate.selectedItem,
this.textAliyunNewFilenameCustomText.text,
this.textAliyunStyleSuffix.text
Expand Down Expand Up @@ -455,6 +458,7 @@ class MISConfigView : MISConfigurationInterfaceForm(), SearchableConfigurable, C
it.aliyunAccessKey = this.textAliyunAccessKey.text.trim()
it.aliyunSecretKey = this.textAliyunSecretKey.text.trim()
it.aliyunEndpoint = this.textAliyunEndpoint.text.trim()
it.aliyunCustomDomain = this.aliyunCustomDomain.text.trim()
it.aliyunNewFilenameTemplate = this.comboAliyunNewFilenameTemplate.selectedItem?.toString()!!.trim()
it.aliyunNewFilenameCustomText = this.textAliyunNewFilenameCustomText.text.trim()
it.aliyunStyleSuffix = this.textAliyunStyleSuffix.text.trim()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,13 @@ class MISAliyunOSSFileStore : MISAbstractOSSFileStore() {
}

override fun previewUrl(fileKey: String, styleSuffix: Boolean): String {
return "https://${state.aliyunBucket}.${state.aliyunEndpoint}/${fileKey}${if (styleSuffix) state.aliyunStyleSuffix else ""}"
MISConfigService.getInstance().state!!.aliyunCustomDomain
return if (MISConfigService.getInstance().state!!.aliyunCustomDomain.isEmpty()) {
"https://${state.aliyunBucket}.${state.aliyunEndpoint}/${fileKey}${if (styleSuffix) state.aliyunStyleSuffix else ""}"
} else {
"https://${state.aliyunCustomDomain}/${fileKey}${if (styleSuffix)
state.aliyunStyleSuffix else ""}"
}
}

}

0 comments on commit f272d87

Please sign in to comment.