3鍒嗐仹銇с亶銈婱ilkCocoa銈掍娇鐢ㄣ仐銇熺煭绺甎RL銈点偆銉堜綔鎴愭柟娉

鐭府URL銈点兗銉撱偣銇仱銇勩仸

URL鐭府銈点兗銉撱偣銇ㄣ伅闀枫亜鏂囧瓧鍒椼伄URL銈掔煭銇忓鎻涖仚銈嬨偟銉笺儞銈广

goo.glbit.ly銇仼銇屾湁鍚嶃

鐭府URL銈点兗銉撱偣銈掍娇鐢ㄣ仚銈嬨儑銉°儶銉冦儓

鐭府URL銈点兗銉撱偣銇究鍒┿仩銇URL銇獮灏俱伀+瑷樺彿銈掍粯銇戙倠銇ㄣ併偄銈偦銈规暟銇仼銇岀涓夎呫仾銇┿伀鐭ャ倝銈屻仸銇椼伨銇銇熴倎銆併儞銈搞儘銈广仹浣跨敤銇欍倠銇伅濂姐伨銇椼亸銇亜銆

鑷ぞ銇偟銈ゃ儓鍐呫伀鐭府URL鐢熸垚銉氥兗銈搞倰浣滄垚

鑷ぞ銇偟銈ゃ儓鍐呫伀鐭府URL鐢熸垚銉氥兗銈搞倰浣滄垚銇欍倢銇扮涓夎呫仾銇┿伀鐭府URL銇偄銈偦銈规暟銇仼銈掔煡銈夈倢銇︺仐銇俱亞蹇冮厤銇仾銇忋仾銈嬨

鐭府URL鐢熸垚銉氥兗銈搞倰浣滄垚銇欍倠銇ㄤ綔銈嬨伄銇檪闁撱亴銇嬨亱銈嬨仺鎬濄亞浜恒亴澶氥亜銇ㄦ濄亞銇屻MilkCocoa銈掍娇鐢ㄣ仚銈屻伆3鍒嗐亸銈夈亜銇т綔鎴愩仹銇嶃倠銆

MilkCocoa銇ㄣ伅

Milkcocoa銇両oT銉囥儛銈ゃ偣銉汇偣銉炪兗銉堛儠銈┿兂銉籔C闁撱仹绨″崢銇儶銈€儷銈裤偆銉犮仾銉囥兗銈裤伄銈勩倞鍙栥倞銇屽嚭鏉ャ倠銈堛亞銇仾銈嬨偗銉┿偊銉夈儣銉┿儍銉堛儠銈┿兗銉犮仹銇欍

浠ヤ笂銇倛銇嗐伀鍏紡銈点偆銉堛伀鏇搞亱銈屻仸銇勩倠銆

绨″崢銇█銇嗐仺JavaScript銇犮亼銇у埄鐢ㄣ仹銇嶃倠绨℃槗銉囥兗銈裤儥銉笺偣(MySQL)銇倛銇嗐仾銈傘伄銇犮

Milkcocoa銇叕寮忋偟銈ゃ儓銇с偄銈偊銉炽儓銈掍綔鎴愩仚銈嬨仺銉囥兗銈裤倰淇濆瓨銇椼仧銈娿仚銈嬪牬鎵銈掍娇鐢ㄣ仹銇嶃倠銈堛亞銇仾銈嬨(銉囥兗銈裤偣銉堛偄)Milkcocoa銇叕寮忋偟銈ゃ儓銇с偄銈偊銉炽儓銈掍綔鎴愩仚銈嬨仺銉囥兗銈裤倰淇濆瓨銇椼仧銈娿仚銈嬪牬鎵銈掍娇鐢ㄣ仹銇嶃倠銈堛亞銇仾銈

銈炽兗銉囥偅銉炽偘鎵嬮爢

銇俱仛鐭府URL銆佺煭绺甎RL銇伔绉诲厛URL銆佺煭绺甎RL鐧婚尣銉溿偪銉炽佺祼鏋溿倰琛ㄧず銇欍倠鍫存墍銈扝TML銇ф浉銇忋

<table>
  <tr>
    <td>iwb.jp/b?</td>
    <td><input type="text" value="" id="val"></td>
  </tr>
  <tr>
    <td>閬风Щ鍏圲RL</td>
    <td><input type="url" value="" id="url"></td>
  </tr>
</table>
<p>
  <button id="b">鐭府URL鐧婚尣</button>
</p>
<p id="r"></p>

娆°伀銉囥兗銈裤伄銈勩倞鍙栥倞銈掋仚銈婮avaScript銈掕杩般仚銈嬨

銇俱仛鏈鍒濄伀Milkcocoa銈掍娇銇堛倠銈堛亞銇玬ilkcocoa.js銇╪ew MilkCocoa('ID')銈掕銇胯炯銈銆

ID銇儴鍒嗐伅銈€偒銈︺兂銉堛伀銈堛仯銇︾暟銇倠銆

// <script src="https://cdn.mlkcca.com/v0.6.0/milkcocoa.js"></script>
const milkcocoa = new MilkCocoa('vuejcx8418w.mlkcca.com');

娆°伀URL銇?浠ラ檷銇儜銉┿儭銉笺偪銉笺伄鍙栧緱銈凪ilkcocoa銇儑銉笺偪銈掑彇寰椼仚銈嬨偝銉笺儔銈掕拷鍔犮仚銈嬨

const ds = milkcocoa.dataStore('urls');
const b = document.getElementById('b');
const c = document.getElementById('c');
const r = document.getElementById('r');
const p = location.search.substring(1);
let datas;
milkcocoa.dataStore('urls').stream().next((err, data) => {
  datas = data.filter(x => x.value.val);
  datas.forEach(x => {
    if (x.value.val === p) {
      location.href = x.value.url
    }
  });
});

娆°伀鐧婚尣銉溿偪銉炽倰鎶笺仐銇熴倝Milkcocoa銇儑銉笺偪銈掔櫥閷层仚銈嬪嚘鐞嗐仺杩藉姞銇欍倠銆

// 鐧婚尣銉溿偪銉炽倰鎶笺仐銇熴倝鐧婚尣
b.addEventListener('click', () => {
  const val = document.getElementById('val').value;
  const url = document.getElementById('url').value;
  if (!val || !url) return;

  // 鐧婚尣娓堛伩銇煭绺甎RL銇嚘鐞嗐倰涓柇
  if (datas.find(x => x.value.val === val)) {
    r.textContent = '銇撱伄鐭府URL銇櫥閷叉笀銇裤仹銇欍';
    return;
  }

  // 鐭府URL銈掔櫥閷
  ds.push({val: val, url: url});
  r.innerHTML =
`<pre>鐭府URL銈掔櫥閷层仐銇俱仐銇熴
iwb.jp/b?${val}
鈫
${url}</pre>`;

  // 鏈鏂般伄銉囥兗銈裤伀鏇存柊
  milkcocoa.dataStore('urls').stream().next((err, data) => {
    datas = data.filter(x => x.value.val);
  });
});

浠ヤ笂銇墜闋嗐仹绨″崢銇玀ilkCocoa銈掍娇鐢ㄣ仐銇熺煭绺甎RL銈点偆銉堛倰浣滄垚銇欍倠銇撱仺銇屻仹銇嶃倠銆

渚嬨亪銇https://iwb.jp/b?svg銇嬨倝https://iwb.jp/svg-file-how-to-use/銇伔绉汇仐銇熴亜鍫村悎銇笅鍥炽伄銈堛亞鐧婚尣銇欍倠銆https://iwb.jp/b?svg銇嬨倝https://iwb.jp/svg-file-how-to-use/銇伔绉汇仐銇熴亜鍫村悎銇亾銇倛銇嗙櫥閷

MilkCocoa鐭府URL銈点偆銉堛偟銉炽儣銉